/* ============================================
   Fennec360-v2 Design Tokens
   Single source of truth for all theme values.
   Light mode = default (:root)
   Dark mode  = [data-theme="dark"] override
   ============================================ */

/* ----------------------------------------
   1. COLOR SCALES (static — not mode-dependent)
   ---------------------------------------- */
:root {
  /* Primary scale (#1A3A6B base) */
  --primary-50:  #E8EDF5;
  --primary-100: #D1DBEB;
  --primary-200: #A3B7D7;
  --primary-300: #7593C3;
  --primary-400: #4A6FA8;
  --primary-500: #2A5189;
  --primary-600: #1A3A6B;
  --primary-700: #152F57;
  --primary-800: #102444;
  --primary-900: #0B1930;
  --primary-950: #060E1C;

  /* Accent scale (#D4A843 base) */
  --accent-50:  #FDF8EC;
  --accent-100: #FAF0D4;
  --accent-200: #F3DEAA;
  --accent-300: #ECCC7F;
  --accent-400: #E0BA5C;
  --accent-500: #D4A843;
  --accent-600: #B8902A;
  --accent-700: #957321;
  --accent-800: #725819;
  --accent-900: #4F3D12;
  --accent-950: #2C210A;

  /* Neutral scale (cool blue undertone) */
  --neutral-50:  #f5f6fa;
  --neutral-100: #ecedf3;
  --neutral-200: #d8dae5;
  --neutral-300: #b8bccf;
  --neutral-400: #9298b0;
  --neutral-500: #757b95;
  --neutral-600: #5e647c;
  --neutral-700: #4d5268;
  --neutral-800: #424659;
  --neutral-900: #3a3d4e;
  --neutral-950: #1a1c2e;

  /* Success scale (green) */
  --success-50:  #f0fdf4;
  --success-100: #dcfce7;
  --success-200: #bbf7d0;
  --success-300: #86efac;
  --success-400: #4ade80;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --success-700: #15803d;
  --success-800: #166534;
  --success-900: #14532d;
  --success-950: #052e16;

  /* Warning scale (amber) */
  --warning-50:  #fffbeb;
  --warning-100: #fef3c7;
  --warning-200: #fde68a;
  --warning-300: #fcd34d;
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --warning-800: #92400e;
  --warning-900: #78350f;
  --warning-950: #451a03;

  /* Info scale (sky blue) */
  --info-50:  #f0f9ff;
  --info-100: #e0f2fe;
  --info-200: #bae6fd;
  --info-300: #7dd3fc;
  --info-400: #38bdf8;
  --info-500: #0ea5e9;
  --info-600: #0284c7;
  --info-700: #0369a1;
  --info-800: #075985;
  --info-900: #0c4a6e;
  --info-950: #082f49;
}

/* ----------------------------------------
   2. SEMANTIC TOKENS — Light Mode (default)
   ---------------------------------------- */
:root {
  /* Surface colors */
  --surface-base:    #f5f6fa;
  --surface-raised:  #ffffff;
  --surface-card:    #ffffff;
  --surface-overlay: #ffffff;
  --surface-input:   #ffffff;
  --surface-subtle:  #f8f9fc;
  --surface-hover:   #ecedf3;
  --surface-active:  #e2e4ed;

  /* Border colors */
  --border-subtle:  #ecedf3;
  --border-default: #e2e4ed;
  --border-strong:  #c8cbda;
  --border-focus:   #272974;

  /* Text colors */
  --text-primary:    #1a1c2e;
  --text-secondary:  #5e647c;
  --text-tertiary:   #9298b0;
  --text-on-primary: #ffffff;
  --text-on-accent:  #ffffff;
  --text-link:       #272974;
  --text-link-hover: #1e2060;

  /* Semantic status colors (WCAG AA compliant - 4.5:1 contrast ratio on white) */
  --success:    #16a34a;
  --success-bg: #f0fdf4;
  --warning:    #92650f;  /* Changed from #ca8a04 for 4.5:1 contrast */
  --warning-bg: #fefce8;
  --danger:     #c81e1e;  /* Changed from #dc2626 for better contrast */
  --danger-bg:  #fef2f2;
  --info:       #0284c7;
  --info-bg:    #f0f9ff;

  /* Chart colors */
  --chart-1:      #272974;
  --chart-2:      #b30e15;
  --chart-3:      #16a34a;
  --chart-4:      #ca8a04;
  --chart-5:      #0284c7;
  --chart-6:      #8e24aa;
  --chart-1-bg:   rgba(39, 41, 116, 0.15);
  --chart-2-bg:   rgba(179, 14, 21, 0.15);
  --chart-grid:   rgba(0, 0, 0, 0.06);
  --chart-tick:   var(--text-secondary);
  --chart-border: var(--border-default);
}

/* ----------------------------------------
   3. SEMANTIC TOKENS — Dark Mode
   ---------------------------------------- */
[data-theme="dark"] {
  /* Surface colors — blue-tinted, deep */
  --surface-base:    #0a0b1a;
  --surface-raised:  #10122b;
  --surface-card:    #10122b;
  --surface-overlay: #161838;
  --surface-input:   #131530;
  --surface-subtle:  #0d0e22;
  --surface-hover:   #1b1e3e;
  --surface-active:  #212448;

  /* Border colors */
  --border-subtle:  #1a1d40;
  --border-default: #232650;
  --border-strong:  #2f325e;
  --border-focus:   #8e99e8;

  /* Text colors */
  --text-primary:    #f0f0f5;
  --text-secondary:  #a0a3c0;
  --text-tertiary:   #8a8ead;
  --text-on-primary: #ffffff;
  --text-on-accent:  #ffffff;
  --text-link:       #bbc3ff;
  --text-link-hover: #dde1ff;

  /* Semantic status colors */
  --success:    #4ade80;
  --success-bg: #0a2618;
  --warning:    #facc15;
  --warning-bg: #261f0a;
  --danger:     #f87171;
  --danger-bg:  #260a0a;
  --info:       #38bdf8;
  --info-bg:    #0a1926;

  /* Chart colors */
  --chart-1:      #8e99e8;
  --chart-2:      #ff6468;
  --chart-3:      #4ade80;
  --chart-4:      #facc15;
  --chart-5:      #38bdf8;
  --chart-6:      #ce93d8;
  --chart-1-bg:   rgba(142, 153, 232, 0.2);
  --chart-2-bg:   rgba(255, 100, 104, 0.2);
  --chart-grid:   rgba(255, 255, 255, 0.06);
  --chart-tick:   var(--text-secondary);
  --chart-border: var(--border-default);
}

/* ----------------------------------------
   4. SPACING TOKENS (mode-independent)
   ---------------------------------------- */
:root {
  --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;
}

/* ----------------------------------------
   5. TYPOGRAPHY TOKENS (mode-independent)
   ---------------------------------------- */
:root {
  --font-heading: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ----------------------------------------
   6. BORDER RADIUS TOKENS (mode-independent)
   ---------------------------------------- */
:root {
  /* Named sizes */
  --radius-sm:    6px;
  --radius-md:    8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --radius-2xl:   20px;
  --radius-full:  9999px;

  /* Semantic aliases */
  --radius-pill:  9999px;
  --radius-card:  14px;
  --radius-input: 10px;
  --radius-badge: 9999px;
}

/* ----------------------------------------
   7. COMPONENT SIZE TOKENS (mode-independent)
   ---------------------------------------- */
:root {
  --topbar-height:      64px;
  --sidebar-width:      260px;
  --sidebar-rail-width: 64px;

  /* Noise texture - subtle grain effect */
  --noise-texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ----------------------------------------
   7b. TEXT SELECTION (mode-dependent)
   ---------------------------------------- */
::selection {
  background: var(--primary-200);
  color: var(--primary-900);
}

::-moz-selection {
  background: var(--primary-200);
  color: var(--primary-900);
}

[data-theme="dark"] ::selection {
  background: var(--primary-700);
  color: var(--primary-100);
}

[data-theme="dark"] ::-moz-selection {
  background: var(--primary-700);
  color: var(--primary-100);
}

/* ----------------------------------------
   8. THEME TRANSITION
   Smooth transition when toggling themes.
   Only activates after data-theme is set.
   ---------------------------------------- */
[data-theme="light"],
[data-theme="dark"] {
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}

/* ----------------------------------------
   9. REDUCED MOTION
   ---------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ----------------------------------------
   10. PRINT — Always light mode
   ---------------------------------------- */
@media print {
  :root {
    --surface-base:    #ffffff;
    --surface-raised:  #ffffff;
    --surface-overlay: #ffffff;
    --surface-input:   #ffffff;
    --surface-hover:   #f5f6fa;
    --surface-active:  #ecedf3;

    --border-default: #d8dae5;
    --border-strong:  #b8bccf;
    --border-focus:   #272974;

    --text-primary:    #1a1c2e;
    --text-secondary:  #5e647c;
    --text-tertiary:   #9298b0;
    --text-link:       #272974;
    --text-link-hover: #1e2060;

    --success:    #16a34a;
    --warning:    #ca8a04;
    --danger:     #dc2626;
    --info:       #0284c7;

    --chart-1:    #272974;
    --chart-2:    #b30e15;
    --chart-3:    #16a34a;
    --chart-4:    #ca8a04;
    --chart-5:    #0284c7;
    --chart-6:    #8e24aa;
    --chart-grid: rgba(0, 0, 0, 0.06);
  }
}
