/**
 * ToolFlux Lab - Design Tokens
 * Semantic token architecture with high WCAG contrast for Light and Dark modes.
 */

:root,
[data-theme="light"] {
  color-scheme: light;

  /* Semantic Text Tokens */
  --text-primary: #0F172A;        /* Slate 900 */
  --text-secondary: #334155;      /* Slate 700 */
  --text-muted: #64748B;          /* Slate 500 */
  --text-placeholder: #94A3B8;    /* Slate 400 */
  --text-result: #1D4ED8;         /* High-contrast Royal Blue */
  --text-result-secondary: #0F172A;
  --text-inverse: #FFFFFF;

  /* Semantic Surface & Border Tokens */
  --surface: #FFFFFF;
  --surface-secondary: #F8FAFC;   /* Slate 50 */
  --surface-hover: #F1F5F9;       /* Slate 100 */
  --surface-elevated: #FFFFFF;
  --border: #CBD5E1;              /* Slate 300 */
  --border-subtle: #E2E8F0;       /* Slate 200 */

  /* Input & Control Tokens */
  --input-background: #FFFFFF;
  --input-text: #0F172A;
  --input-placeholder: #94A3B8;
  --input-border: #CBD5E1;
  --input-focus-border: #2563EB;
  --input-focus-ring: rgba(37, 99, 235, 0.18);
  --input-affix: #475569;         /* Slate 600 */

  /* Accent & Status Tokens */
  --accent: #2563EB;
  --accent-dark: #1D4ED8;
  --accent-light: #EFF6FF;
  --accent-glow: rgba(37, 99, 235, 0.15);

  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;

  /* Backward Compatibility Aliases */
  --bg-main: #F8FAFC;
  --bg-surface: var(--surface);
  --bg-surface-secondary: var(--surface-secondary);
  --bg-surface-hover: var(--surface-hover);
  --bg-input: var(--input-background);
  --border-color: var(--border);
  --text-main: var(--text-primary);
  --primary: var(--accent);
  --primary-dark: var(--accent-dark);
  --primary-light: var(--accent-light);
  --primary-glow: var(--accent-glow);
  --error: var(--danger);
  --error-bg: var(--danger-bg);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', 'Cairo', -apple-system, Tahoma, sans-serif;
  
  /* Font Sizes */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  --text-5xl: 3rem;      /* 48px */

  /* Spacing Scale */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Border Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.06), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --container-max: 1200px;
  --header-height: 64px;
}

/* =========================================================
   DARK MODE TOKENS (High-Contrast Numerical Precision)
========================================================= */
html.dark,
[data-theme="dark"] {
  color-scheme: dark;

  /* Semantic Text Tokens */
  --text-primary: #F8FAFC;        /* Slate 50 (maximum readability) */
  --text-secondary: #CBD5E1;      /* Slate 300 */
  --text-muted: #94A3B8;          /* Slate 400 */
  --text-placeholder: #64748B;    /* Slate 500 */
  --text-result: #38BDF8;         /* Radiant Sky Blue (WCAG AAA contrast on dark) */
  --text-result-secondary: #F1F5F9;
  --text-inverse: #020617;

  /* Semantic Surface & Border Tokens */
  --surface: #0F172A;             /* Slate 900 */
  --surface-secondary: #1E293B;   /* Slate 800 */
  --surface-hover: #334155;       /* Slate 700 */
  --surface-elevated: #1E293B;
  --border: #334155;              /* Slate 700 */
  --border-subtle: #1E293B;       /* Slate 800 */

  /* Input & Control Tokens */
  --input-background: #0B1120;     /* Deep slate for crisp text separation */
  --input-text: #F8FAFC;           /* Clear white-slate */
  --input-placeholder: #64748B;
  --input-border: #334155;
  --input-focus-border: #38BDF8;
  --input-focus-ring: rgba(56, 189, 248, 0.25);
  --input-affix: #94A3B8;          /* High readability for $, %, units */

  /* Accent & Status Tokens */
  --accent: #38BDF8;
  --accent-dark: #0284C7;
  --accent-light: rgba(56, 189, 248, 0.15);
  --accent-glow: rgba(56, 189, 248, 0.22);

  --success: #22C55E;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #F87171;
  --danger-bg: rgba(248, 113, 113, 0.15);

  /* Backward Compatibility Aliases */
  --bg-main: #020617;             /* Slate 950 */
  --bg-surface: var(--surface);
  --bg-surface-secondary: var(--surface-secondary);
  --bg-surface-hover: var(--surface-hover);
  --bg-input: var(--input-background);
  --border-color: var(--border);
  --text-main: var(--text-primary);
  --primary: var(--accent);
  --primary-dark: var(--accent-dark);
  --primary-light: var(--accent-light);
  --primary-glow: var(--accent-glow);
  --error: var(--danger);
  --error-bg: var(--danger-bg);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.7);
}
