/* ==========================================================================
   EARNING PLATFORM — DESIGN TOKENS (Redesign Phase 2)
   Single source of truth for colour, spacing, radius, shadow, typography.
   Palette implements Them.txt §1 EXACTLY. Every component (components.css)
   and every later phase (3 landing, 4 user, 5 admin) must consume THESE
   variables — never hardcode a colour, radius or shadow in a view/layout.

   DARK MODE CONTRACT (user panel): Phase 6 flips `data-theme="dark"` on
   <html> (values in the [data-theme="dark"] block below) and persists the
   choice. Because components only read variables, the flip is the whole job.
   No data-theme attribute  ==  light (the delivered default).

   BREAKPOINTS (§10 — CSS variables cannot drive @media, so the scale is
   fixed here as the canonical list; components.css uses these literals):
     xs 360 · sm 576 · md 768 · lg 992 · xl 1024 · 2xl 1200 · 3xl 1366 · 4xl 1600 · max 1920
   ========================================================================== */

:root {
  /* --- §1 palette (EXACT values, do not alter) --- */
  --ep-primary: #2563EB;
  --ep-secondary: #0F172A;
  --ep-accent: #10B981;
  --ep-success: #16A34A;
  --ep-warning: #F59E0B;
  --ep-danger: #EF4444;
  --ep-bg: #F5F8FF;
  --ep-card: #FFFFFF;
  --ep-border: #E2E8F0;
  --ep-text: #0F172A;
  --ep-text-2: #64748B;

  /* --- derived shades (same hues, for hover/soft fills/rings) --- */
  --ep-primary-dark: #1D4ED8;
  --ep-primary-darker: #1E40AF;
  --ep-primary-soft: #EFF6FF;          /* tinted fill behind primary elements */
  --ep-primary-ring: rgba(37, 99, 235, .25);
  --ep-accent-dark: #059669;
  --ep-accent-soft: #ECFDF5;
  --ep-success-soft: #F0FDF4;
  --ep-warning-soft: #FFFBEB;
  --ep-warning-text: #92400E;
  --ep-danger-soft: #FEF2F2;
  --ep-danger-dark: #DC2626;
  --ep-info: #0284C7;
  --ep-info-soft: #F0F9FF;
  /* --- v9.11: brief palette — purple / cyan / pink / orange + gradients --- */
  --ep-purple: #7C3AED;
  --ep-purple-dark: #9333EA;
  --ep-purple-soft: #F5F3FF;
  --ep-cyan: #06B6D4;
  --ep-cyan-dark: #0EA5E9;
  --ep-cyan-soft: #ECFEFF;
  --ep-pink: #EC4899;
  --ep-pink-dark: #DB2777;
  --ep-pink-soft: #FDF2F8;
  --ep-orange: #F97316;
  --ep-orange-soft: #FFF7ED;
  --ep-grad-blue-purple: linear-gradient(135deg, #2563EB, #7C3AED);
  --ep-grad-cyan-blue: linear-gradient(135deg, #06B6D4, #2563EB);
  --ep-grad-purple-pink: linear-gradient(135deg, #7C3AED, #EC4899);
  --ep-grad-green-cyan: linear-gradient(135deg, #10B981, #06B6D4);
  --ep-grad-orange-yellow: linear-gradient(135deg, #F59E0B, #FACC15);
  --ep-text-3: #94A3B8;                /* placeholders, disabled, captions */
  --ep-border-strong: #CBD5E1;
  --ep-surface-2: #F1F5F9;             /* zebra rows, inset panels, skeleton base */
  --ep-overlay: rgba(15, 23, 42, .5);  /* modal backdrop */
  --ep-on-primary: #FFFFFF;            /* text on --ep-primary fills */
  --ep-on-accent: #FFFFFF;
  --ep-hero-gradient: linear-gradient(135deg, #2563EB 0%, #1D4ED8 55%, #0F766E 130%);

  /* --- typography (§3): Inter for Latin glyphs, Noto Sans Bengali for Bengali.
         Per-glyph fallback: Inter has no Bengali glyphs, so Bengali text
         falls through to Noto Sans Bengali automatically in this stack order. --- */
  --ep-font-sans: 'Noto Sans Bengali', 'Inter', 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ep-font-bn: 'Noto Sans Bengali', 'Hind Siliguri', 'Inter', system-ui, sans-serif;
  --ep-line-height: 1.6;               /* Bengali needs the taller line (§3) */
  --ep-line-height-tight: 1.35;

  /* --- spacing scale (4px base) --- */
  --ep-sp-1: .25rem;  --ep-sp-2: .5rem;   --ep-sp-3: .75rem;  --ep-sp-4: 1rem;
  --ep-sp-5: 1.25rem; --ep-sp-6: 1.5rem;  --ep-sp-8: 2rem;    --ep-sp-10: 2.5rem;
  --ep-sp-12: 3rem;   --ep-sp-16: 4rem;

  /* --- radius scale ("rounded cards and components", §1) --- */
  --ep-radius-xs: .25rem;
  --ep-radius-sm: .375rem;
  --ep-radius: .5rem;                  /* inputs, buttons */
  --ep-radius-md: .75rem;
  --ep-radius-lg: 1rem;                /* cards */
  --ep-radius-xl: 1.25rem;
  --ep-radius-pill: 999px;

  /* --- soft shadows (§1 "soft shadows"; never hard/heavy) --- */
  --ep-shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --ep-shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .05);
  --ep-shadow: 0 4px 12px rgba(15, 23, 42, .08);
  --ep-shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --ep-shadow-primary: 0 6px 16px rgba(37, 99, 235, .28);

  /* --- motion (§11: subtle & smooth only) --- */
  --ep-transition: .18s ease;
  --ep-transition-slow: .28s ease;

  /* --- layering --- */
  --ep-z-dropdown: 1000;
  --ep-z-sticky: 1020;
  --ep-z-modal: 1050;
  --ep-z-toast: 1090;

  /* --- Bootstrap 5.3 root-variable mapping (components.css does the
         component-level overrides; these align Bootstrap's own var-driven
         parts — body, links, borders, form focus — with the tokens) --- */
  --bs-body-bg: var(--ep-bg);
  --bs-body-color: var(--ep-text);
  --bs-body-font-family: var(--ep-font-sans);
  --bs-border-color: var(--ep-border);
  --bs-border-radius: var(--ep-radius);
  --bs-border-radius-lg: var(--ep-radius-lg);
  --bs-link-color: var(--ep-primary);
  --bs-link-hover-color: var(--ep-primary-dark);
  --bs-primary: var(--ep-primary);
  --bs-primary-rgb: 37, 99, 235;
  --bs-success: var(--ep-success);
  --bs-success-rgb: 22, 163, 74;
  --bs-warning: var(--ep-warning);
  --bs-warning-rgb: 245, 158, 11;
  --bs-danger: var(--ep-danger);
  --bs-danger-rgb: 239, 68, 68;
  --bs-secondary: var(--ep-secondary);
  --bs-secondary-rgb: 15, 23, 42;
  --bs-body-secondary-color: var(--ep-text-2);
  --bs-body-tertiary-bg: var(--ep-surface-2);
  --bs-emphasis-color: var(--ep-text);
}

/* ==========================================================================
   DARK — user panel. Same primary/accent (§1 hues survive on dark);
   backgrounds/surfaces/borders/text are the professional dark derivation.
   Activated ONLY by data-theme="dark" on <html> (Phase 6 persistence).
   ========================================================================== */
[data-theme="dark"] {
  color-scheme: dark; /* v9.75: native controls (select lists, spinners, scrollbars) render dark */
  --ep-bg: #0B1120;
  --ep-card: #111C30;
  --ep-border: #1E293B;
  --ep-border-strong: #334155;
  --ep-text: #F1F5F9;
  --ep-text-2: #94A3B8;
  --ep-text-3: #64748B;
  --ep-surface-2: #16233C;
  --ep-primary: #3B82F6;               /* lifted one step for dark contrast */
  --ep-primary-dark: #2563EB;
  --ep-primary-darker: #60A5FA;
  --ep-primary-soft: rgba(59, 130, 246, .14);
  --ep-primary-ring: rgba(59, 130, 246, .35);
  --ep-accent-soft: rgba(16, 185, 129, .13);
  --ep-success-soft: rgba(22, 163, 74, .14);
  --ep-warning-soft: rgba(245, 158, 11, .13);
  --ep-warning-text: #FBBF24;
  --ep-danger-soft: rgba(239, 68, 68, .13);
  --ep-info-soft: rgba(2, 132, 199, .16);
  --ep-purple: #8B5CF6;
  --ep-purple-dark: #A78BFA;
  --ep-purple-soft: rgba(124, 58, 237, .16);
  --ep-cyan: #22D3EE;
  --ep-cyan-dark: #38BDF8;
  --ep-cyan-soft: rgba(6, 182, 212, .14);
  --ep-pink: #F472B6;
  --ep-pink-dark: #EC4899;
  --ep-pink-soft: rgba(236, 72, 153, .14);
  --ep-orange: #FB923C;
  --ep-orange-soft: rgba(249, 115, 22, .14);
  --ep-overlay: rgba(2, 6, 23, .7);
  --ep-shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --ep-shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --ep-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  --ep-shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);
  --ep-shadow-primary: 0 6px 16px rgba(59, 130, 246, .3);
  --bs-body-bg: var(--ep-bg);
  --bs-body-color: var(--ep-text);
  --bs-border-color: var(--ep-border);
  --bs-body-secondary-color: var(--ep-text-2);
  --bs-body-tertiary-bg: var(--ep-surface-2);
  --bs-link-color: #60A5FA;
  --bs-link-hover-color: #93C5FD;
}

/* Cross-fade surfaces when the theme attribute flips (disabled under
   prefers-reduced-motion by the global rule in components.css). */
body, .card, .ep-card, .ep-stat, input, select, textarea, .table {
  transition: background-color var(--ep-transition), border-color var(--ep-transition), color var(--ep-transition);
}

/* ==========================================================================
   v9.75 — DESIGN.md v1.8-frontend-only tokens (§3 light + dark).
   NEW --color-* variables used ONLY by the user-panel redesign
   (.ep-user scope). The --ep-* values above are deliberately NOT
   changed: admin (--adm-* references them) and the public site keep
   rendering exactly as before.
   ========================================================================== */
:root {
  --color-primary: #2563EB; --color-primary-hover: #1D4ED8; --color-accent: #10B981;
  --color-bg: #F2F5FB; --color-surface: #FFFFFF; --color-text: #0F172A; --color-text-muted: #64748B;
  --color-border: #E2E8F0; --color-success: #10B981; --color-warning: #F59E0B; --color-danger: #EF4444;
  --color-primary-soft: #DBEAFE; --color-success-soft: #D1FAE5; --color-warning-soft: #FEF3C7; --color-danger-soft: #FEE2E2;
  --color-cyan-soft: #ECFEFF; --color-purple-soft: #EDE9FE; --color-rose-soft: #FDE8EF;
  --color-sidebar: linear-gradient(180deg, #1E3A8A 0%, #1D4ED8 55%, #2563EB 100%);
  --color-sidebar-text: #FFFFFF; --color-sidebar-muted: rgba(255, 255, 255, .72);
  --color-sidebar-active: rgba(255, 255, 255, .16);
  --grad-primary: linear-gradient(135deg, #2563EB, #1D4ED8);
  --grad-hero: linear-gradient(135deg, #2563EB 0%, #1D4ED8 55%, #1E40AF 100%);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --z-dropdown: 100; --z-sticky: 200; --z-bottomnav: 300; --z-sheet: 400; --z-modal: 500; --z-toast: 600;
  --sidebar-w: 264px; --sidebar-w-collapsed: 76px; --topbar-h: 60px; --bottomnav-h: 60px;
}
[data-theme="dark"] {
  --color-primary: #3B82F6; --color-primary-hover: #2563EB; --color-accent: #34D399;
  --color-bg: #0B1220; --color-surface: #1E293B; --color-text: #F1F5F9; --color-text-muted: #94A3B8;
  --color-border: #334155; --color-success: #34D399; --color-warning: #FBBF24; --color-danger: #F87171;
  --color-primary-soft: #1E3A8A; --color-success-soft: #064E3B; --color-warning-soft: #78350F; --color-danger-soft: #7F1D1D;
  --color-cyan-soft: rgba(6, 182, 212, .14); --color-purple-soft: rgba(124, 58, 237, .16); --color-rose-soft: rgba(236, 72, 153, .16);
  --color-sidebar: linear-gradient(180deg, #111C3E 0%, #1E3A8A 100%);
  --color-sidebar-text: #F1F5F9; --color-sidebar-muted: rgba(241, 245, 249, .72);
  --grad-primary: linear-gradient(135deg, #3B82F6, #2563EB);
  --grad-hero: linear-gradient(135deg, #3B82F6 0%, #2563EB 55%, #1E40AF 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .55);
}
