/* Self-hosted web font (SIL OFL — redistribution permitted).
   Inter = primary sans-serif, used for both body and headings.
   6 discrete weights × 7 unicode subsets = 42 @font-face declarations.
   Subsets: cyrillic-ext, cyrillic, greek-ext, greek, vietnamese,
   latin-ext, latin. The browser fetches ONLY the subsets whose code
   points appear on the page (unicode-range mechanic), so the on-disk
   footprint (~1.2MB) does not translate to per-request bandwidth —
   English/Malay traffic only pulls the latin subset (~24KB per
   weight). Inter does NOT ship CJK / Arabic / Hebrew / Thai /
   Devanagari glyphs — those code points fall through the font stack
   to Noto / system fonts. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('/static/vendor/inter/inter-300.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/static/vendor/inter/inter-400.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/vendor/inter/inter-500.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/vendor/inter/inter-600.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/vendor/inter/inter-700.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-cyr-ext.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-cyr.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-gre-ext.woff2') format('woff2');
    unicode-range: U+1F00-1FFF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-gre.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-viet.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/vendor/inter/inter-800.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Font stacks are scripts-aware: Latin glyphs render via Inter;
       non-Latin code points fall through to system-ui (OS defaults
       with CJK/Arabic/Thai/Hebrew via font-linking on macOS/Windows/
       Android) then to named Noto fonts for Linux hosts. */
    --font-family-base: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Noto Sans', 'Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR',
        'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans Thai', 'Noto Sans Devanagari',
        sans-serif;
    --font-family-heading: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        'Noto Sans', 'Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR',
        'Noto Sans Arabic', 'Noto Sans Hebrew', 'Noto Sans Thai', 'Noto Sans Devanagari',
        sans-serif;
    --font-family-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', 'Source Code Pro',
        'Noto Sans Mono', 'Noto Sans Mono CJK SC', 'Noto Sans Mono CJK JP',
        monospace;
    /* Body default weight — Regular (400). Bumped from 300 so paragraph text
       renders with more presence in both light and dark themes. Override
       where headings or emphasized runs need heavier weights. */
    --font-weight-body: 400;
}

/* Font Loading - Ensure icons are visible while fonts load */
.fa, .fas, .far, .fab, .fal, .fad {
    /* Prevent layout shift by reserving space for icons */
    min-width: 1em;
    min-height: 1em;
    display: inline-block;
}

/* When fonts are loaded, class is added by JS */
.fonts-loaded .fa,
.fonts-loaded .fas,
.fonts-loaded .far,
.fonts-loaded .fab {
    min-width: unset;
    min-height: unset;
}

/* Global Styles - Modern Color System */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #8b5cf6;
    --light-color: #f6f4f0;
    --dark-color: #2c2c2e;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
}

/* S3 Storage Indicator */
.s3-icon {
    color: #ff9900 !important; /* AWS orange color */
    font-size: 0.85em;
    margin-left: 4px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.s3-icon:hover {
    opacity: 1;
}

/* Make S3 icon in dashboard slightly smaller */
.document-icon .s3-icon {
    font-size: 0.7em;
    margin-left: 2px;
}

/* Theme Variables - Warm Pastel (matching chat + admin palette) */
:root {
    /* Dark theme (default) - Soft Charcoal */
    --bg-primary: #15151b;
    --bg-secondary: #1c1c22;
    --bg-tertiary: #25252c;
    --text-primary: #e4e4e8;
    --text-secondary: #a8a8b0;
    --text-muted: #78787f;
    --text-dark: #e4e4e8;
    --border-color: rgba(200, 200, 210, 0.15);
    --card-bg: #1c1c22;
    --navbar-bg: #15151b;
    --accent-color: #a5b4fc;
}

[data-theme="light"] {
    /* Light theme - Warm Linen */
    --bg-primary: #ebe9e5;
    --bg-secondary: #e8e6e1;
    --bg-tertiary: #dfdcd7;
    --text-primary: #2c2c2e;
    --text-secondary: #6b6b70;
    --text-muted: #8a8a90;
    --text-dark: #2c2c2e;
    --border-color: rgba(140, 135, 128, 0.2);
    --card-bg: #ebe9e5;
    --navbar-bg: #ebe9e5;
    --accent-color: #6366f1;
}


/* Performance optimizations */
* {
    box-sizing: border-box;
}

/* Paper-grain texture applied to <html> (not body) so any page-level body
   shorthand rule can't clobber the background-image. Two variants: warm
   cream speckle on the dark theme, warm umber speckle on the light theme.
   Tile 240×240, stitched seamless, attachment fixed so the paper stays put
   while content scrolls (paper-under-page feel). */
html {
    background-color: var(--bg-primary);
    /* Paper grain — per-theme tuning.
       Dark (cream specks): baseFrequency 1.4 (fine grain) + alpha
       0.03. At higher alphas the cream blended into a uniform
       grey-white wash; 0.03 keeps individual specks faintly visible
       without averaging out the dark bg.
       Light (umber specks): baseFrequency 0.7 + alpha 0.05. Reduced
       from 0.20 to match dark's perceived strength — umber on light
       reads stronger per unit alpha than cream on dark, so 0.05
       (~1.7× dark) lands at similar visual weight rather than
       literal-alpha parity. */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.95 0 0 0 0 0.90 0 0 0 0 0.80 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-attachment: fixed;
}
[data-theme="light"] html,
html[data-theme="light"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.28 0 0 0 0 0.22 0 0 0 0 0.13 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body {
    /* Body text bumped +1.5px (was 14px default) for readability on Native
       chat. Header-surfaces that need a specific size override explicitly.
       font-size stays at body-level (0,0,1) so page templates with their
       own mobile --font-size override can still win. */
    font-size: 15.5px;
    /* Transparent so the <html> paper grain shows through. */
    background-color: transparent;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: color 0.3s;
}
/* html body (specificity 0,0,2) so page-level `body { ... }` rules in
   templates can't override font-weight or font-family. Font-size is kept
   out of this rule so mobile overrides in templates continue to win. */
html body {
    font-family: var(--font-family-base);
    font-weight: var(--font-weight-body);
}

/* Headings inherit Inter via --font-family-heading. */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-family-heading);
    font-weight: 500;
}

/* Promote inline bold contexts to Inter ExtraBold (800). 700 reads
   too close to 400 at body sizes; 800 gives clearer visual contrast
   for emphasis. */
b, strong, .fw-bold {
    font-weight: 800;
}

main {
    flex: 1;
}

/* Navigation - Flat Design */
.navbar {
    background-color: var(--navbar-bg) !important;
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--text-primary) !important;
}

.navbar-brand i {
    color: var(--accent-color);
}

.nav-link {
    color: var(--text-secondary) !important;
}

.nav-link:hover {
    color: var(--accent-color) !important;
}

.page-container .dropdown-menu {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

/* Cards - Flat Design */
.card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    box-shadow: none;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: var(--accent-color);
}

/* Processing Steps - Flat Design */
.processing-step {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.processing-step:last-child {
    border-bottom: none;
}

.processing-step .step-icon {
    width: 24px;
    text-align: center;
}

.processing-step .step-text {
    font-weight: 500;
    color: var(--text-primary);
}

.processing-step .step-details {
    margin-left: 26px;
}

.processing-step .step-details .progress {
    background-color: var(--bg-tertiary);
}

/* Buttons - Flat Design */
.btn {
    border-radius: 6px;
    padding: 8px 16px;
    font-weight: 500;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
    box-shadow: none;
}

.btn:hover {
    opacity: 0.9;
}

body.admin-native .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

body.admin-native .btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    box-shadow: none !important;
}

body.admin-native .btn:disabled,
body.admin-native .btn.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Forms - Flat Design */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Compact small buttons to avoid square/bloated look */
.btn-sm {
    padding: 4px 10px !important;
    border-radius: 6px !important;
    font-size: 0.875rem;
    line-height: 1.2;
}

/* Keep icon+label spacing tidy without changing chat or widget buttons. */
.btn i + span { margin-left: 0.4rem; }
body.admin-native .btn i + span { margin-left: 0; }

/* Shared compact action language used by AI-assisted admin fields. */
.ikb-action-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.ikb-ai-assist {
    /* Keep the foreground explicit: the previous accent-on-surface pairing
       became dark indigo on near-black in the admin dark theme.  Darken the
       configurable accent enough that white remains readable in both themes. */
    color: #fff;
    background: #4338ca;
    background: color-mix(in srgb, var(--c-primary, var(--accent-color)) 82%, #000);
    border: 1px solid var(--c-primary, var(--accent-color));
}

.ikb-ai-assist:hover,
.ikb-ai-assist:focus-visible {
    color: #fff;
    background: #4f46e5;
    background: color-mix(in srgb, var(--c-primary, var(--accent-color)) 90%, #000);
    border-color: var(--c-primary, var(--accent-color));
    opacity: 1;
}

.ikb-ai-assist:disabled,
.ikb-ai-assist.disabled {
    color: #fff;
}

.ikb-managed-prompt-panel,
.ikb-prompt-context-card {
    border: 1px solid var(--c-border, var(--border-color));
    border-radius: 8px;
    background: var(--c-section-tint, var(--bg-tertiary));
    color: var(--c-text-base, var(--text-primary));
    padding: 0.75rem 0.85rem;
}

.ikb-managed-prompt-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    color: var(--c-text-muted, var(--text-muted));
    font-size: 0.78rem;
}

.ikb-status-dot {
    width: 0.48rem;
    height: 0.48rem;
    border-radius: 50%;
    background: var(--c-text-muted, var(--text-muted));
    flex: 0 0 auto;
}

.ikb-managed-prompt-status[data-status="current"] .ikb-status-dot {
    background: var(--success-color, #16845b);
}

.ikb-managed-prompt-status[data-status="stale"] .ikb-status-dot,
.ikb-managed-prompt-status[data-status="generating"] .ikb-status-dot {
    background: var(--warning-color, #c47a13);
}

.ikb-managed-prompt-status[data-status="failed"] .ikb-status-dot,
.ikb-managed-prompt-status[data-status="manual_override"] .ikb-status-dot {
    background: var(--danger-color, #c94a4a);
}

.ikb-prompt-context-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.6rem;
    font-weight: 650;
}

.ikb-prompt-context-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.ikb-prompt-context-grid > span {
    display: flex;
    align-items: center;
    gap: 0.38rem;
    min-width: 0;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--c-border, var(--border-color));
    border-radius: 6px;
    background: var(--c-bkg, var(--card-bg));
    font-size: 0.76rem;
}

.ikb-prompt-context-card > small {
    color: var(--c-text-muted, var(--text-muted));
}

@media (max-width: 640px) {
    .ikb-action-group {
        width: 100%;
    }
    .ikb-action-group .btn {
        flex: 1 1 auto;
    }
    .ikb-prompt-context-grid {
        grid-template-columns: 1fr;
    }
}

/* Tighten spacing in small button groups */
.btn-group .btn-sm + .btn-sm { margin-left: 4px; }

.form-control:focus, .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: none;
    background-color: var(--bg-secondary);
}

/* Tables - Flat Design */
.table {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: visible; /* Allow dropdowns/tooltips to extend outside table */
    box-shadow: none;
    border: 1px solid var(--border-color);
}

.table thead th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.table thead th a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
}

.table thead th a:hover {
    color: var(--accent-color);
}

.table tbody td {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .table tbody tr:hover {
    background: var(--bg-tertiary) !important;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 10px;
    padding: 15px 20px;
}

/* Stats Cards - Flat Design */
.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    box-shadow: none;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
    min-height: 120px;
}

.stat-card:hover {
    border-color: var(--accent-color);
}

.stat-card .stat-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Admin Dashboard - Flat Design */
.dashboard-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 30px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-header h1 {
    margin: 0;
    font-weight: 600;
}

/* Topic Cards - Flat Design */
.topic-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: none;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.topic-card:hover {
    border-color: var(--accent-color);
}

.topic-card .topic-name {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.topic-card .topic-description {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.topic-card .topic-stats {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
}

.topic-card .topic-stats span {
    color: var(--text-secondary);
}

.topic-card .topic-stats strong {
    color: var(--text-primary);
}

/* Document List - Flat Design */
.document-item {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: none;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.document-item:hover {
    border-color: var(--accent-color);
}

.document-item .document-icon {
    font-size: 2rem;
    color: var(--accent-color);
    margin-right: 15px;
}

.document-item .document-info {
    flex: 1;
}

.document-item .document-name {
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.document-item .document-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.document-item .document-status {
    margin-left: 10px;
}

.document-item .badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Upload Zone - Flat Design */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background: var(--bg-secondary);
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent-color);
    background: var(--bg-tertiary);
}

.upload-zone.dragover {
    border-color: var(--success-color);
    background: var(--bg-tertiary);
}

.upload-zone .upload-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.upload-zone .upload-text {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Loading Spinner */
.spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Login Page - Flat Design */
.login-container {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: none;
    border: 1px solid var(--border-color);
}

.login-card .login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .login-header i {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.google-login-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    transition: border-color 0.2s, background-color 0.2s;
}

.google-login-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.google-login-btn img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 15px;
    }
    
    .dashboard-header {
        padding: 20px 0;
    }
    
    .topic-card .topic-stats {
        flex-direction: column;
        gap: 5px;
    }
    
    .document-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .document-item .document-status {
        margin-left: 0;
        margin-top: 10px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Footer */
.footer {
    background: var(--light-color);
    border-top: 1px solid rgba(222, 226, 230, 0.3); /* Much more subtle border */
    margin-top: auto;
}

/* Dark theme footer border */
[data-theme="dark"] .footer {
    border-top: 1px solid rgba(64, 64, 64, 0.3); /* Subtle dark theme border */
}

/* ============================
   DARK MODE - FLAT DESIGN
   ============================ */

/* Text color overrides */
[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-secondary {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-body {
    color: var(--text-primary) !important;
}

/* Main containers and backgrounds.
   NOTE: do NOT set `background` on body in any theme — body must stay
   transparent so the html paper-grain shows through. The `background:
   var(--bg-primary)` rule that lived here was the reason dark-mode
   chat rendered as flat dark with the grain hidden (the rule won by
   attribute-selector specificity and painted a solid bg layer over
   the html). Light theme worked only because no equivalent rule
   existed. body color is inherited from the base body{} block which
   reads var(--text-primary), already theme-scoped. */
[data-theme="dark"] .container,
[data-theme="dark"] .container-fluid {
    background-color: transparent;
}

/* Cards - Flat dark design */
[data-theme="dark"] .card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

[data-theme="dark"] .card-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .card-body {
    background: transparent;
    color: var(--text-secondary);
}

[data-theme="dark"] .card-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* Tables - Flat dark style */
[data-theme="dark"] .table {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Pricing totals row styling */
.table tfoot tr.table-total th {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
    font-weight: 600;
}

[data-theme="dark"] .table tfoot tr.table-total th {
    background: var(--bg-tertiary) !important;
    border-top: 2px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .table thead th {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    border-color: var(--border-color);
}

/* Forms - Flat dark inputs */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly] {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: none;
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-label {
    color: var(--text-secondary);
    font-weight: 500;
}

[data-theme="dark"] .form-text {
    color: var(--text-muted);
}

[data-theme="dark"] .input-group-text {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* Buttons - Flat dark mode */
[data-theme="dark"] .btn-primary {
    background: var(--c-primary, var(--primary-color));
    border: 1px solid var(--c-primary, var(--primary-color));
    box-shadow: none;
}

[data-theme="dark"] .btn-primary:hover {
    background: var(--c-primary-hover, var(--primary-hover));
    border-color: var(--c-primary-hover, var(--primary-hover));
    box-shadow: none !important;
}

[data-theme="dark"] .btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-success {
    background: var(--success-color);
    border: 1px solid var(--success-color);
}

[data-theme="dark"] .btn-danger {
    background: var(--danger-color);
    border: 1px solid var(--danger-color);
}

[data-theme="dark"] .btn-outline-primary {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

[data-theme="dark"] .btn-outline-primary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Alerts - Flat dark alerts */
[data-theme="dark"] .alert {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .alert-primary {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--accent-color);
}

[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #86efac;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

[data-theme="dark"] .alert-info {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
    color: #7dd3fc;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

/* Modals - Flat dark modals */
[data-theme="dark"] .modal {
    --bs-modal-color: var(--text-primary);
    --bs-modal-bg: var(--card-bg);
    --bs-modal-border-color: var(--border-color);
    --bs-modal-header-border-color: var(--border-color);
    --bs-modal-footer-border-color: var(--border-color);
}

[data-theme="dark"] .modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

[data-theme="dark"] .modal-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-body {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .modal-backdrop {
    background-color: #000;
    opacity: 0.7;
}

/* Dropdowns - Flat dark dropdowns */
[data-theme="dark"] .page-container .dropdown-menu {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-secondary);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-divider {
    border-color: var(--border-color);
}

/* Admin Spacing Improvements */
.container .card {
    margin-bottom: 24px;
}

.container .card-body {
    padding: 24px;
}

.container .card-header {
    padding: 16px 24px;
}

/* Form spacing */
.form-group,
.mb-3:has(.form-control),
.mb-3:has(.form-select) {
    margin-bottom: 20px;
}

.form-label {
    margin-bottom: 8px;
    font-weight: 500;
}

.form-text {
    margin-top: 8px;
}

.form-control,
.form-select {
    padding: 10px 14px;
}

textarea.form-control {
    min-height: 100px;
}

/* Row spacing in forms */
.row > [class*="col-"] {
    margin-bottom: 16px;
}

/* Table spacing */
.table th,
.table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.table-responsive {
    margin-bottom: 16px;
    overflow-x: auto; /* Horizontal scroll for wide tables */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Button group spacing */
.btn-group-sm > .btn {
    padding: 6px 12px;
}

/* Section headers */
h1, h2, h3, h4, h5 {
    margin-bottom: 16px;
}

.page-subtitle {
    margin-bottom: 24px;
}

/* Alert spacing */
.alert {
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* Nav tabs spacing */
.nav-tabs {
    margin-bottom: 24px;
}

.nav-tabs .nav-link {
    padding: 12px 20px;
}

/* Stat cards spacing */
.stat-card {
    padding: 20px;
}

/* Topic/document cards spacing */
.topic-card,
.document-item {
    padding: 16px;
    margin-bottom: 16px;
}

.topic-card:last-child,
.document-item:last-child {
    margin-bottom: 0;
}

/* ============================
   ADMIN UI POLISH - Full Redesign
   ============================ */

/* Theme-aware card headers - Replace bg-light */
.card-header.bg-light {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color);
}

.card-header.bg-light h5,
.card-header.bg-light .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="light"] .card-header.bg-light {
    background: #f6f4f0 !important;
}

/* Enhanced stat cards */
.stat-card {
    padding: 24px 20px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.9;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Compact stat cards for dashboard overview */
.stat-card-compact {
    padding: 16px;
    min-height: auto;
}

.stat-card-compact .stat-icon {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.stat-card-compact .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-card-compact .stat-label {
    font-size: 0.7rem;
}

/* Better card spacing */
.admin-card {
    margin-bottom: 28px;
}

.admin-card .card-body {
    padding: 28px;
}

.admin-card .card-header {
    padding: 18px 28px;
    font-weight: 600;
}

/* Section dividers */
.admin-section {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.admin-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.admin-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-section-title i {
    color: var(--accent-color);
    font-size: 1rem;
}

/* Compact table improvements */
.table-admin {
    font-size: 0.9rem;
}

.table-admin thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding: 12px 14px;
    white-space: nowrap;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.table-admin tbody td {
    padding: 14px;
    vertical-align: middle;
}

.table-admin .actions-cell {
    white-space: nowrap;
    text-align: right;
}

/* Action dropdown for tables */
.action-dropdown .dropdown-toggle {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.action-dropdown .dropdown-toggle::after {
    margin-left: 6px;
}

.action-dropdown .dropdown-menu {
    min-width: 160px;
    padding: 8px 0;
    font-size: 0.875rem;
}

.action-dropdown .dropdown-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-dropdown .dropdown-item i {
    width: 16px;
    text-align: center;
    opacity: 0.7;
}

.action-dropdown .dropdown-item:hover i {
    opacity: 1;
}

.action-dropdown .dropdown-divider {
    margin: 6px 0;
}

/* Quick action buttons (primary actions visible) */
.quick-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.quick-actions .btn {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* Better form sections */
.form-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.form-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.form-section-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-section-header i {
    color: var(--accent-color);
}

/* Collapsible sections */
.collapsible-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.collapsible-header {
    background: var(--bg-tertiary);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: var(--bg-secondary);
}

.collapsible-header h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.collapsible-header .collapse-icon {
    transition: transform 0.2s;
}

.collapsible-header[aria-expanded="true"] .collapse-icon {
    transform: rotate(180deg);
}

.collapsible-body {
    padding: 20px;
    background: var(--card-bg);
}

/* Two-column form layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-grid .form-group-full {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Danger zone styling */
.danger-zone {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 24px;
    margin-top: 32px;
}

[data-theme="dark"] .danger-zone {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
}

.danger-zone-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--danger-color);
}

.danger-zone-header i {
    font-size: 1.25rem;
}

.danger-zone-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--danger-color);
}

/* Action cards in danger zone */
.danger-action-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.danger-action-card .action-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    opacity: 0.8;
}

.danger-action-card h6 {
    font-weight: 600;
    margin-bottom: 8px;
}

.danger-action-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex-grow: 1;
}

.danger-action-card .btn {
    align-self: stretch;
}

/* Navigation improvements */
.navbar .dropdown-menu {
    padding: 12px 0;
    min-width: 240px;
}

.navbar .dropdown-header {
    padding: 8px 20px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.navbar .dropdown-item {
    padding: 10px 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar .dropdown-item i {
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

.navbar .dropdown-item:hover i {
    opacity: 1;
}

.navbar .dropdown-divider {
    margin: 8px 16px;
    border-color: var(--border-color);
}

/* Menu section labels */
.dropdown-section-label {
    padding: 12px 20px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Page header improvements */
.page-header-container {
    margin-bottom: 24px;
}

.page-header-container h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-header-container .page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Better topic cards */
.topic-card {
    padding: 20px;
    margin-bottom: 16px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.topic-card:hover {
    transform: translateY(-2px);
}

.topic-card .topic-name {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.topic-card .topic-description {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 12px;
}

.topic-card .topic-stats {
    font-size: 0.85rem;
    gap: 16px;
}

.topic-card .btn-group {
    margin-top: 12px;
}

/* Document items */
.document-item {
    padding: 16px 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.document-item:hover {
    transform: translateY(-1px);
}

.document-item .document-icon {
    font-size: 1.75rem;
    margin-right: 16px;
}

.document-item .document-name {
    font-size: 0.95rem;
}

.document-item .document-meta {
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Badge improvements */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge.bg-info {
    background: var(--info-color) !important;
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* Loading states */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 48px;
}

/* Responsive admin improvements */
@media (max-width: 992px) {
    .table-admin {
        font-size: 0.85rem;
    }

    .table-admin thead th {
        padding: 10px 12px;
    }

    .table-admin tbody td {
        padding: 12px;
    }

    .stat-card {
        padding: 20px 16px;
        min-height: 120px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .admin-card .card-body {
        padding: 20px;
    }

    .form-section {
        padding: 16px;
    }

    .quick-actions {
        flex-wrap: wrap;
    }
}

/* List groups - Flat dark style */
[data-theme="dark"] .list-group-item {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .list-group-item:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .list-group-item.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #1c1c22;
}

/* Badges - Flat visibility */
[data-theme="dark"] .badge {
    font-weight: 500;
}

[data-theme="dark"] .badge.bg-primary {
    background: var(--accent-color) !important;
    color: #1c1c22 !important;
}

[data-theme="dark"] .badge.bg-success {
    background: #10b981 !important;
    color: #1c1c22 !important;
}

[data-theme="dark"] .badge.bg-warning {
    background: #f59e0b !important;
    color: #1a1a1a !important;
}

[data-theme="dark"] .badge.bg-danger {
    background: #ef4444 !important;
}

/* Pagination - Flat dark pagination */
[data-theme="dark"] .page-link {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .page-link:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

[data-theme="dark"] .page-item.active .page-link {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #1c1c22;
}

/* Progress bars */
[data-theme="dark"] .progress {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Scrollbars - Flat dark scrollbars */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #3a3a44;
}

/* Close buttons */
[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Breadcrumbs */
[data-theme="dark"] .breadcrumb {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: #6b7280;
}

/* Nav tabs */
[data-theme="dark"] .nav-tabs {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .nav-tabs .nav-link {
    color: #a8b3c5;
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
    border-color: rgba(255, 255, 255, 0.1);
    color: #e4e6eb;
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--bg-primary);
    border-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.1) var(--bg-primary);
    color: #f0f2f5;
}

/* Code blocks */
[data-theme="dark"] pre,
[data-theme="dark"] code {
    background-color: #1c1c22;
    color: #e4e6eb;
}

/* HR elements */
[data-theme="dark"] hr {
    border-color: rgba(255, 255, 255, 0.08);
    opacity: 1;
}

/* Admin Dashboard Specific - Stat Cards */
[data-theme="dark"] .stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: none;
    transition: border-color 0.3s ease;
}

[data-theme="dark"] .stat-card:hover {
    border-color: var(--accent-color);
}

[data-theme="dark"] .stat-card .stat-icon {
    color: var(--accent-color);
}

[data-theme="dark"] .stat-card .stat-value {
    color: var(--text-primary);
    font-weight: 700;
}

[data-theme="dark"] .stat-card .stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Topic Cards */
[data-theme="dark"] .topic-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: none;
    transition: border-color 0.3s ease;
}

[data-theme="dark"] .topic-card:hover {
    border-color: var(--accent-color);
}

[data-theme="dark"] .topic-card .topic-name {
    color: var(--text-primary);
    font-weight: 600;
}

[data-theme="dark"] .topic-card .topic-description {
    color: var(--text-secondary);
}

/* Document Items */
[data-theme="dark"] .document-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.3s ease;
}

[data-theme="dark"] .document-item:hover {
    border-color: var(--accent-color);
}

[data-theme="dark"] .document-item .document-name {
    color: var(--text-primary);
    font-weight: 600;
}

[data-theme="dark"] .document-item .document-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Processing status indicators */
[data-theme="dark"] .processing-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-theme="dark"] .processing-status.status-complete {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .processing-status.status-processing {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .processing-status.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Empty states */
[data-theme="dark"] .empty-state {
    color: #6b7280;
    text-align: center;
    padding: 3rem 2rem;
}

[data-theme="dark"] .empty-state i {
    color: #4b5563;
    margin-bottom: 1rem;
}

[data-theme="dark"] .empty-state h6 {
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

[data-theme="dark"] .empty-state p {
    color: #6b7280;
    margin-bottom: 0;
}

/* Session detail specific */
[data-theme="dark"] .session-meta {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

[data-theme="dark"] .session-meta dt {
    color: #b8bdc6;
    font-weight: 600;
}

[data-theme="dark"] .session-meta dd {
    color: #d1d5db;
}

/* Message bubbles in session detail */
[data-theme="dark"] .message-bubble {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

[data-theme="dark"] .message-bubble.user {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .message-bubble.assistant {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* Timeline elements */
[data-theme="dark"] .timeline-item {
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    padding-left: 20px;
    margin-bottom: 24px;
    position: relative;
}

[data-theme="dark"] .timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 10px;
    height: 10px;
    background: #4a9eff;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

/* Loading animations */
[data-theme="dark"] .loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top: 3px solid #4a9eff;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fix remaining light inner blocks in dark mode */
[data-theme="dark"] .inner-content,
[data-theme="dark"] .content-block,
[data-theme="dark"] .info-block,
[data-theme="dark"] .stats-block,
[data-theme="dark"] .data-block {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Fix specific admin template elements */
[data-theme="dark"] .row .col-md-6 .card-body,
[data-theme="dark"] .row .col-md-4 .card-body,
[data-theme="dark"] .row .col-md-3 .card-body,
[data-theme="dark"] .session-details,
[data-theme="dark"] .topic-stats,
[data-theme="dark"] .user-info,
[data-theme="dark"] .group-info {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Fix any remaining white/light backgrounds */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100 {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Fix inner card components */
[data-theme="dark"] .card .card-body .card,
[data-theme="dark"] .card .card-body .alert,
[data-theme="dark"] .nested-card {
    background: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
}

/* Fix table inner cells */
[data-theme="dark"] .table tbody tr td,
[data-theme="dark"] .table tbody tr th {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}

/* Fix any remaining Bootstrap utility classes */
[data-theme="dark"] .bg-transparent {
    background-color: transparent !important;
}

[data-theme="dark"] .border-light {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .text-body,
[data-theme="dark"] .text-reset {
    color: var(--text-primary) !important;
}

/* Fix accordion and collapse components */
[data-theme="dark"] .accordion-item {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .accordion-header button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

[data-theme="dark"] .accordion-body {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Fix offcanvas components */
[data-theme="dark"] .offcanvas {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* Fix toast notifications */
[data-theme="dark"] .toast {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .toast-header {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

/* Fix card groups and decks */
[data-theme="dark"] .card-group .card,
[data-theme="dark"] .card-deck .card {
    background: var(--card-bg);
    border-color: var(--border-color);
}

/* Fix remaining utility backgrounds */
[data-theme="dark"] [class*="bg-gray"],
[data-theme="dark"] [class*="bg-slate"],
[data-theme="dark"] [class*="bg-zinc"],
[data-theme="dark"] [class*="bg-neutral"] {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}


/* Fix administrative action cards in settings */
[data-theme="dark"] .card.border-danger {
    background: var(--card-bg) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: var(--text-primary) !important;
}


[data-theme="dark"] .card.border-warning {
    border-color: rgba(245, 158, 11, 0.4) !important;
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .card.border-warning .card-header.bg-warning {
    background: rgba(245, 158, 11, 0.9) !important;
    border-bottom: 1px solid rgba(245, 158, 11, 0.3) !important;
    color: #000 !important;
}

[data-theme="dark"] .card.border-danger .card-body {
    background: transparent !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .card.border-danger .card-title {
    color: #f0f2f5 !important;
}

[data-theme="dark"] .card.border-danger .card-text {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .card.border-danger ul li {
    color: var(--text-secondary) !important;
}

/* Ensure buttons in danger cards are visible */
[data-theme="dark"] .card.border-danger .btn-danger {
    background: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
    color: white !important;
}

/* FINAL FIX - Comprehensive table hover for ALL tables in dark mode */
[data-theme="dark"] .table-hover > tbody > tr:hover,
[data-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-theme="dark"] .table-hover tbody tr:hover,
[data-theme="dark"] .table-hover tbody tr:hover > *,
[data-theme="dark"] .table tbody tr:hover,
[data-theme="dark"] .table tbody tr:hover > *,
[data-theme="dark"] table tbody tr:hover,
[data-theme="dark"] table tbody tr:hover > *,
[data-theme="dark"] .table-responsive table tbody tr:hover,
[data-theme="dark"] .table-responsive table tbody tr:hover > * {
    background-color: rgba(255, 255, 255, 0.06) !important;
    background: rgba(255, 255, 255, 0.06) !important;
    color: inherit !important;
}

/* Fix document chunks modal - dark mode chunk text display */
[data-theme="dark"] .chunk-text {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .chunk-item .card {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .chunk-item .card-header {
    background: var(--bg-tertiary) !important;
    border-bottom-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .chunk-item .card-body {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Fix chunk editor (textarea) */
[data-theme="dark"] .chunk-editor {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Worksheet Config Modal - Dark Mode */
[data-theme="dark"] .table-primary,
[data-theme="dark"] .table-primary > td,
[data-theme="dark"] .table-primary > th {
    background-color: rgba(99, 102, 241, 0.25) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .table-secondary,
[data-theme="dark"] .table-secondary > td,
[data-theme="dark"] .table-secondary > th {
    background-color: rgba(100, 116, 139, 0.2) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] #worksheetConfigModal .border {
    border-color: var(--border-color) !important;
    background: var(--bg-secondary);
}

[data-theme="dark"] #worksheetConfigModal h6 {
    color: var(--text-primary);
    border-color: var(--border-color) !important;
}

[data-theme="dark"] #worksheetConfigModal .form-check-label {
    color: var(--text-secondary);
}

[data-theme="dark"] #worksheetConfigModal .text-muted {
    color: var(--text-muted) !important;
}
