/* tokens.css — THE ONLY file allowed to hold colour/size literals (Theme.md §2–4, §7).
 * Light default on :root · dark on [data-theme="dark"] · OS-follow on [data-theme="auto"].
 * Components consume var(--…) exclusively. */

:root {
  /* Brand (identical in both themes — Theme §2.1) */
  --primary: #3157d5;
  --primary-hover: #2848b8;
  --primary-active: #1f3a97;
  --primary-soft: rgba(49, 87, 213, .10);
  --brand-gradient: linear-gradient(135deg, #3157d5, #5b7ce8);
  /* Product-preview window chrome (macOS-style) — identical in both themes */
  --window-bg: #0f172a; --window-dot: #334155;
  --mac-red: #ef4444; --mac-amber: #f59e0b; --mac-green: #22c55e;

  /* Semantic — light (Theme §2.2) */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #e3e8f0;
  --border-strong: #cbd5e1;
  --text: #172033;
  --text-muted: #5b667e;
  --text-inverse: #ffffff;
  --sidebar-bg: #111827;
  --sidebar-text: #cbd5e1;
  --sidebar-active-bg: rgba(255, 255, 255, .08);
  --sidebar-active-text: #ffffff;

  --success: #16a34a;      --success-soft: rgba(22, 163, 74, .12);
  --danger: #dc2626;       --danger-soft: rgba(220, 38, 38, .12);
  --warning: #d97706;      --warning-soft: rgba(217, 119, 6, .14);
  --info: #2563eb;         --info-soft: rgba(37, 99, 235, .12);

  --focus-ring: #3157d5;
  --overlay: rgba(8, 12, 24, .5);
  --table-head-bg: var(--primary);
  --table-head-text: #ffffff;
  --chart-1: #3157d5;
  --chart-2: #16a34a;
  --chart-3: #d97706;
  --chart-4: #dc2626;

  /* Dashboard KPI fills — solid metric cards. Fixed (not theme-flipped) so
     white text keeps contrast in both light and dark themes. */
  --kpi-blue: #3157d5;
  --kpi-green: #16a34a;
  --kpi-amber: #d97706;
  --kpi-red: #dc2626;
  --kpi-teal: #0e7490;
  --kpi-violet: #7c3aed;

  /* Typography (Theme §3) — system stack, no CDN font (NFR1.4) */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px;
  --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh-tight: 1.25; --lh-normal: 1.5;

  /* Spacing (Theme §4) — 4px grid */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

  /* Radius — squarer (was 8 / 14; user feedback: "little more square") */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 6px 16px rgba(16, 24, 40, .08);
  --shadow-3: 0 16px 40px rgba(16, 24, 40, .14);

  /* Z-index (Theme §4) */
  --z-sticky: 10; --z-sidebar: 20; --z-topbar: 30; --z-dropdown: 40;
  --z-sidebar-mobile: 45; /* mobile drawer sits above the topbar (30), below modal (50) */
  --z-backdrop: 44;       /* dim layer behind the mobile drawer */
  --z-modal: 50; --z-toast: 60; --z-progress: 70;

  /* Motion (Theme §7) */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 250ms;

  /* Layout */
  --sidebar-w: 245px;
  --topbar-h: 56px;
  --content-max: 1400px;
}

/* Semantic — dark (Theme §2.3) */
[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #18233b;
  --border: #24304d;
  --border-strong: #33415e;
  --text: #e6ecf8;
  --text-muted: #93a1bd;
  --text-inverse: #0b1120;

  /* brand lifted for contrast on dark */
  --primary: #6d8dff;
  --primary-hover: #8aa4ff;
  --primary-active: #a5baff;
  --primary-soft: rgba(109, 141, 255, .16);
  --brand-gradient: linear-gradient(135deg, #3d5fd8, #6d8dff);

  --sidebar-bg: #0d1526;
  --sidebar-text: #93a1bd;

  --success: #4ade80;      --success-soft: rgba(74, 222, 128, .14);
  --danger: #f87171;       --danger-soft: rgba(248, 113, 113, .14);
  --warning: #fbbf24;      --warning-soft: rgba(251, 191, 36, .14);
  --info: #60a5fa;         --info-soft: rgba(96, 165, 250, .14);

  --focus-ring: #8aa4ff;
  --overlay: rgba(0, 0, 0, .6);
  --table-head-bg: var(--surface-2);
  --table-head-text: var(--text);

  --chart-1: #6d8dff;
  --chart-2: #4ade80;
  --chart-3: #fbbf24;
  --chart-4: #f87171;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 6px 16px rgba(0, 0, 0, .45);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, .55);
}

/* auto → follow OS (same block as dark; Theme §10) */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0b1120;
    --surface: #111a2e;
    --surface-2: #18233b;
    --border: #24304d;
    --border-strong: #33415e;
    --text: #e6ecf8;
    --text-muted: #93a1bd;
    --text-inverse: #0b1120;

    --primary: #6d8dff;
    --primary-hover: #8aa4ff;
    --primary-active: #a5baff;
    --primary-soft: rgba(109, 141, 255, .16);
    --brand-gradient: linear-gradient(135deg, #3d5fd8, #6d8dff);

    --sidebar-bg: #0d1526;
    --sidebar-text: #93a1bd;

    --success: #4ade80;      --success-soft: rgba(74, 222, 128, .14);
    --danger: #f87171;       --danger-soft: rgba(248, 113, 113, .14);
    --warning: #fbbf24;      --warning-soft: rgba(251, 191, 36, .14);
    --info: #60a5fa;         --info-soft: rgba(96, 165, 250, .14);

    --focus-ring: #8aa4ff;
    --overlay: rgba(0, 0, 0, .6);
    --table-head-bg: var(--surface-2);
    --table-head-text: var(--text);

    --chart-1: #6d8dff;
    --chart-2: #4ade80;
    --chart-3: #fbbf24;
    --chart-4: #f87171;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 6px 16px rgba(0, 0, 0, .45);
    --shadow-3: 0 16px 40px rgba(0, 0, 0, .55);
  }
}
