/* ============================================================
   GestAI Design Tokens
   Two layers: primitives (raw ramps) → semantic (what components use).
   Components must only consume semantic tokens, so the dark theme
   is a pure token swap via [data-theme="dark"].
   ============================================================ */

:root {
    /* ---------- Primitives: plum ---------- */
    --plum-50:  #f6f3fc;
    --plum-100: #ede8f9;
    --plum-200: #ddd2f3;
    --plum-300: #c3aee9;
    --plum-400: #a685dc;
    --plum-500: #8b5cf6;
    --plum-600: #7c3aed;
    --plum-700: #6d28d9;
    --plum-800: #5b21b6;
    --plum-900: #581c87;
    --plum-950: #371356;

    /* ---------- Primitives: ember (warm orange) ---------- */
    --ember-50:  #fff7ed;
    --ember-100: #ffedd5;
    --ember-200: #fed7aa;
    --ember-300: #fdba74;
    --ember-400: #fb923c;
    --ember-500: #f97316;
    --ember-600: #ea580c;
    --ember-700: #c2410c;

    /* ---------- Primitives: warm gray (stone) ---------- */
    --stone-50:  #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --stone-950: #0c0a09;

    /* ---------- Primitives: status ---------- */
    --green-100: #dcfce7;
    --green-300: #86efac;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    --amber-100: #fef3c7;
    --amber-300: #fcd34d;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;
    --red-100:   #fee2e2;
    --red-300:   #fca5a5;
    --red-500:   #ef4444;
    --red-600:   #dc2626;
    --red-700:   #b91c1c;
    --blue-100:  #dbeafe;
    --blue-300:  #93c5fd;
    --blue-500:  #3b82f6;
    --blue-600:  #2563eb;
    --blue-700:  #1d4ed8;

    /* ---------- Typography ---------- */
    --font-display: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
    --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --text-xs:   0.75rem;   /* 12 */
    --text-sm:   0.875rem;  /* 14 */
    --text-base: 1rem;      /* 16 */
    --text-lg:   1.125rem;  /* 18 */
    --text-xl:   1.375rem;  /* 22 */
    --text-2xl:  1.75rem;   /* 28 */
    --text-3xl:  2.25rem;   /* 36 */
    --text-4xl:  3rem;      /* 48 */
    --text-5xl:  4rem;      /* 64 */

    /* ---------- Shape ---------- */
    --radius-xs:   8px;
    --radius-sm:   10px;
    --radius-md:   14px;
    --radius-lg:   20px;
    --radius-xl:   28px;
    --radius-pill: 999px;

    /* ---------- Spacing ---------- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* ---------- Motion ---------- */
    --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
    --ease-swift:  cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast:  140ms;
    --dur-base:  220ms;
    --dur-slow:  360ms;
    --dur-lazy:  600ms;

    /* ---------- Z layers ---------- */
    --z-sticky: 50;
    --z-drawer: 100;
    --z-overlay: 900;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* ============================================================
   Semantic tokens — LIGHT (default)
   ============================================================ */
:root,
[data-theme="light"] {
    color-scheme: light;

    /* Surfaces */
    --surface:         #fdfbf7;   /* warm cream app background */
    --surface-raised:  #ffffff;   /* cards, sidebar */
    --surface-sunken:  #f6f2ea;   /* inset wells, table heads */
    --surface-overlay: #ffffff;   /* modals, dropdowns */
    --surface-veil:    rgba(28, 22, 18, 0.45);  /* modal backdrop */

    /* Ink */
    --ink:           var(--stone-800);
    --ink-secondary: var(--stone-600);
    --ink-muted:     var(--stone-500);
    --ink-faint:     var(--stone-400);
    --ink-inverse:   #fdfbf7;

    /* Brand */
    --brand:        var(--plum-700);
    --brand-strong: var(--plum-900);
    --brand-bright: var(--plum-600);
    --brand-soft:   #f3eefb;            /* warm-tinted plum wash */
    --brand-soft-2: #e9e1f7;
    --on-brand:     #ffffff;

    /* Accent */
    --accent:      var(--ember-600);
    --accent-soft: var(--ember-100);
    --on-accent:   #ffffff;

    /* Lines & focus */
    --border:        #eae5dc;
    --border-strong: #d9d2c7;
    --ring:          rgba(109, 40, 217, 0.35);
    --ring-offset:   var(--surface);

    /* Status */
    --positive:       var(--green-600);
    --positive-strong:var(--green-700);
    --positive-soft:  #e4f7e9;
    --caution:        var(--amber-600);
    --caution-strong: var(--amber-700);
    --caution-soft:   #fdf3d8;
    --danger:         var(--red-600);
    --danger-strong:  var(--red-700);
    --danger-soft:    #fde8e8;
    --info:           var(--blue-600);
    --info-strong:    var(--blue-700);
    --info-soft:      #e3edfd;

    /* Shadows (warm-tinted) */
    --shadow-xs: 0 1px 2px rgba(41, 30, 18, 0.05);
    --shadow-sm: 0 1px 3px rgba(41, 30, 18, 0.07), 0 1px 2px rgba(41, 30, 18, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(41, 30, 18, 0.1), 0 2px 6px -2px rgba(41, 30, 18, 0.05);
    --shadow-lg: 0 16px 40px -8px rgba(41, 30, 18, 0.16), 0 4px 12px -4px rgba(41, 30, 18, 0.06);
    --shadow-brand: 0 8px 24px -6px rgba(109, 40, 217, 0.35);
    --shadow-accent: 0 8px 24px -6px rgba(234, 88, 12, 0.35);

    /* Charts */
    --chart-grid: #efe9df;
    --chart-tick: var(--stone-500);
}

/* ============================================================
   Legacy variable aliases.
   Old templates and JS-generated inline styles reference the
   pre-redesign variable names. They map onto semantic tokens,
   so they follow the active theme automatically.
   ============================================================ */
:root {
    --primary: var(--brand);
    --primary-dark: var(--brand-strong);
    --primary-light: var(--plum-400);
    --primary-50: var(--brand-soft);
    --primary-100: var(--brand-soft-2);

    --gray-50: var(--surface-sunken);
    --gray-100: var(--surface-sunken);
    --gray-200: var(--border);
    --gray-300: var(--border-strong);
    --gray-400: var(--ink-faint);
    --gray-500: var(--ink-muted);
    --gray-600: var(--ink-secondary);
    --gray-700: var(--ink-secondary);
    --gray-800: var(--ink);
    --gray-900: var(--ink);

    --success: var(--positive);
    --success-light: var(--positive-soft);
    --warning: var(--caution);
    --warning-light: var(--caution-soft);
    --error: var(--danger);
    --error-light: var(--danger-soft);
    --info-light: var(--info-soft);

    --bg-body: var(--surface);
    --bg-card: var(--surface-raised);
    --bg-sidebar: var(--surface-raised);

    --text-primary: var(--ink);
    --text-secondary: var(--ink-secondary);
    --text-muted: var(--ink-muted);

    --border-color: var(--border);
    --border-radius: var(--radius-md);
    --border-radius-sm: var(--radius-sm);
    --border-radius-lg: var(--radius-lg);

    --transition-fast: var(--dur-fast) var(--ease-swift);
    --transition-base: var(--dur-base) var(--ease-swift);
    --transition-slow: var(--dur-slow) var(--ease-swift);

    --sidebar-width: 280px;
}

/* ============================================================
   Semantic tokens — DARK
   ============================================================ */
[data-theme="dark"] {
    color-scheme: dark;

    /* Surfaces — warm near-blacks, never pure black */
    --surface:         #151210;
    --surface-raised:  #201c19;
    --surface-sunken:  #0f0d0b;
    --surface-overlay: #272220;
    --surface-veil:    rgba(8, 6, 4, 0.6);

    /* Ink */
    --ink:           #f3efe8;
    --ink-secondary: #c9c2b8;
    --ink-muted:     #968e84;
    --ink-faint:     #6b645c;
    --ink-inverse:   var(--stone-900);

    /* Brand — lifted for dark-surface contrast */
    --brand:        var(--plum-400);
    --brand-strong: var(--plum-300);
    --brand-bright: var(--plum-500);
    --brand-soft:   rgba(166, 133, 220, 0.14);
    --brand-soft-2: rgba(166, 133, 220, 0.24);
    --on-brand:     #1a1028;

    /* Accent */
    --accent:      var(--ember-400);
    --accent-soft: rgba(251, 146, 60, 0.16);
    --on-accent:   #2b1304;

    /* Lines & focus */
    --border:        #322c27;
    --border-strong: #463f38;
    --ring:          rgba(166, 133, 220, 0.45);
    --ring-offset:   var(--surface);

    /* Status */
    --positive:       var(--green-500);
    --positive-strong:var(--green-300);
    --positive-soft:  rgba(34, 197, 94, 0.15);
    --caution:        var(--amber-500);
    --caution-strong: var(--amber-300);
    --caution-soft:   rgba(245, 158, 11, 0.15);
    --danger:         var(--red-500);
    --danger-strong:  var(--red-300);
    --danger-soft:    rgba(239, 68, 68, 0.16);
    --info:           var(--blue-500);
    --info-strong:    var(--blue-300);
    --info-soft:      rgba(59, 130, 246, 0.16);

    /* Shadows — deeper, tighter */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.65), 0 4px 12px -4px rgba(0, 0, 0, 0.45);
    --shadow-brand: 0 8px 24px -6px rgba(124, 58, 237, 0.45);
    --shadow-accent: 0 8px 24px -6px rgba(251, 146, 60, 0.35);

    /* Charts */
    --chart-grid: #2b2622;
    --chart-tick: #968e84;
}
