/* ==========================================================================
   ProVisionI - site.css
   Dark theme by default; light via :root[data-theme="light"]
   Organized: Tokens -> Base/Reset -> Layout -> Typography -> Links
              -> Header/Nav/Footer -> Buttons -> Sections/Cards -> Forms
              -> Hero/Features -> Auth module -> Utilities -> Media queries
   ========================================================================== */

/* 1) THEME TOKENS --------------------------------------------------------- */
:root {
    --bg: #0b0f14;
    --surface: #121821;
    --surface-2: #18202b;
    --surface-3: #1c2633;
    --text: #f0f3f7;
    --muted: #9aa7b7;
    /* ORANGE ACCENT (dark) */
    --primary: #ff8a00; /* vivid orange */
    --primary-strong: #ff6a00; /* deeper/orange-red */
    --accent: #ffa94d; /* chip/badge */

    --border: #223042;
    --border-strong: #2d3c4f;
    --link: #ffb864; /* readable on dark bg */
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    --success: #22c55e;
    --success-strong: #16a34a;
    --danger: #f87171;
    --danger-strong: #ef4444;
    --info: #38bdf8;
    --info-strong: #0ea5e9;
    --input-bg: #161e2a;
    --input-border: #2f3f54;
    --input-border-strong: #3b4f68;
    --input-placeholder: rgba(154, 167, 183, 0.75);
    --focus-ring: rgba(255, 138, 0, 0.35);
    --focus-ring-strong: rgba(255, 138, 0, 0.55);
    --pill-hover-bg: rgba(255, 138, 0, 0.15);
    --pill-active-bg: #ff8a00;
    --pill-active-color: #0b0f14;
    --alert-bg: rgba(255, 138, 0, 0.12);
    --alert-border: rgba(255, 138, 0, 0.45);

    /* Bootstrap primary overrides — forces ALL Bootstrap "primary" utilities orange */
    --bs-primary: #ff8a00;
    --bs-primary-rgb: 255, 138, 0;
    --bs-primary-text-emphasis: #ffa94d;
    --bs-primary-bg-subtle: rgba(255, 138, 0, 0.15);
    --bs-primary-border-subtle: rgba(255, 138, 0, 0.30);
    --bs-link-color: #ffb864;
    --bs-link-color-rgb: 255, 184, 100;
    --bs-link-hover-color: #ff8a00;
    --bs-link-hover-color-rgb: 255, 138, 0;
}

    :root[data-theme="light"] {
        --bg: #f7f8fb;
        --surface: #ffffff;
        --surface-2: #f4f6f9;
        --surface-3: #eef1f6;
        --text: #0b0f14;
        --muted: #556171;
        /* ORANGE ACCENT (light) */
        --primary: #f97316; /* orange-500 */
        --primary-strong: #ea580c; /* orange-600 */
        --accent: #fb923c; /* orange-400 */

        --border: #e3e7ef;
        --border-strong: #cdd5e3;
        --link: #c2410c; /* darker orange on light */
        --shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
        --input-bg: #ffffff;
        --input-border: #d7ddea;
        --input-border-strong: #c2cce0;
        --input-placeholder: rgba(85, 97, 113, 0.7);
        --focus-ring: rgba(249, 115, 22, 0.25);
        --focus-ring-strong: rgba(249, 115, 22, 0.4);
        --pill-hover-bg: rgba(249, 115, 22, 0.12);
        --pill-active-bg: #f97316;
        --pill-active-color: #ffffff;
        --alert-bg: rgba(249, 115, 22, 0.12);
        --alert-border: rgba(249, 115, 22, 0.35);
        --success: #16a34a;
        --success-strong: #15803d;
        --danger: #ef4444;
        --danger-strong: #dc2626;
        --info: #0ea5e9;
        --info-strong: #0284c7;

        /* Bootstrap primary overrides (light) */
        --bs-primary: #f97316;
        --bs-primary-rgb: 249, 115, 22;
        --bs-primary-text-emphasis: #c2410c;
        --bs-primary-bg-subtle: rgba(249, 115, 22, 0.12);
        --bs-primary-border-subtle: rgba(249, 115, 22, 0.25);
        --bs-link-color: #c2410c;
        --bs-link-color-rgb: 194, 65, 12;
        --bs-link-hover-color: #ea580c;
        --bs-link-hover-color-rgb: 234, 88, 12;
    }


/* 2) BASE / RESET --------------------------------------------------------- */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    color-scheme: light dark; /* native controls respect theme */
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}


/* 3) LAYOUT (APP + STICKY FOOTER) ---------------------------------------- */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    padding: 1rem 0 2.5rem;
    flex: 1 0 auto;
}

.app-footer {
    margin-top: auto;
}

.container {
    padding-top: 30px;
    width: min(1400px, 100%);
    margin-inline: auto;
    padding-inline: 1.25rem;
}

.container-nopadding {
    width: min(1400px, 100%);
    margin-inline: auto;
    padding-inline: 1.25rem;
}

/* Normalize Bootstrap tab look to �folder tabs� */
.nav-tabs {
    border-bottom: 1px solid var(--bs-border-color);
}

    .nav-tabs .nav-link {
        border: 1px solid transparent !important;
        border-bottom-color: transparent !important;
        border-radius: .375rem .375rem 0 0 !important;
        background: transparent !important;
        padding: .5rem .75rem;
    }

        .nav-tabs .nav-link:hover {
            border-color: var(--bs-border-color) var(--bs-border-color) transparent !important;
            background: rgba(var(--bs-body-color-rgb, 255,255,255), .03) !important;
        }

        .nav-tabs .nav-link.active {
            border-color: var(--bs-border-color) var(--bs-border-color) transparent !important;
            background-color: var(--bs-body-bg) !important;
            color: var(--bs-body-color) !important;
            font-weight: 600;
        }

        .nav-tabs .nav-link:focus {
            box-shadow: none;
        }


/* 4) TYPOGRAPHY ----------------------------------------------------------- */
h1, h2, h3 {
    line-height: 1.2;
}

.text-muted {
    color: var(--muted) !important;
}

.text-secondary {
    color: var(--muted) !important;
}

.list-group-item {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

    .list-group-item .text-muted,
    .list-group-item .small.text-muted {
        color: var(--muted) !important;
    }

.list-group-item-theme {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

:root[data-theme="light"] .list-group-item-theme {
    background-color: var(--surface);
}


/* 5) LINKS ---------------------------------------------------------------- */
a {
    color: var(--link);
    text-decoration: none;
}

    a:hover, a:focus {
        text-decoration: underline;
    }


/* 6) HEADER / NAV / FOOTER ------------------------------------------------ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(1.05) blur(8px);
}

.brand {
    color: var(--text);
}

.brand-name {
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.brand-logo {
    height: 62px;
    width: auto;
}

.nav-main {
    display: flex;
    gap: .75rem;
    align-items: center;
}

/* Desktop version - always visible on desktop */
.nav-main--desktop {
    display: flex;
}

/* Mobile version - hidden by default, only shown on mobile when active */
.nav-main--mobile {
    display: none;
}

/* Hide close button on desktop */
.nav-close {
    display: none;
}


.account-view-banner {
    background-color: #f6e652;
    color: #2b1700;
    padding: .25rem 0;
}

:root[data-theme="dark"] .account-view-banner {
    color: #1f1400;
}

.account-view-banner__label {
    font-weight: 600;
}

.account-view-banner__action {
    border-color: rgba(45, 26, 5, 0.35);
    color: inherit;
}

    .account-view-banner__action:hover,
    .account-view-banner__action:focus {
        border-color: rgba(45, 26, 5, 0.55);
        background: rgba(0, 0, 0, 0.08);
    }

.nav-link {
    padding: .4rem .8rem;
    border-radius: 999px;
    color: var(--muted);
}

    /* Fallback (rgba) then enhanced (color-mix) so all browsers look decent */
    .nav-link:hover {
        background: rgba(255, 138, 0, 0.18);
        background: color-mix(in oklab, var(--primary) 18%, transparent);
        color: var(--text);
        text-decoration: none;
    }

    .nav-link.active {
        background: rgba(255, 138, 0, 0.28);
        background: color-mix(in oklab, var(--primary) 28%, transparent);
        color: var(--text);
    }

.auth-controls {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    color: var(--text);
    font-size: .95rem;
}

.auth-greeting {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

    .auth-greeting:hover,
    .auth-greeting:focus {
        color: var(--primary);
        text-decoration: none;
    }

.auth-link {
    color: var(--text);
    font-weight: 600;
    padding: .35rem .85rem;
    border-radius: .65rem;
    border: 1px solid var(--border);
    border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
    background: var(--surface-2);
    background: color-mix(in oklab, var(--surface-2) 88%, transparent);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.nav-pills {
    gap: .5rem;
}

.side-nav {
    position: sticky;
    top: 5.5rem;
}

.nav-pills .nav-link {
    border-radius: .75rem;
    border: 1px solid transparent;
    color: var(--muted);
    font-weight: 600;
    background-color: transparent;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

    .nav-pills .nav-link:hover,
    .nav-pills .nav-link:focus {
        background-color: var(--pill-hover-bg);
        color: var(--text);
        border-color: var(--primary);
        border-color: color-mix(in oklab, var(--primary) 35%, transparent);
    }

    .nav-pills .nav-link.active,
    .nav-pills .show > .nav-link {
        background-color: var(--pill-active-bg);
        color: var(--pill-active-color);
        border-color: transparent;
        box-shadow: 0 12px 26px var(--focus-ring);
    }

.nav-link[data-bs-toggle="collapse"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

/* Parent navigation items with children */
.nav-link-parent {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    padding: .75rem 1rem;
}

.nav-chevron {
    font-size: .75rem;
}

/* Submenu container */
.nav-submenu {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    padding-left: 0;
}

/* Child navigation items - more subtle styling */
.nav-link-child {
    padding: .5rem 1rem .5rem 2.5rem !important;
    font-size: 0.9rem;
    font-weight: 500 !important;
}

    .nav-link-child:hover,
    .nav-link-child:focus {
        background-color: var(--bs-secondary-bg) !important;
        color: var(--text) !important;
        border-color: var(--bs-border-color) !important;
        box-shadow: none !important;
    }

    .nav-link-child.active {
        background-color: var(--bs-tertiary-bg) !important;
        color: var(--text) !important;
        border-color: var(--bs-border-color) !important;
        box-shadow: none !important;
        border-left: 3px solid var(--primary);
    }

    .nav-link[data-bs-toggle="collapse"] i {
        transition: transform 0.2s ease;
    }

    .nav-link[data-bs-toggle="collapse"]:not(.collapsed) i {
        transform: rotate(180deg);
    }

.auth-link:hover,
.auth-link:focus {
    color: var(--text);
    background: color-mix(in oklab, var(--primary) 18%, var(--surface));
    border-color: var(--primary);
    text-decoration: none;
}

.logout-form {
    margin: 0;
}

.btn-primary {
    --bs-btn-color: #0b0f14;
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-color: #0b0f14;
    --bs-btn-hover-bg: var(--primary-strong);
    --bs-btn-hover-border-color: var(--primary-strong);
    --bs-btn-active-color: #0b0f14;
    --bs-btn-active-bg: var(--primary-strong);
    --bs-btn-active-border-color: var(--primary-strong);
    --bs-btn-disabled-bg: color-mix(in oklab, var(--primary) 60%, transparent);
    --bs-btn-disabled-border-color: color-mix(in oklab, var(--primary) 60%, transparent);
    background: var(--primary);
    border: 1px solid var(--primary);
    border: 1px solid color-mix(in oklab, var(--primary) 68%, transparent);
    color: #0b0f14;
}

    .btn-primary:hover,
    .btn-primary:focus,
    .btn-primary:active {
        background: var(--primary-strong);
        border-color: var(--primary-strong);
        color: #0b0f14;
    }

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

    .btn-outline-primary:hover {
        color: #0b0f14;
        background-color: var(--primary);
        border-color: var(--primary);
    }

    .btn-outline-primary:focus {
        box-shadow: 0 0 0 0.25rem var(--focus-ring);
    }

    .btn-outline-primary:active,
    .btn-outline-primary.active,
    .btn-outline-primary.dropdown-toggle.show {
        color: #0b0f14;
        background-color: var(--primary-strong);
        border-color: var(--primary-strong);
    }

    .btn-outline-primary:disabled,
    .btn-outline-primary.disabled {
        color: var(--primary);
        background-color: transparent;
    }

/* Pagination */
.page-link {
    color: var(--primary);
    background-color: var(--surface);
    border-color: var(--border);
}

    .page-link:hover {
        color: var(--primary-strong);
        background-color: var(--surface-2);
        border-color: var(--border-strong);
    }

    .page-link:focus {
        color: var(--primary-strong);
        background-color: var(--surface-2);
        box-shadow: 0 0 0 0.25rem var(--focus-ring);
    }

.page-item.active .page-link {
    color: #0b0f14;
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-item.disabled .page-link {
    color: var(--muted);
    background-color: var(--surface);
    border-color: var(--border);
}

/* Bootstrap utility overrides (5.1 hardcodes blue) */
.border-primary {
    border-color: var(--primary) !important;
}

.bg-primary-subtle {
    background-color: var(--bs-primary-bg-subtle, rgba(255, 138, 0, 0.15)) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.btn-icon {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-icon-sm {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: 0.15em;
}

/* UPDATED: allow vertical overflow for dropdowns inside responsive tables */
.table-responsive.table-responsive-actions {
    overflow: visible !important; /* was: overflow-x:auto; overflow-y:visible */
}

/* NEW: ensure no inner table element clips the menu */
.table-responsive-actions table,
.table-responsive-actions thead,
.table-responsive-actions tbody,
.table-responsive-actions tr,
.table-responsive-actions th,
.table-responsive-actions td {
    overflow: visible !important;
}

.table-responsive-actions .dropdown {
    position: relative;
}

/* UPDATED: raise z-index so menu renders above table/card */
.table-responsive-actions .dropdown-menu {
    z-index: 2000;
}

.dropdown-menu-portal {
    z-index: 2000;
}

.dropdown-menu .dropdown-item-form {
    margin: 0;
}

    .dropdown-menu .dropdown-item-form .dropdown-item {
        width: 100%;
        text-align: left;
    }

.theme-toggle {
    background: var(--surface-2);
    background: color-mix(in oklab, var(--surface-2) 88%, transparent);
    border: 1px solid var(--border);
    border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
    color: var(--text);
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

    .theme-toggle:hover,
    .theme-toggle:focus {
        background: color-mix(in oklab, var(--primary) 18%, var(--surface));
        border-color: var(--primary);
        color: var(--text);
    }

.theme-toggle-icon {
    display: none;
    width: 1.35rem;
    height: 1.35rem;
}

.theme-toggle-icon--dark {
    display: block;
}

[data-theme="light"] .theme-toggle-icon--dark {
    display: none;
}

[data-theme="light"] .theme-toggle-icon--light {
    display: block;
}

[data-theme="dark"] .theme-toggle-icon--dark {
    display: block;
}

[data-theme="dark"] .theme-toggle-icon--light {
    display: none;
}

.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.app-footer .container {
    font-size: .9rem;
}

.link-muted {
    color: var(--muted);
}

    .link-muted:hover {
        color: var(--text);
    }


/* Media document tile (JS-rendered file attachment placeholder) */
.media-doc-tile {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-3);
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--muted);
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.media-doc-tile:hover {
    background-color: var(--surface-2);
    border-color: var(--primary);
    color: var(--text);
}


/* Client side menu section dividers */
.side-menu-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.side-menu-section--tinted {
    padding: 1rem;
    margin-top: 1.5rem;
    margin-left: -1rem;
    margin-right: -1rem;
    background-color: color-mix(in oklab, var(--surface-3) 60%, transparent);
    border-radius: 0.5rem;
    border-top: none;
    margin-top: 0;
}

.side-menu-section-label {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}


/* 7) BUTTONS (Bootstrap-friendly, stable text colors) --------------------- */
.btn {
    font-weight: 600;
    border-radius: .6rem;
}

/* Outline-style action */
.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(34, 48, 66, 0.8); /* fallback */
    border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
}

    .btn-outline:hover {
        border-color: var(--primary);
        box-shadow: 0 10px 24px rgba(255, 138, 0, 0.22); /* fallback */
        box-shadow: 0 10px 24px color-mix(in oklab, var(--primary) 22%, transparent);
    }

/* Tinted surface button */
.btn-surface {
    background: rgba(255, 138, 0, 0.10); /* fallback */
    background: color-mix(in oklab, var(--primary) 10%, var(--surface));
    color: var(--text);
    border: 1px solid rgba(255, 138, 0, 0.30); /* fallback */
    border: 1px solid color-mix(in oklab, var(--primary) 30%, var(--border));
}

    .btn-surface:hover {
        background: rgba(255, 138, 0, 0.16); /* fallback */
        background: color-mix(in oklab, var(--primary) 16%, var(--surface));
        border-color: var(--primary);
    }

/* Keep readable button text through state changes (overrides Bootstrap) */
.btn-outline,
.btn-surface {
    --bs-btn-color: var(--text);
    --bs-btn-hover-color: var(--text);
    --bs-btn-active-color: var(--text);
    --bs-btn-disabled-color: color-mix(in oklab, var(--muted) 70%, transparent);
    color: var(--text) !important;
}

    .btn-outline:hover,
    .btn-outline:focus,
    .btn-outline:active,
    .btn-outline:focus-visible,
    .btn-surface:hover,
    .btn-surface:focus,
    .btn-surface:active,
    .btn-surface:focus-visible {
        color: var(--text) !important;
    }


/* Dropdown menus */
.dropdown-menu {
    background-color: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.dropdown-item {
    color: var(--text);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: color-mix(in oklab, var(--primary) 12%, var(--surface-2));
    color: var(--text);
}

.dropdown-item:active {
    background-color: var(--primary);
    color: #0b0f14;
}

.dropdown-item.disabled,
.dropdown-item:disabled {
    color: var(--muted);
}

.dropdown-divider {
    border-color: var(--border);
}

.dropdown-header {
    color: var(--muted);
}

/* Progress bar */
.progress {
    background-color: var(--surface-3);
    border-radius: .5rem;
}

.progress-bar {
    background-color: var(--primary);
    color: #0b0f14;
}


/* Bootstrap card sub-elements */
.card-header,
.card-footer {
    background-color: color-mix(in oklab, var(--surface-3) 70%, transparent);
    border-color: var(--border);
    color: var(--text);
}

.card-body {
    color: var(--text);
}


/* 8) SECTIONS / CARDS ----------------------------------------------------- */
.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: .9rem;
    padding: 1rem;
    box-shadow: var(--shadow);
}


/* 9) FORMS (Bootstrap controls) ------------------------------------------ */
.form-control,
.form-select,
.form-check-input,
input,
select,
textarea {
    background-color: var(--input-bg);
    color: var(--text);
    border-color: var(--input-border);
    border-radius: .65rem;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
    box-shadow: none;
}

    .form-control::placeholder,
    input::placeholder,
    textarea::placeholder {
        color: var(--input-placeholder);
        opacity: 1;
    }

    .form-control:disabled,
    .form-control[readonly],
    input:disabled,
    input[readonly],
    textarea:disabled,
    textarea[readonly],
    select:disabled {
        background-color: var(--surface-2);
        background-color: color-mix(in oklab, var(--input-bg) 88%, transparent);
        color: var(--muted);
        color: color-mix(in oklab, var(--muted) 70%, transparent);
        opacity: 1;
    }

    .form-control:focus,
    .form-select:focus,
    .form-check-input:focus,
    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 .2rem var(--focus-ring);
        color: var(--text);
        background-color: var(--input-bg);
        outline: none;
    }

.form-select {
    background-image: none;
    padding-right: 2.5rem;
}

.form-check-input {
    width: 1.05rem;
    height: 1.05rem;
    margin-top: .25rem;
    border-radius: .35rem;
}

    .form-check-input:checked {
        background-color: var(--primary-strong);
        border-color: var(--primary-strong);
    }

    .form-check-input:focus {
        box-shadow: 0 0 0 .2rem var(--focus-ring);
    }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--input-border);
    color: var(--muted);
}

.form-floating > .form-control,
.form-floating > .form-select {
    background-color: var(--input-bg);
    color: var(--text);
}

.form-floating > label {
    color: var(--muted);
    transition: color .2s ease, transform .2s ease;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select:focus ~ label,
.form-floating > .form-select:not([value=""]) ~ label {
    color: var(--text);
    color: color-mix(in oklab, var(--muted) 55%, var(--text));
}

.form-text {
    color: var(--muted) !important;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px var(--input-bg) inset;
    -webkit-text-fill-color: var(--text);
    transition: background-color 9999s ease-in-out 0s;
}

/* 10) MODALS ------------------------------------------------------------- */
.modal-content {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid color-mix(in oklab, var(--border) 82%, transparent);
    box-shadow: var(--shadow);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.modal-header,
.modal-footer {
    background: color-mix(in oklab, var(--surface-2) 94%, transparent);
    border-color: color-mix(in oklab, var(--border) 72%, transparent);
    color: var(--text);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.modal-title {
    color: var(--text);
}

.modal-body {
    color: var(--text);
}

.btn-close {
    opacity: .7;
    transition: opacity .2s ease, transform .2s ease;
}

.btn-close:hover,
.btn-close:focus {
    opacity: 1;
    transform: scale(1.05);
}

.btn-close:focus {
    box-shadow: 0 0 0 .25rem var(--focus-ring);
}

:root[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%);
}

:root[data-theme="dark"] .btn-close:hover,
:root[data-theme="dark"] .btn-close:focus {
    filter: invert(1) grayscale(100%);
}

/* Alerts & status messaging */
.alert {
    border-radius: 1rem;
    border: 1px solid var(--border);
    border: 1px solid color-mix(in oklab, var(--border) 85%, transparent);
    background-color: var(--surface-2);
    background-color: color-mix(in oklab, var(--surface) 92%, transparent);
    color: var(--text);
}

.alert-heading {
    color: var(--text);
}

.alert-warning {
    background-color: var(--alert-bg);
    border-color: var(--alert-border);
    color: var(--text);
}

.alert-success {
    background-color: var(--surface-2);
    background-color: color-mix(in oklab, var(--success) 18%, var(--surface));
    border-color: var(--success-strong);
    border-color: color-mix(in oklab, var(--success-strong) 42%, var(--border));
    color: var(--text);
}

.alert-danger {
    background-color: var(--surface-2);
    background-color: color-mix(in oklab, var(--danger) 18%, var(--surface));
    border-color: var(--danger-strong);
    border-color: color-mix(in oklab, var(--danger-strong) 40%, var(--border));
    color: var(--text);
}

.alert-info {
    background-color: var(--surface-2);
    background-color: color-mix(in oklab, var(--info) 18%, var(--surface));
    border-color: var(--info-strong);
    border-color: color-mix(in oklab, var(--info-strong) 40%, var(--border));
    color: var(--text);
}

code {
    background-color: var(--surface-2);
    border-radius: .4rem;
    padding: .15rem .45rem;
    color: var(--accent);
    font-weight: 600;
}

.recovery-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 6rem;
    margin: .15rem 0;
    letter-spacing: .1em;
}

.table {
    --bs-table-color: var(--text);
    --bs-table-bg: var(--surface);
    --bs-table-border-color: var(--border);
    --bs-table-border-color: color-mix(in oklab, var(--border) 80%, transparent);
    --bs-table-striped-bg: var(--surface-2);
    --bs-table-striped-bg: color-mix(in oklab, var(--surface-2) 92%, transparent);
    --bs-table-striped-color: var(--text);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-bg: color-mix(in oklab, var(--primary) 12%, var(--surface));
    --bs-table-hover-color: var(--text);
    color: var(--text);
    border-color: var(--border);
    border-color: color-mix(in oklab, var(--border) 80%, transparent);
}

    .table thead th {
        background-color: var(--surface-2);
        color: var(--text);
    }

    .table thead.table-light th {
        background-color: var(--surface-2);
        color: var(--text);
    }

    .table th, .table td {
        padding: 10px 20px 10px 20px;
    }

.table > :not(caption) > * > * {
    background-color: var(--bs-table-bg);
    color: var(--bs-table-color);
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
}

.action-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

    .action-overlay[aria-hidden="false"] {
        opacity: 1;
        pointer-events: all;
    }

    .action-overlay-card {
        display: flex;
        align-items: center;
        gap: 1rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 1rem;
        padding: 1.25rem 1.5rem;
        box-shadow: var(--shadow);
        color: var(--text);
    }


/* 10) HERO & FEATURE GRID (Index) ---------------------------------------- */
.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: var(--shadow);
}

    .hero .eyebrow {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        padding: .25rem .7rem;
        border-radius: 999px;
        background: rgba(255, 138, 0, 0.20); /* fallback */
        background: color-mix(in oklab, var(--primary) 20%, transparent);
        color: var(--text);
        border: 1px solid rgba(255, 138, 0, 0.45); /* fallback */
        border: 1px solid color-mix(in oklab, var(--primary) 45%, var(--border));
        font-size: .85rem;
        letter-spacing: .12em;
        text-transform: uppercase;
        margin-bottom: 1rem;
    }

.feature-grid {
    display: grid;
    gap: 1rem;
    margin: 1.25rem 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: .9rem;
    padding: 1rem;
}

.manage-account {
    display: flex;
    flex-direction: column;
}

.manage-account__header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
}

.manage-account__nav,
.manage-account__content {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
    border-radius: 1rem;
    padding: 1.5rem;
    height: 100%;
}

.manage-account__content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}


/* 11) AUTH MODULE --------------------------------------------------------- */
/* Page container */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

/* Card */
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem 2rem;
    border-radius: 1.25rem;
    background: var(--surface);
    background: linear-gradient(160deg, color-mix(in oklab, var(--surface) 94%, transparent), color-mix(in oklab, var(--surface-3) 88%, transparent));
    border: 1px solid color-mix(in oklab, var(--primary) 22%, var(--border));
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.auth-helper {
    padding-top: 40px;
}

.auth-header {
    margin-bottom: 1.5rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: .35rem;
}

.auth-subtitle {
    color: var(--muted);
    margin: 0;
}

/* Inputs inside auth form */
.auth-form .form-control {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text);
}

    .auth-form .form-control:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 0.15rem var(--focus-ring);
    }

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: .9rem;
}

    .auth-options a {
        color: var(--accent);
    }

.auth-submit {
    padding: .75rem;
    font-weight: 600;
    border-radius: .75rem;
    box-shadow: 0 14px 30px color-mix(in oklab, var(--primary) 22%, transparent);
}

.auth-divider {
    position: relative;
    text-align: center;
    margin: 2rem 0 1.25rem;
    color: var(--muted);
    font-size: .85rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

    .auth-divider::before,
    .auth-divider::after {
        content: "";
        position: absolute;
        top: 50%;
        width: 30%;
        height: 1px;
        background: var(--border);
        background: color-mix(in oklab, var(--border) 75%, transparent);
    }

    .auth-divider::before {
        left: 0;
    }

    .auth-divider::after {
        right: 0;
    }

.auth-providers {
    display: grid;
    gap: .75rem;
}

.auth-footer {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1.75rem;
    font-size: .9rem;
}

    .auth-footer a {
        color: var(--accent);
    }


/* 12) UTILITIES ----------------------------------------------------------- */
hr {
    border-color: var(--border);
}


/* Hamburger menu button */
.nav-hamburger {
    display: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    align-items: center;
    justify-content: center;
    border-radius: .5rem;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease;
}

.nav-hamburger:hover,
.nav-hamburger:focus {
    background: color-mix(in oklab, var(--primary) 18%, var(--surface));
    border-color: var(--primary);
}

.nav-hamburger-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.nav-hamburger-icon span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}

.nav-hamburger.active .nav-hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-hamburger.active .nav-hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.nav-hamburger.active .nav-hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Side nav mobile toggle */
.side-nav-toggle {
    display: none;
    flex-direction: row;
    width: 100%;
    margin-bottom: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .75rem 1rem;
    border-radius: .75rem;
    cursor: pointer;
    font-weight: 600;
    text-align: left;
    align-items: center;
    justify-content: space-between;
    transition: background-color .2s ease, border-color .2s ease;
}

.side-nav-toggle:hover,
.side-nav-toggle:focus {
    background: color-mix(in oklab, var(--primary) 18%, var(--surface));
    border-color: var(--primary);
}

.side-nav-toggle-icon {
    transition: transform .2s ease;
}

.side-nav-toggle.active .side-nav-toggle-icon {
    transform: rotate(180deg);
}

/* Mobile collapsible side nav */
.side-nav-collapse {
    display: block;
}

/* Hide side nav close button on desktop */
.side-nav-close {
    display: none;
}

/* 13) MEDIA QUERIES ------------------------------------------------------- */
@media (max-width: 992px) {
    .feature-grid {
        grid-template-columns: 1fr 1fr;
    }

    .manage-account__nav,
    .manage-account__content {
        padding: 1.25rem;
    }

    /* Show hamburger menu on mobile */
    .nav-hamburger {
        display: inline-flex;
    }

    /* Hide desktop nav on mobile */
    .nav-main--desktop {
        display: none !important;
    }

    /* Footer responsive */
    .app-footer .container {
        flex-direction: column;
        gap: .5rem;
        text-align: center;
        font-size: .85rem;
    }

    /* Mobile menu - full overlay from right */
    .nav-main--mobile {
        display: none;
        position: fixed;
        top: 0;
        left: auto;
        right: 0;
        bottom: 0;
        width: min(320px, 85vw);
        background: var(--surface);
        z-index: 9999;
        flex-direction: column;
        padding: 1.5rem;
        overflow-y: auto;
        gap: 1rem;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
        animation: slideInFromRight .3s ease;
    }

    @keyframes slideInFromRight {
        from {
            transform: translateX(100%);
        }
        to {
            transform: translateX(0);
        }
    }

    .nav-main--mobile.active {
        display: flex;
    }

    /* Mobile menu backdrop */
    .nav-main--mobile.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        animation: fadeIn .3s ease;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    .nav-main--mobile .nav-link {
        width: 100%;
        text-align: left;
        padding: .75rem 1rem;
        border-radius: .75rem;
        font-size: 1.1rem;
    }

    /* Mobile close button for nav menu */
    .nav-main--mobile .nav-close {
        align-self: flex-end;
        background: var(--surface-2);
        border: 1px solid var(--border);
        color: var(--text);
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: .5rem;
        cursor: pointer;
        margin-bottom: .5rem;
    }

    /* Make side nav collapsible on mobile */
    .side-nav-toggle {
        display: flex;
    }

    .side-nav-collapse {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface);
        z-index: 9999;
        overflow-y: auto;
        padding: 1.5rem;
    }

    .side-nav-collapse.show {
        display: block;
        animation: slideInFromTop .3s ease;
    }

    @keyframes slideInFromTop {
        from {
            transform: translateY(-20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Backdrop for side nav dropdown */
    .side-nav-collapse.show::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Close button for side nav dropdown */
    .side-nav-close {
        display: flex;
        align-self: flex-end;
        background: var(--surface-2);
        border: 1px solid var(--border);
        color: var(--text);
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        align-items: center;
        justify-content: center;
        border-radius: .5rem;
        cursor: pointer;
        margin-bottom: 1rem;
        transition: background-color .2s ease, border-color .2s ease;
    }

    .side-nav-close:hover,
    .side-nav-close:focus {
        background: color-mix(in oklab, var(--primary) 18%, var(--surface));
        border-color: var(--primary);
    }

    .side-nav {
        position: static;
    }

    /* Auth controls on mobile */
    .auth-controls {
        flex-wrap: nowrap;
        font-size: .9rem;
    }

    .auth-greeting {
        font-size: .9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    /* Header adjustments for mobile */
    .app-header .container {
        padding-top: 0;
    }

    .brand-logo {
        height: 48px;
    }
}

@media (max-width: 600px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    /* Further reduce text on very small screens */
    .auth-greeting {
        max-width: 80px;
        font-size: .85rem;
    }

    /* Compact header on very small screens */
    .app-header .container {
        padding-inline: .75rem;
        gap: .5rem;
    }

    .brand-logo {
        height: 40px;
    }

    /* Stack header title and actions */
    .d-flex.align-items-center.justify-content-between.flex-wrap {
        gap: .75rem;
    }

    /* Make cards more compact */
    .section,
    .card {
        padding: 1rem;
    }

    /* Smaller buttons on very small screens */
    .btn {
        font-size: .85rem;
        padding: .5rem .75rem;
    }

    .btn-sm {
        padding: .3rem .5rem;
        font-size: .8rem;
    }

    /* Reduce heading sizes */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Table improvements for very small screens */
    .table {
        font-size: .8rem;
        min-width: 500px;
    }

    .table th,
    .table td {
        padding: 6px 8px;
    }

    /* Hide less important table columns on very small screens */
        .table th:nth-child(2),
        .table td:nth-child(2),
        .table th:nth-child(3),
        .table td:nth-child(3),
        .table th:nth-child(4),
        .table td:nth-child(4) {
            display: none;
        }

    /* Ensure first and last columns (name and actions) are always visible */
    .table th:first-child,
    .table td:first-child,
    .table th:last-child,
    .table td:last-child {
        display: table-cell;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .auth-options {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }

    .manage-account__nav,
    .manage-account__content {
        padding: 1rem;
    }

    .manage-account__header {
        margin-bottom: 1.25rem;
        padding-bottom: 1rem;
    }

    /* Alert messages more compact */
    .alert {
        padding: .75rem;
        font-size: .9rem;
    }

    /* Form improvements */
    .form-label {
        font-size: .9rem;
        margin-bottom: .375rem;
    }

    .form-control,
    .form-select {
        font-size: .9rem;
        padding: .5rem .75rem;
    }

    /* Responsive tables */
    .table-responsive {
        border: 1px solid var(--border);
        border-radius: .5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        margin-bottom: 0;
        font-size: .85rem;
        min-width: 600px; /* Ensure horizontal scroll for complex tables */
    }

    .table th,
    .table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    /* Allow wrapping for certain columns on mobile */
    .table td.text-muted.small {
        white-space: normal;
        min-width: 100px;
    }

    /* Make action buttons more compact on mobile */
    .table .btn-icon-sm {
        width: 2rem;
        height: 2rem;
        font-size: .875rem;
    }

    /* Smaller breadcrumb on mobile */
    .breadcrumb {
        font-size: .85rem;
        padding: .5rem 0;
    }

    .breadcrumb-item {
        padding: 0 .25rem;
    }

    /* Improve spacing for header action buttons on mobile */
    .d-flex.gap-2 {
        gap: .5rem !important;
    }

    .btn-sm {
        padding: .375rem .625rem;
        font-size: .85rem;
    }
}

/* ==========================================================================
   COLLAPSIBLE RIGHT SIDEBAR
   ========================================================================== */

/* Sidebar toggle button - positioned in page header */
[data-sidebar-toggle] {
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Collapsible sidebar container */
[data-collapsible-sidebar] {
    position: relative;
    transition: all 0.3s ease;
}

/* Collapsible sidebar */
[data-collapsible-sidebar] {
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Icon navigation - hidden when expanded */
.sidebar-icons {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.sidebar-icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    cursor: pointer;
    margin: 0 auto;
}

.sidebar-icon-btn:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    color: var(--primary);
}

/* Collapsed sidebar - narrow icon bar */
[data-collapsible-sidebar].sidebar-collapsed {
    flex: 0 0 60px !important;
    max-width: 60px !important;
    min-width: 60px;
}

[data-collapsible-sidebar].sidebar-collapsed .sidebar-icons {
    display: flex;
}

[data-collapsible-sidebar].sidebar-collapsed .sidebar-content {
    display: none;
}

/* Expanded sidebar - hide icons, show content */
[data-collapsible-sidebar]:not(.sidebar-collapsed) .sidebar-icons {
    display: none;
}

[data-collapsible-sidebar]:not(.sidebar-collapsed) .sidebar-content {
    display: block;
}

/* Main content expansion when sidebar is collapsed */
[data-sidebar-main] {
    transition: all 0.3s ease;
}

[data-sidebar-main].sidebar-main-expanded {
    /* When sidebar is collapsed, main content takes more width */
    flex: 0 0 calc(100% - 60px);
    max-width: calc(100% - 60px);
}

/* Responsive: Auto-show sidebar on smaller screens */
@media (max-width: 991.98px) {
    [data-collapsible-sidebar] {
        display: block !important;
    }

    [data-sidebar-main] {
        flex: auto;
        max-width: 100%;
    }
}
