/* THE design-token source for the whole platform — one :root palette, no twin.
   base.html loads it as the FIRST stylesheet in <head> (before sips-components.css
   and tailwind.css, which both read these var(--*) values), and the standalone auth
   pages that do NOT extend base.html pull it in through registration/_auth_head.html.
   It used to be duplicated as a hand-written inline <style> in base.html: 102
   identical declarations in two places with nothing in CI diffing them. Do not
   reintroduce a second copy — edit the palette here and both tiers follow. */

/* =========================
   THEME TOKENS (dark/light)
   Stripe-inspired refinements
   ========================= */

/* DARK (par défaut) */
:root{
    /* Brand — Saudi green (#006C35, the flag's green) in BOTH themes since
       2026-11-06. The dark theme used to run on Tailwind's bluish emerald
       mint; it now runs on the same hue as the light theme, lifted just enough
       to pass on the ink surfaces:
         500 #3DB372  bright text / figures   (8.2:1 on --bg-1)
         600 #22A35F  icons, links, chart accent, badge text (5.6:1 on --bg-1)
         700 #006C35  fills — white text on it reads 6.2:1
         800 #005128  pressed / hover fills */
    --brand-500: #3DB372;
    --brand-600: #22A35F;
    --brand-700: #006C35;
    --brand-800: #005128;
    --brand-soft: rgba(0,108,53,0.22);

    /* Brand RGB triplets for Tailwind opacity — the same Saudi ramp, so every
       emerald-* utility follows: 500/600 carry white text at >= 4.5:1,
       300/400 are the text tints on dark. */
    --brand-50-rgb:  232 245 238;
    --brand-100-rgb: 205 235 217;
    --brand-200-rgb: 159 216 184;
    --brand-300-rgb: 108 196 148;
    --brand-400-rgb: 61 179 114;
    --brand-500-rgb: 16 138 74;
    --brand-600-rgb: 0 108 53;
    --brand-700-rgb: 0 90 44;
    --brand-800-rgb: 0 71 34;
    --brand-900-rgb: 0 53 26;
    --brand-950-rgb: 0 34 17;

    /* Secondary (sky/blue) */
    --secondary-500: #0284c7;
    --secondary-light: #7dd3fc;
    --secondary-soft: rgba(2,132,199,0.12);

    /* Tertiary — a NEUTRAL slate, not a third hue. The old violet ramp made
       the chrome carry three accents (emerald, sky, violet); the names stay so
       nothing breaks, the values now read as a quiet grey-blue so a third
       chart series or a decorative ring never competes with the one accent. */
    --accent-300: #a3adbb;
    --accent-400: #8591a1;
    --accent-500: #6b7686;
    --accent-soft: rgba(133,145,161,0.14);

    /* Status */
    --success: #22A35F;
    --success-soft: rgba(34,163,95,0.16);
    --warning: #f59e0b;
    --warning-soft: rgba(245,158,11,0.15);
    --error: #f87171;
    --error-dark: #dc2626;
    --error-light: #fca5a5;
    --error-soft: rgba(220,38,38,0.15);

    /* Status badge text (CLR-04) — DARK: bright glass mints/amber/coral
       measure >=4.5:1 on their soft fills over the dark surface
       (ok 7.19:1, attn 6.32:1, danger 5.81:1, neutral 6.16:1). */
    --ui-badge-ok-text:     var(--brand-500);   /* #3DB372 */
    --ui-badge-attn-text:   var(--warning);     /* #f59e0b */
    --ui-badge-danger-text: var(--error);       /* #f87171 */

    /* === Type scale (CLR-04) — 4 sizes, formalized from existing values ===
       Meta 12px / Body 14px / Heading 16px / Display 28px. Two weights only:
       400 body, 600 emphasis (see .ui-meta for the muted-metadata role). */
    --text-meta:    0.75rem;   /* 12px — muted metadata (.ui-meta) */
    --text-body:    0.875rem;  /* 14px — body / labels */
    --text-heading: 1rem;      /* 16px — section headings */
    --text-display: 1.75rem;   /* 28px — page / display headings */

    /* Surfaces — ONE flat ink ramp tinted toward the logo's teal (design
       review 2026-11-06). Depth is a surface step plus a hairline, never a
       halo, a gradient or a blur: page < card < raised. */
    --surface: #10161c;        /* card */
    --surface-soft: #161d25;   /* raised: inputs, inner blocks, active rows */

    /* Text — three roles, nothing in between. */
    --text-main: rgba(255,255,255,0.92);
    --text-secondary: rgba(255,255,255,0.72);
    --text-muted: rgba(255,255,255,0.56);

    /* Borders — the text colour at 8 / 14 %. */
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);

    /* Shadow — neutral and small; dark surfaces lift by step, not by shadow. */
    --shadow: 0 1px 2px rgba(0,0,0,0.24);

    /* Radii — nested: inner = outer − padding, never under 4. */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    /* === Legacy / backward-compat aliases === */
    --bg-1: #0b0f14;
    --bg-2: #0b0f14;
    --bg-3: #0b0f14;

    --text: var(--text-main);
    --muted: var(--text-muted);

    --glass-bg: var(--surface);
    --glass-border: var(--border);
    --glass-shadow: var(--shadow);

    --soft-bg: var(--surface-soft);
    --soft-border: rgba(255,255,255,0.06);

    /* Hover is a hairline step, not a green liseré with a tinted shadow. */
    --hover-border: var(--border-strong);
    --hover-shadow: var(--shadow);

    /* The two radial halos base.html used to paint are gone in both themes. */
    --glow-1: transparent;
    --glow-2: transparent;

    /* Sidebar (DARK) — the deepest surface, opaque, no blur. */
    --sidebar-bg: #090d11;
    --sidebar-border: rgba(255,255,255,0.07);
    --sidebar-shadow: none;

    --sidebar-overlay: rgba(0,0,0,0.32);

    --nav-bg: transparent;
    --nav-border: transparent;
    --nav-hover-bg: rgba(255,255,255,0.05);
    --nav-hover-border: transparent;
    --nav-active-accent: var(--brand-600);

    /* Stripe-like inset divider */
    --divider: var(--border);
    --row-hover: rgba(255,255,255,0.04);

    /* Ground of the medication thumbnails (.med-thumb) */
    --med-tile: #161d25;
}

/* LIGHT (adouci le 2026-11-23 — le « full blanc » de 2026-09-14 éblouissait).
   Même logique que le sombre : page < carte < bloc, en aplats, sans dégradé ni
   halo. La page est un blanc cassé teinté vert saoudien (#f2f6f3), les cartes
   restent blanches et se détachent donc par palier, la sidebar est un cran plus
   verte (#e7f0ea). Filets et fonds doux portent la même teinte verte au lieu du
   gris neutre. Les accents restent en vert saoudien #006C35 (6.1:1 sur la page). */
html[data-theme="light"]{
    /* Fond : un seul aplat sur les trois paliers — le dégradé de base.html
       (linear-gradient bg-1 -> bg-2 -> bg-3) devient donc invisible, et les
       --glow-* passent à transparent pour neutraliser les deux radial-gradient.
       Garder base.html / errors/base_error.html (anti-flash) sur la même valeur. */
    --bg-1: #f2f6f3;
    --bg-2: #f2f6f3;
    --bg-3: #f2f6f3;

    /* Accent unique (vert saoudien). La rampe --brand-* est ramenée sur cette
       teinte en clair : tout ce qui lit var(--brand-500..800) — pastilles,
       flèches de tri, liens .rec-link, .ui-next-action, .seg-tab active, anneaux
       de focus — devient vert saoudien sans règle supplémentaire. Les triplets
       --brand-*-rgb (utilisés par Tailwind pour les opacités) ne changent PAS :
       ce sont deux canaux distincts, et les utilitaires emerald/N sont déjà
       remappés un par un dans sips-components.css.
       Contrastes : #006C35 6.6:1 sur blanc, #007A3B 5.5:1 sur blanc et 4.8:1
       sur la sidebar teintée — tous >= 4.5:1. */
    --brand-500: #007A3B;
    --brand-600: #006C35;
    --brand-700: #006C35;
    --brand-800: #005128;

    /* Sémantique : les teintes vives du mode sombre (--success #10B981 2.5:1,
       --error #f87171 3.0:1) ne passent pas sur blanc. On les assombrit ici, donc
       tout ce qui lit var(--success)/var(--error) — .ui-delta-*, le lien Logout de
       la sidebar, les points de statut — suit sans règle supplémentaire. */
    --success: #006C35;
    --success-soft: rgba(0,108,53,0.10);
    --warning: #b45309;
    --warning-soft: rgba(180,83,9,0.10);
    --error: #b91c1c;
    --error-light: #b91c1c;   /* #fca5a5 serait illisible sur blanc */
    --error-soft: rgba(185,28,28,0.09);
    --brand-soft: rgba(0,108,53,0.12);

    --text-main: #0b1220;
    --text-secondary: #3b4a5e;
    --text-muted: #46566b;   /* 7.4:1 sur blanc, 6.8:1 sur la page */
    --text: var(--text-main);
    --muted: var(--text-muted);

    --border: #d8e4dc;
    --border-strong: #bfd1c5;

    --glass-bg: #ffffff;
    --glass-border: #d8e4dc;
    --glass-shadow: 0 1px 2px rgba(11,18,32,0.04);

    --soft-bg: #e9f1ec;
    --soft-border: #d8e4dc;

    --hover-border: #bfd1c5;
    --hover-shadow: 0 1px 2px rgba(11,18,32,0.06), 0 2px 10px rgba(11,18,32,0.05);

    /* Halos neutralisés : le fond reste plat quelle que soit la page. */
    --glow-1: transparent;
    --glow-2: transparent;

    --shadow: 0 1px 2px rgba(11,18,32,0.04);

    --surface: #ffffff;
    --surface-soft: #e9f1ec;

    /* Status badge text (CLR-04) — LIGHT: the bright glass mints/amber/coral
       fail 4.5:1 on the near-white soft fills (ok 1.66:1, attn 1.91:1,
       danger 2.18:1), so remap to darker shades that pass
       (ok #006C35 6.9:1, attn #92400e 6.31:1, danger #991b1b 6.56:1;
       neutral --muted #46566b on --soft-bg = 6.7:1). */
    --ui-badge-ok-text:     #006C35;
    --ui-badge-attn-text:   #92400e;
    --ui-badge-danger-text: #991b1b;

    /* Sidebar (LIGHT) — le palier le plus vert, comme elle est le plus
       sombre en mode sombre ; aplat opaque, pas d'ombre portée. */
    --sidebar-bg: #e7f0ea;
    --sidebar-border: #d3e1d8;
    --sidebar-shadow: none;

    --sidebar-overlay: rgba(0,54,26,0.10);

    --nav-bg: transparent;
    --nav-border: transparent;
    --nav-hover-bg: rgba(0,108,53,0.08);
    --nav-hover-border: transparent;
    --nav-active-accent: #006C35;

    --divider: var(--border);
    --row-hover: rgba(0,108,53,0.045);

    --med-tile: #e9f1ec;
}
