/* ==========================================================================
   Stocka design system — a custom layer on top of Bootstrap 5.
   Professional corporate blue, fixed sidebar + slim topbar, Inter typography.
   ========================================================================== */

:root {
    /* Brand blue (refined enterprise blue — deliberately not Bootstrap #0d6efd) */
    --stk-primary: #2350a8;
    --stk-primary-dark: #1a3c80;      /* hover / active */
    --stk-primary-soft: #eaf0fb;      /* tinted backgrounds (active nav, focus) */
    --stk-primary-ring: rgba(35, 80, 168, .25);

    /* Surfaces & neutrals */
    --stk-bg: #f4f6fb;                /* app background */
    --stk-surface: #ffffff;           /* cards, sidebar, topbar */
    --stk-sidebar-bg: #ffffff;
    --stk-text: #1f2733;              /* primary text */
    --stk-text-muted: #6b7685;        /* secondary text */
    --stk-border: #e4e8f0;

    /* Status palette */
    --stk-success: #15915a;
    --stk-success-soft: #e4f4ec;
    --stk-danger: #d64545;
    --stk-danger-soft: #fbe9e9;
    --stk-warning: #c47d12;
    --stk-warning-soft: #fbf0db;
    --stk-info: #2f74c4;
    --stk-info-soft: #e7f0fa;

    /* Shape & depth */
    --stk-radius: .625rem;            /* 10px */
    --stk-radius-sm: .375rem;
    --stk-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --stk-shadow: 0 2px 10px rgba(16, 24, 40, .08);

    --stk-sidebar-width: 250px;
    --stk-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ----------------------------------------------------------- base ------- */
body {
    font-family: var(--stk-font);
    background-color: var(--stk-bg);
    color: var(--stk-text);
    font-size: .925rem;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--stk-text); }

a { color: var(--stk-primary); }
a:hover { color: var(--stk-primary-dark); }

code { color: var(--stk-primary-dark); background: var(--stk-primary-soft); padding: .1rem .35rem; border-radius: .25rem; }

/* ------------------------------------------------------ app shell ------- */
.stk-layout { min-height: 100vh; }

.stk-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--stk-sidebar-width);
    background: var(--stk-sidebar-bg);
    border-right: 1px solid var(--stk-border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.stk-sidebar__brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    height: 60px;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--stk-border);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--stk-primary);
    letter-spacing: -.02em;
}
.stk-sidebar__brand .bi { font-size: 1.4rem; }

.stk-nav { padding: .75rem .75rem; overflow-y: auto; flex: 1; }
.stk-nav__section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--stk-text-muted);
    font-weight: 600;
    padding: .9rem .75rem .35rem;
}

.stk-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .75rem;
    margin-bottom: .15rem;
    border-radius: var(--stk-radius-sm);
    color: var(--stk-text);
    text-decoration: none;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background-color .12s, color .12s;
}
.stk-nav-link .bi { font-size: 1.05rem; color: var(--stk-text-muted); width: 1.1rem; text-align: center; }
.stk-nav-link:hover { background: var(--stk-bg); color: var(--stk-text); }
.stk-nav-link.active {
    background: var(--stk-primary-soft);
    color: var(--stk-primary-dark);
    border-left-color: var(--stk-primary);
    font-weight: 600;
}
.stk-nav-link.active .bi { color: var(--stk-primary); }

.stk-nav-link.disabled {
    color: #aab2bf;
    cursor: default;
    pointer-events: none;
    justify-content: space-between;
}
.stk-nav-link.disabled .bi { color: #c2c8d2; }
.stk-soon {
    font-size: .62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--stk-bg);
    color: #98a0ad;
    border: 1px solid var(--stk-border);
    border-radius: 999px;
    padding: .08rem .45rem;
}

/* main column */
.stk-main { margin-left: var(--stk-sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

.stk-topbar {
    position: sticky;
    top: 0;
    height: 60px;
    background: var(--stk-surface);
    border-bottom: 1px solid var(--stk-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    z-index: 1030;
}
.stk-topbar__title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.stk-topbar__right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.stk-topbar__company { color: var(--stk-text-muted); font-weight: 500; font-size: .85rem; }
.stk-topbar__company .bi { color: var(--stk-primary); }

.stk-hamburger { display: none; background: none; border: none; font-size: 1.4rem; color: var(--stk-text); padding: 0; }

.stk-content { padding: 1.6rem 1.5rem; flex: 1; }

.stk-sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, .35);
    z-index: 1035;
}
.stk-sidebar-overlay.show { display: block; }

/* user dropdown trigger */
.stk-user-btn {
    display: flex; align-items: center; gap: .55rem;
    background: none; border: none; color: var(--stk-text);
    font-weight: 500; padding: .25rem .25rem;
}
.stk-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--stk-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem;
}

/* page header (title + actions row inside content) */
.stk-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.stk-page-header h1 { font-size: 1.4rem; margin: 0; }
.stk-page-header .text-muted { font-size: .85rem; }

/* ------------------------------------------------ Bootstrap overrides --- */
.card {
    border: 1px solid var(--stk-border);
    border-radius: var(--stk-radius);
    box-shadow: var(--stk-shadow-sm);
}
.card-header {
    background: var(--stk-surface);
    border-bottom: 1px solid var(--stk-border);
    font-weight: 600;
    padding: .85rem 1.1rem;
}
.card-body { padding: 1.1rem; }

.table { color: var(--stk-text); margin-bottom: 0; }
.table > thead > tr > th {
    background: #f7f9fc;
    color: var(--stk-text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    border-bottom: 1px solid var(--stk-border);
    padding: .7rem .9rem;
}
.table > tbody > tr > td { padding: .75rem .9rem; vertical-align: middle; border-color: var(--stk-border); }
.table-hover > tbody > tr:hover > * { background: var(--stk-primary-soft); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fafbfd; }

/* buttons */
.btn { border-radius: var(--stk-radius-sm); font-weight: 500; }
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 .2rem var(--stk-primary-ring); }
.btn-primary { background-color: var(--stk-primary); border-color: var(--stk-primary); }
.btn-primary:hover, .btn-primary:active { background-color: var(--stk-primary-dark) !important; border-color: var(--stk-primary-dark) !important; }
.btn-outline-primary { color: var(--stk-primary); border-color: var(--stk-primary); }
.btn-outline-primary:hover { background-color: var(--stk-primary); border-color: var(--stk-primary); }
.btn-danger { background-color: var(--stk-danger); border-color: var(--stk-danger); }
.btn-outline-secondary { color: var(--stk-text-muted); border-color: var(--stk-border); }
.btn-outline-secondary:hover { background-color: var(--stk-bg); color: var(--stk-text); border-color: var(--stk-text-muted); }
.btn-link { color: var(--stk-primary); text-decoration: none; }
.btn-link:hover { color: var(--stk-primary-dark); text-decoration: underline; }

/* forms */
.form-label { font-weight: 500; font-size: .85rem; color: var(--stk-text); margin-bottom: .3rem; }
.form-control, .form-select {
    border-color: var(--stk-border);
    border-radius: var(--stk-radius-sm);
    color: var(--stk-text);
    padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--stk-primary);
    box-shadow: 0 0 0 .2rem var(--stk-primary-ring);
}
.form-control[readonly] { background: #f3f5f9; }
.form-text { color: var(--stk-text-muted); font-size: .8rem; }

/* searchable selects */
.searchable-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.stk-searchable-select { position: relative; }
.stk-searchable-select__button {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}
.stk-searchable-select__button.is-placeholder { color: var(--stk-text-muted); }
.stk-searchable-select__menu {
    display: none;
    position: absolute;
    z-index: 1060;
    top: calc(100% + .25rem);
    left: 0;
    right: 0;
    min-width: 14rem;
    padding: .5rem;
    background: var(--stk-surface);
    border: 1px solid var(--stk-border);
    border-radius: var(--stk-radius-sm);
    box-shadow: var(--stk-shadow);
}
.stk-searchable-select.is-open .stk-searchable-select__menu { display: block; }
.stk-searchable-select__options {
    max-height: 15rem;
    overflow-y: auto;
    margin-top: .4rem;
}
.stk-searchable-select__option {
    display: block;
    width: 100%;
    padding: .45rem .55rem;
    border: 0;
    border-radius: var(--stk-radius-sm);
    background: transparent;
    color: var(--stk-text);
    text-align: left;
    font-size: .9rem;
}
.stk-searchable-select__option:hover,
.stk-searchable-select__option:focus,
.stk-searchable-select__option.is-selected {
    background: var(--stk-primary-soft);
    color: var(--stk-primary-dark);
}
.stk-searchable-select__option:disabled {
    color: var(--stk-text-muted);
    cursor: default;
}
.stk-searchable-select__empty {
    padding: .6rem .35rem .25rem;
    color: var(--stk-text-muted);
    font-size: .85rem;
}
.stk-searchable-select--sm .stk-searchable-select__option { font-size: .82rem; padding: .35rem .45rem; }
.stk-quick-select { display: flex; gap: .5rem; align-items: flex-start; }
.stk-quick-select > select,
.stk-quick-select > .stk-searchable-select { flex: 1 1 auto; min-width: 0; }
.stk-quick-select > .btn { flex: 0 0 auto; }

/* document line item grids */
.stk-line-items { margin-bottom: 1.5rem; }
.stk-line-items .card-header,
.stk-line-items .card-footer { padding: 1rem 1.25rem; }
.stk-line-items .table-responsive {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}
.stk-line-items table {
    width: 100%;
    min-width: 0;
    margin-bottom: 0;
}
.stk-line-items th,
.stk-line-items td {
    padding: 1rem .95rem;
    vertical-align: top;
}
.stk-line-items th:first-child,
.stk-line-items td:first-child { min-width: 28rem; }
.stk-line-items th:nth-child(2),
.stk-line-items td:nth-child(2) { min-width: 12rem; }
.stk-line-items th:nth-child(3),
.stk-line-items td:nth-child(3) { min-width: 15rem; }
.stk-line-items .form-control,
.stk-line-items .form-select,
.stk-line-items .stk-searchable-select__button {
    min-height: 2.65rem;
    font-size: .95rem;
}
.stk-line-items .btn-outline-danger {
    min-width: 2.4rem;
    min-height: 2.4rem;
}
.stk-line-items + .d-flex,
.stk-line-items + .mt-3,
.stk-line-items + .form-actions {
    margin-top: 1.25rem !important;
}
.stk-line-validation-summary { margin: 1rem 1.25rem 0; }
.stk-line-error { display: block; }
.stk-searchable-select__button.is-invalid {
    border-color: var(--bs-danger);
    padding-right: calc(1.5em + .75rem);
}

/* categories tree */
.stk-category-name {
    display: flex;
    align-items: center;
    min-height: 2rem;
}
.stk-category-toggle {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--stk-text-muted);
    text-decoration: none;
}
.stk-category-toggle:hover { color: var(--stk-primary); }
.stk-category-spacer {
    width: 1.75rem;
    flex: 0 0 1.75rem;
}

/* status pills */
.stk-pill {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .73rem;
    font-weight: 600;
    line-height: 1;
}
.stk-pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; opacity: .9; }
.stk-pill--success { background: var(--stk-success-soft); color: var(--stk-success); }
.stk-pill--muted   { background: #eef1f6; color: var(--stk-text-muted); }
.stk-pill--warning { background: var(--stk-warning-soft); color: var(--stk-warning); }
.stk-pill--info    { background: var(--stk-info-soft); color: var(--stk-info); }
.stk-pill--danger  { background: var(--stk-danger-soft); color: var(--stk-danger); }

/* keep Bootstrap badges on-palette too */
.badge.bg-success { background-color: var(--stk-success) !important; }
.badge.bg-secondary { background-color: #8a94a3 !important; }

/* alerts */
.alert { border-radius: var(--stk-radius); border: 1px solid transparent; }
.alert-success { background: var(--stk-success-soft); color: #0e6b41; border-color: #bfe3cf; }
.alert-danger { background: var(--stk-danger-soft); color: #a52c2c; border-color: #f1c7c7; }
.alert-info { background: var(--stk-info-soft); color: #1f567f; border-color: #c5dcf1; }

/* dashboard stat cards */
.stk-stat { display: flex; align-items: center; gap: 1rem; }
.stk-stat__icon {
    width: 48px; height: 48px; border-radius: var(--stk-radius);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    background: var(--stk-primary-soft); color: var(--stk-primary);
}
.stk-stat__label { color: var(--stk-text-muted); font-size: .8rem; font-weight: 500; margin: 0; }
.stk-stat__value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; margin: .15rem 0 0; }
.stk-stat__icon--warning { background: var(--stk-warning-soft); color: var(--stk-warning); }
.stk-stat__icon--success { background: var(--stk-success-soft); color: var(--stk-success); }
.stk-stat__icon--info { background: var(--stk-info-soft); color: var(--stk-info); }

.stk-empty { text-align: center; color: var(--stk-text-muted); padding: 2.5rem 1rem; }
.stk-empty .bi { font-size: 2rem; color: #c2c8d2; display: block; margin-bottom: .5rem; }

/* ---------------------------------------------------- login screen ----- */
.stk-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #eef2fb 0%, #f4f6fb 60%); padding: 1rem; }
.stk-login__card { width: 100%; max-width: 410px; background: var(--stk-surface); border: 1px solid var(--stk-border); border-radius: var(--stk-radius); box-shadow: var(--stk-shadow); padding: 2.25rem; }
.stk-login__brand { text-align: center; font-weight: 700; font-size: 1.75rem; color: var(--stk-primary); letter-spacing: -.02em; margin-bottom: .25rem; }
.stk-login__brand .bi { font-size: 1.6rem; }

/* ----------------------------------------------------- responsive ------- */
@media (max-width: 991.98px) {
    .stk-sidebar { transform: translateX(-100%); }
    .stk-sidebar.show { transform: translateX(0); box-shadow: var(--stk-shadow); }
    .stk-main { margin-left: 0; }
    .stk-hamburger { display: inline-flex; }
}
