/* ============================================
   TOKENS.CSS — Design system & theme variables
   BizFinance Pro ERP UI Framework
   ============================================ */

:root {
  /* Semantic aliases (use these in components) */
  --background-primary: var(--page-bg);
  --background-secondary: var(--page-bg-subtle);
  --surface-card: var(--card-bg);
  --surface-elevated: var(--card-bg-elevated);
  --text-primary-color: var(--text-primary);
  --text-secondary-color: var(--text-secondary);
  --primary-color: var(--color-primary);
  --success-color: var(--color-success);
  --warning-color: var(--color-warning);
  --danger-color: var(--color-danger);
  --sidebar-background: var(--sidebar-bg);
  --bg-card: var(--card-bg);
  --bg-muted: var(--page-bg-subtle);

  /* Brand */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-darker: #1e3a8a;
  --color-primary-light: #eff6ff;
  --color-primary-muted: #dbeafe;
  --color-secondary: #0891b2;
  --color-accent: #6366f1;

  /* Semantic */
  --color-success: #059669;
  --color-success-light: #ecfdf5;
  --color-success-text: #065f46;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;
  --color-warning-text: #92400e;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-danger-text: #991b1b;
  --color-info: #0284c7;
  --color-info-light: #f0f9ff;
  --color-info-text: #1e40af;

  /* Layout */
  --sidebar-width: 276px;
  --sidebar-collapsed-width: 76px;
  --header-height: 64px;
  --content-max-width: 1480px;

  /* Sidebar — professional dark nav on light app shell */
  --sidebar-bg: #0f172a;
  --sidebar-bg-end: #0b1120;
  --sidebar-bg-elevated: #1e293b;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f8fafc;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(37, 99, 235, 0.2);
  --sidebar-active-border: #3b82f6;
  --sidebar-search-bg: rgba(0, 0, 0, 0.25);
  --sidebar-tooltip-bg: #1e293b;
  --sidebar-tooltip-text: #f8fafc;

  /* Surfaces — Light mode */
  --page-bg: #f4f6f9;
  --page-bg-subtle: #eef1f6;
  --card-bg: #ffffff;
  --card-bg-elevated: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --input-bg: #ffffff;
  --overlay-bg: rgba(15, 23, 42, 0.55);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Borders */
  --border-color: #e2e8f0;
  --border-color-subtle: #f1f5f9;
  --border-color-strong: #cbd5e1;
  --border-focus: var(--color-primary);

  /* Table */
  --table-header-bg: #f8fafc;
  --table-row-hover: #f1f5f9;
  --table-row-stripe: #fafbfc;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
  --shadow-sidebar: 4px 0 32px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.03);

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

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13.5px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 22px;
  --font-size-3xl: 28px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.65;
  --letter-tight: -0.02em;

  /* 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;

  /* Transitions */
  --transition-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-sidebar: 200;
  --z-header: 100;
  --z-overlay: 199;
  --z-modal: 500;
  --z-confirm: 600;
  --z-toast: 1000;

  color-scheme: light;
}

/* Dark mode — material-style surfaces (#121212), not pure black */
:root[data-theme="dark"] {
  color-scheme: dark;

  --page-bg: #121212;
  --page-bg-subtle: #161616;
  --card-bg: #1e1e1e;
  --card-bg-elevated: #252525;
  --header-bg: rgba(30, 30, 30, 0.94);
  --input-bg: #1a1a1a;
  --overlay-bg: rgba(0, 0, 0, 0.72);

  --text-primary: #f0f0f0;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;

  --border-color: #333333;
  --border-color-subtle: #2a2a2a;
  --border-color-strong: #404040;

  --table-header-bg: #252525;
  --table-row-hover: rgba(255, 255, 255, 0.04);
  --table-row-stripe: rgba(255, 255, 255, 0.02);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-sidebar: 4px 0 24px rgba(0, 0, 0, 0.45);

  --color-primary-light: rgba(37, 99, 235, 0.18);
  --color-primary-muted: rgba(37, 99, 235, 0.28);
  --color-success-light: rgba(5, 150, 105, 0.18);
  --color-success-text: #6ee7b7;
  --color-warning-light: rgba(217, 119, 6, 0.18);
  --color-warning-text: #fcd34d;
  --color-danger-light: rgba(220, 38, 38, 0.18);
  --color-danger-text: #fca5a5;
  --color-info-light: rgba(2, 132, 199, 0.18);
  --color-info-text: #7dd3fc;

  /* Sidebar — deeper in dark app */
  --sidebar-bg: #0a0a0a;
  --sidebar-bg-end: #050505;
  --sidebar-bg-elevated: #141414;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-search-bg: rgba(255, 255, 255, 0.06);
  --sidebar-tooltip-bg: #2a2a2a;
  --sidebar-tooltip-text: #f0f0f0;
}

/* Smooth theme transition on key surfaces */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition) !important;
}
