/* ==========================================================================
   DESIGN TOKENS - LOCAL CLASSROOM SYSTEM (EdTech Modern SaaS)
   Single source of truth for visual styling.
   Zero external dependencies, 100% offline & local LAN compatible.
   ========================================================================== */

:root {
  /* --- Colors: Brand & Primary (iOS 18 Apple Blue) --- */
  --color-primary: #007AFF;
  --color-primary-hover: #0062CC;
  --color-primary-active: #0051A8;
  --color-primary-soft: rgba(0, 122, 255, 0.11);
  --color-primary-border: rgba(0, 122, 255, 0.25);
  --color-primary-contrast: #ffffff;
  --color-ios-fill: rgba(118, 118, 128, 0.11);
  --color-ios-fill-hover: rgba(118, 118, 128, 0.18);
  --color-ios-red: #FF3B30;
  --color-ios-red-soft: rgba(255, 59, 48, 0.11);
  --color-ios-green: #16a34a;
  --color-ios-green-soft: rgba(52, 199, 89, 0.14);

  /* --- Colors: Neutral & Surfaces --- */
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-surface-active: #e2e8f0;
  --color-surface-subtle: #f8fafc;

  /* --- Colors: Text Hierarchy --- */
  --color-text: #0f172a;            /* Slate 900: High contrast, readable */
  --color-text-secondary: #1e293b;  /* Slate 800: Crisp body & labels */
  --color-text-muted: #334155;      /* Slate 700: High-contrast hints & metadata */
  --color-text-disabled: #64748b;   /* Slate 500: Readable inactive states */
  --color-text-inverse: #ffffff;

  /* --- Colors: Borders & Dividers --- */
  --color-border: #e2e8f0;          /* Slate 200: Card borders, inputs */
  --color-border-strong: #cbd5e1;   /* Slate 300: Focus/hover borders */
  --color-border-subtle: #f1f5f9;

  /* --- Colors: Feedback & Status --- */
  --color-success: #16a34a;
  --color-success-hover: #15803d;
  --color-success-soft: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-warning: #d97706;
  --color-warning-hover: #b45309;
  --color-warning-soft: #fffbeb;
  --color-warning-border: #fde68a;

  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-soft: #fef2f2;
  --color-danger-border: #fecaca;

  --color-info: #0284c7;
  --color-info-hover: #0369a1;
  --color-info-soft: #f0f9ff;
  --color-info-border: #bae6fd;

  /* --- Typography Stack (Self-Hosted Be Vietnam Pro & 100% Vietnamese Native) --- */
  --font-display: "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Ubuntu", "Cantarell", sans-serif;
  --font-sans: "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Ubuntu", "Cantarell", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;

  /* --- Typography Scale --- */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */

  /* --- Font Weights --- */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* --- Line Heights --- */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* --- 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 Radius --- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* --- Shadows (Soft & Modern) --- */
  --shadow-none: none;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  /* --- Transitions & Motion --- */
  --motion-fast: 120ms;
  --motion-normal: 200ms;
  --motion-slow: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* --- Z-Index Hierarchy --- */
  --z-base: 1;
  --z-sticky: 40;
  --z-dropdown: 50;
  --z-overlay: 100;
  --z-modal: 200;
  --z-toast: 1100;

  /* --- Layout & Sizing --- */
  --sidebar-width: 245px;
  --sidebar-collapsed-width: 68px;
  --header-height: 56px;
  --container-max-width: 1560px;
  --content-narrow-width: 720px;

  /* --- Student UI Architecture Tokens (Phase 2) --- */
  --student-header-height: 52px;
  --student-touch-min: 44px;
  --student-reading-max-width: 820px;
  --student-single-max-width: 640px;
  --student-workspace-max-width: 1480px;
  --student-palette-width: 260px;
  --student-outline-width: 280px;
  --student-focus-ring: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary);

  /* --- Semantic Aliases & Compatibility Tokens (Phase A) --- */
  --color-text-main: var(--color-text);
  --color-bg: var(--color-background);
  --color-bg-main: var(--color-background);
  --color-bg-subtle: var(--color-surface-subtle);

  --color-primary-subtle: var(--color-primary-soft);
  --color-primary-light: var(--color-primary-soft);
  --color-primary-dark: var(--color-primary-active);

  --color-success-subtle: var(--color-success-soft);
  --color-warning-subtle: var(--color-warning-soft);
  --color-warning-dark: var(--color-warning-hover);
  --color-danger-subtle: var(--color-danger-soft);

  --text-xs: var(--font-size-xs);
  --text-sm: var(--font-size-sm);
  --text-base: var(--font-size-base);
  --text-lg: var(--font-size-lg);
  --text-xl: var(--font-size-xl);
  --text-2xl: var(--font-size-2xl);
  --text-3xl: var(--font-size-3xl);
  --font-size-md: var(--font-size-base);

  --border-radius-sm: var(--radius-sm);
  --border-radius-md: var(--radius-md);
}

/* Responsive container & layout tuning across 3 target viewports */
@media (min-width: 1600px) {
  :root {
    --container-max-width: 1640px;
    --sidebar-width: 255px;
  }
}

@media (max-width: 1366px) {
  :root {
    --sidebar-width: 240px;
  }
}

@media (max-height: 768px) {
  :root {
    --header-height: 52px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
    --motion-normal: 0ms;
    --motion-slow: 0ms;
  }
}
