/*
 * PTC PaySync design tokens.
 *
 * Every colour used by portal.css and schedule.css is defined here once.
 * The active theme is chosen on the server and written to
 * <html data-theme="eco|pearl|dark">, so the correct palette is applied before
 * the first paint (no flash of the wrong theme). All three themes share the
 * same components and layout; only these values differ.
 *
 * Brand palette (approved): #099226 primary, #0EAB2F secondary/active,
 * #FFFFFF, #000000, #1E1E1E, #E5E7EB, #C1C1C1, #D9D9D9, #8F8F8F.
 *
 * Accessibility notes (WCAG 2.2 contrast ratios):
 *   white on #099226 ............ 4.08:1  (sidebar labels; AA for large text and UI parts)
 *   white on #087F21 ............ 5.16:1  (buttons — supporting shade of the brand)
 *   #06701C on white / #E7F6EA .. 6.28:1 / 5.62:1  (links, success text)
 *   #0B1F10 on #0EAB2F .......... 5.65:1  (Eco active navigation item)
 *   #5F6368 on white ............ 6.05:1  (secondary text)
 *
 * Dark Mode (WCAG 2.2, measured): body text 14.62:1 on surfaces, secondary
 * text 7.92:1, links 9.16:1, status texts 7.41-8.84:1, input borders 3.78:1
 * (UI minimum 3:1), white on buttons 5.16:1 (the Eco button shade).
 */

:root {
    /* Brand */
    --brand: #099226;
    --brand-active: #0eab2f;
    --brand-strong: #087f21;
    --brand-strong-hover: #06701c;
    --brand-ink: #06701c;
    --brand-soft: #e7f6ea;
    --brand-soft-border: #c9e8d0;

    /* Neutrals */
    --white: #ffffff;
    --black: #000000;
    --neutral-900: #1e1e1e;
    --neutral-700: #3c4043;
    --neutral-600: #5f6368;
    --neutral-500: #8f8f8f;
    --neutral-400: #c1c1c1;
    --neutral-300: #d9d9d9;
    --neutral-200: #e5e7eb;
    --neutral-100: #f1f2f4;

    /* Workspace surfaces */
    --page-bg: #f4f6f4;
    --surface: #ffffff;
    --surface-muted: #f7f9f7;
    --surface-hover: #f3f8f4;
    --border: #e5e7eb;
    --border-strong: #d9d9d9;
    --text: #1e1e1e;
    --text-muted: #5f6368;
    --focus-ring: #0eab2f;
    --link: var(--brand-ink);

    /* Status colours (always paired with a text label, never colour alone) */
    --success-bg: #e7f6ea;
    --success-text: #06701c;
    --success-border: #c9e8d0;
    --warning-bg: #fef3e2;
    --warning-text: #8a5300;
    --warning-border: #f4dcb4;
    --danger-bg: #fdecea;
    --danger-text: #b42318;
    --danger-border: #f5c6c0;
    --danger-hover-bg: #fbdcd8;
    --info-bg: #e8f1fd;
    --info-text: #1d4ed8;
    --neutral-bg: #f1f2f4;
    --neutral-text: #4b5563;
    --attention: #f97316;
    --preference-bg: #e3e6e4;
    --preference-text: #2f3b33;
    --preference-border: #a9b3ad;

    /* Department identification (badges also carry the department code) */
    --dept-iict-bg: #e8f1fd;
    --dept-iict-text: #1d4ed8;
    --dept-iboa-bg: #fdf0e6;
    --dept-iboa-text: #9a3412;
    --dept-executive-bg: #f3e8fd;
    --dept-executive-text: #6b21a8;

    /* Buttons */
    --button-bg: var(--brand-strong);
    --button-bg-hover: var(--brand-strong-hover);
    --button-text: #ffffff;

    /* Shape and depth */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 2px rgb(16 24 16 / 5%);
    --shadow-raised: 0 12px 32px rgb(16 40 20 / 10%);
    --overlay: rgb(15 30 18 / 45%);
    --overlay-nav: rgb(15 30 18 / 40%);
    --sidebar-width: 256px;
    --topbar-height: 68px;

    /* Typography: local system fonts only (no web-font requests) */
    --font-sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-numeric: var(--font-sans);
}

/* Eco Mode (default): the green sidebar is the brand expression. */
:root,
:root[data-theme="eco"] {
    color-scheme: light;
    --sidebar-bg: var(--brand);
    --sidebar-border: transparent;
    --sidebar-text: #ffffff;
    --sidebar-muted: #ffffff;
    --sidebar-label: #ffffff;
    --sidebar-hover-bg: rgb(255 255 255 / 14%);
    --sidebar-active-bg: var(--brand-active);
    --sidebar-active-text: #0b1f10;
    --sidebar-active-indicator: #ffffff;
    --sidebar-divider: rgb(255 255 255 / 28%);
    --sidebar-avatar-bg: #ffffff;
    --sidebar-avatar-text: var(--brand-ink);
    --sidebar-button-bg: rgb(255 255 255 / 14%);
    --sidebar-button-border: rgb(255 255 255 / 45%);
    --sidebar-button-text: #ffffff;
    --brand-mark-bg: #ffffff;
    --brand-mark-text: var(--brand);
    --topbar-bg: #ffffff;
    --topbar-accent: transparent;
    --card-accent: transparent;
    --auth-panel-bg: var(--brand);
    --auth-panel-text: #ffffff;
    --auth-panel-muted: #ffffff;
    --auth-panel-decoration: rgb(255 255 255 / 12%);
}

/* Pearl Mode: light neutral sidebar with subtle green indicators. */
:root[data-theme="pearl"] {
    color-scheme: light;
    --page-bg: #f6f7f6;
    --sidebar-bg: #ffffff;
    --sidebar-border: var(--neutral-200);
    --sidebar-text: var(--neutral-900);
    --sidebar-muted: var(--neutral-600);
    --sidebar-label: #5f6368;
    --sidebar-hover-bg: var(--surface-hover);
    --sidebar-active-bg: var(--brand-soft);
    --sidebar-active-text: var(--brand-ink);
    --sidebar-active-indicator: var(--brand-active);
    --sidebar-divider: var(--neutral-200);
    --sidebar-avatar-bg: var(--brand-soft);
    --sidebar-avatar-text: var(--brand-ink);
    --sidebar-button-bg: var(--surface);
    --sidebar-button-border: var(--neutral-200);
    --sidebar-button-text: var(--neutral-900);
    --brand-mark-bg: var(--brand);
    --brand-mark-text: #ffffff;
    --topbar-bg: #ffffff;
    --topbar-accent: var(--brand);
    --card-accent: var(--brand-active);
    --auth-panel-bg: #ffffff;
    --auth-panel-text: var(--neutral-900);
    --auth-panel-muted: var(--neutral-600);
    --auth-panel-decoration: var(--brand-soft);
}

/*
 * Dark Mode: a separate palette, not an inversion. It redefines every
 * semantic token the components read. It applies to screens only, so printed
 * payslips and records keep the light default palette.
 */
@media screen {
    :root[data-theme="dark"] {
        color-scheme: dark;

        /* Brand accents for a dark background. The soft border is the green
           outline of brand-tinted panels, hovered cards and focused inputs. */
        --brand-ink: #5ad374;
        --brand-soft: #14301c;
        --brand-soft-border: #2b6038;

        /* Neutrals used directly by a few rules (form labels, status dots, dashed borders) */
        --neutral-700: #c9d1cb;
        --neutral-500: #8c978f;
        --neutral-400: #5c6862;
        --neutral-200: #34483a;

        /* Workspace surfaces */
        --page-bg: #0e1310;
        --surface: #151b17;
        --surface-muted: #1a211c;
        --surface-hover: #1f2822;
        /* Ordinary structural lines: a quiet green-grey, not a brand colour. */
        --border: #34483a;
        --border-strong: #6b786f;
        --text: #e7ece8;
        --text-muted: #a7b1aa;
        --focus-ring: #3ddc63;

        /* Status colours (still paired with text labels) */
        --success-bg: #12301b;
        --success-text: #6fdc8a;
        --success-border: #1f4a2a;
        --warning-bg: #33270f;
        --warning-text: #f2c26b;
        --warning-border: #5a4419;
        --danger-bg: #3a1714;
        --danger-text: #ff9a8f;
        --danger-border: #6b2a24;
        --danger-hover-bg: #4a1d19;
        --info-bg: #142540;
        --info-text: #8fb4ff;
        --neutral-bg: #1f2622;
        --neutral-text: #c3cbc5;
        --attention: #fb923c;
        --preference-bg: #262d29;
        --preference-text: #c9d1cb;
        --preference-border: #4b5650;

        /* Department identification */
        --dept-iict-bg: #142540;
        --dept-iict-text: #8fb4ff;
        --dept-iboa-bg: #3a2414;
        --dept-iboa-text: #fdba8c;
        --dept-executive-bg: #2c1a3d;
        --dept-executive-text: #d8b4fe;

        /* Buttons keep the Eco shades: white on #087f21 is 5.16:1, on #06701c 6.28:1 */
        --button-bg: #087f21;
        --button-bg-hover: #06701c;
        --button-text: #ffffff;

        /* Depth and overlays */
        --shadow-card: 0 1px 2px rgb(0 0 0 / 40%);
        --shadow-raised: 0 12px 32px rgb(0 0 0 / 55%);
        --overlay: rgb(0 0 0 / 60%);
        --overlay-nav: rgb(0 0 0 / 55%);

        /* Shell */
        --sidebar-bg: #111713;
        --sidebar-border: #222b25;
        --sidebar-text: #e7ece8;
        --sidebar-muted: #a7b1aa;
        --sidebar-label: #8c978f;
        --sidebar-hover-bg: rgb(90 211 116 / 9%);
        --sidebar-active-bg: #173a22;
        --sidebar-active-text: #8ff0a6;
        --sidebar-active-indicator: #3ddc63;
        --sidebar-divider: #222b25;
        --sidebar-avatar-bg: #173a22;
        --sidebar-avatar-text: #8ff0a6;
        --sidebar-button-bg: #1a211c;
        --sidebar-button-border: #2a342d;
        --sidebar-button-text: #e7ece8;
        --brand-mark-bg: var(--brand);
        --brand-mark-text: #ffffff;
        --topbar-bg: #121814;
        --topbar-accent: #0eab2f;
        /* Same green top edge on cards as Pearl (it was transparent here). */
        --card-accent: var(--brand-active);
        --auth-panel-bg: #0f2416;
        --auth-panel-text: #e7ece8;
        --auth-panel-muted: #a7b1aa;
        --auth-panel-decoration: rgb(14 171 47 / 14%);
    }
}
