/* ============================================================
   INFINITE MINDS ACADEMY — BRAND DESIGN SYSTEM v4.0
   Designed as a premium, highly modern, student-friendly visual framework.
   Uses the brand colors of Red, Black, and White (Crimson & Obsidian).
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   1. GOOGLE FONTS IMPORT
   ───────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─────────────────────────────────────────────────────────────
   2. DESIGN TOKENS — LIGHT MODE (Snow White & Crimson)
   ───────────────────────────────────────────────────────────── */
:root {
  /* --- Crimson Red Brand Palette --- */
  --color-primary-50: #fff1f2;
  --color-primary-100: #ffe4e6;
  --color-primary-200: #fecdd3;
  --color-primary-300: #fda4af;
  --color-primary-400: #fb7185;
  --color-primary-500: #f43f5e;
  --color-primary-600: #e11d48;
  --color-primary-700: #be123c;
  --color-primary-800: #9f1239;
  --color-primary-900: #881337;
  --color-primary-950: #4c0519;

  /* --- Gold/Amber Accent --- */
  --color-accent-300: #fde047;
  --color-accent-400: #facc15;
  --color-accent-500: #eab308;
  --color-accent-600: #ca8a04;
  --color-accent-700: #a16207;
  --color-accent-glow: rgba(234, 179, 8, 0.15);

  /* --- Premium Neutrals --- */
  --color-neutral-0: #ffffff;
  --color-neutral-50: #f8fafc;
  --color-neutral-100: #f1f5f9;
  --color-neutral-200: #e2e8f0;
  --color-neutral-300: #cbd5e1;
  --color-neutral-400: #94a3b8;
  --color-neutral-500: #64748b;
  --color-neutral-600: #475569;
  --color-neutral-700: #334155;
  --color-neutral-800: #1e293b;
  --color-neutral-900: #0f172a;
  --color-neutral-950: #020617;

  /* --- Semantics --- */
  --color-success-50: #f0fdf4;
  --color-success-100: #dcfce7;
  --color-success-500: #10b981;
  --color-success-600: #059669;
  --color-success-700: #047857;

  --color-warning-50: #fffbeb;
  --color-warning-100: #fef3c7;
  --color-warning-500: #f59e0b;
  --color-warning-600: #d97706;
  --color-warning-700: #b45309;

  --color-error-50: #fef2f2;
  --color-error-100: #fee2e2;
  --color-error-500: #ef4444;
  --color-error-600: #dc2626;
  --color-error-700: #b91c1c;

  --color-info-50: #f0f9ff;
  --color-info-100: #e0f2fe;
  --color-info-500: #0ea5e9;
  --color-info-600: #0284c7;
  --color-info-700: #0369a1;

  /* --- Gradients --- */
  --gradient-primary: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  --gradient-accent: linear-gradient(135deg, #facc15 0%, #eab308 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-error: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.15) 100%);

  /* --- UI Mapping (Light) --- */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-raised: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-subtle: #f8fafc;

  --border-color: rgba(226, 232, 240, 0.8);
  --border-strong: rgba(203, 213, 225, 0.9);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-disabled: #cbd5e1;
  --text-inverse: #ffffff;

  --text-brand: #e11d48;
  --bg-brand: #e11d48;
  --bg-brand-hover: #be123c;

  /* --- Fonts & Spacings --- */
  --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.03), 0 1px 2px 0 rgba(0, 0, 0, 0.02);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.06), 0 4px 12px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 28px 72px -10px rgba(0, 0, 0, 0.08), 0 10px 30px -8px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.03), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 20px 48px -8px rgba(225, 29, 72, 0.1), 0 0 1px 1px rgba(225, 29, 72, 0.06);
  --shadow-brand: 0 10px 30px -5px rgba(225, 29, 72, 0.25);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 68px;
  --header-height: 64px;
  --content-max-width: 1440px;

  --z-sidebar: 30;
  --z-header: 40;
  --z-dropdown: 50;
  --z-modal: 60;
  --z-toast: 70;
  --z-overlay: 20;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─────────────────────────────────────────────────────────────
   3. DESIGN TOKENS — DARK MODE (Obsidian Slate & Crimson Red)
   ───────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-base: #030712;
  --bg-surface: #0f172a;
  --bg-surface-raised: #1e293b;
  --bg-muted: #1e293b;
  --bg-subtle: #090e1a;

  --border-color: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;
  --text-inverse: #030712;

  --text-brand: #fb7185;
  --bg-brand: #e11d48;
  --bg-brand-hover: #f43f5e;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 24px 60px -8px rgba(0, 0, 0, 0.7), 0 0 1px 1px rgba(225, 29, 72, 0.2);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 32px 72px rgba(0, 0, 0, 0.6);
  --shadow-brand: 0 10px 30px -5px rgba(225, 29, 72, 0.4);

  --gradient-glass: linear-gradient(135deg, rgba(11, 15, 25, 0.8) 0%, rgba(17, 24, 39, 0.4) 100%);
}

/* ─────────────────────────────────────────────────────────────
   4. BASE / RESET / SCROLLBAR
   ───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-y: scroll; /* Prevent layout shift between long/short pages */
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Minimalist Crimson Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-500);
  border: 2px solid transparent;
  background-clip: padding-box;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--color-neutral-700);
  border: 2px solid transparent;
  background-clip: padding-box;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-500);
  border: 2px solid transparent;
  background-clip: padding-box;
}

:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────
   5. LAYOUT (HEADER, SIDEBAR & MAIN WRAPPER)
   ───────────────────────────────────────────────────────────── */
.ima-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  transition: all var(--transition-slow);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .ima-header {
  background: rgba(11, 15, 25, 0.7);
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

@media (min-width: 768px) {
  .ima-header {
    left: var(--sidebar-width);
  }
}

.ima-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow), width var(--transition-slow),
              background-color var(--transition-slow), border-color var(--transition-slow);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .ima-sidebar {
  background: rgba(11, 15, 25, 0.88);
  border-right-color: rgba(255, 255, 255, 0.05);
}

@media (max-width: 767px) {
  .ima-sidebar {
    transform: translateX(-100%);
  }
  .ima-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
}

.ima-main,
.main-content {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  padding: var(--space-6) var(--space-8);
  transition: margin-left var(--transition-slow);
}

@media (max-width: 767px) {
  .ima-main,
  .main-content {
    margin-left: 0;
    padding: var(--space-4);
  }
}

.ima-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.ima-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* ─────────────────────────────────────────────────────────────
   6. BUTTONS WITH CRIMSON INTERACTION
   ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  padding: 0.625rem var(--space-5);
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary Button (Crimson Gradient) */
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.18);
  border: none;
}

.btn-primary:hover {
  box-shadow: var(--shadow-brand);
  transform: translateY(-2px);
}

/* Secondary Button */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

/* Danger Button */
.btn-danger {
  background: var(--gradient-error);
  color: #fff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
  border: none;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.3);
}

/* Gold/Accent Button */
.btn-accent {
  background: var(--gradient-accent);
  color: #0f172a;
  font-weight: var(--font-bold);
  border: none;
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px var(--color-accent-glow);
}

/* Button Sizes */
.btn-sm {
  padding: 0.4375rem var(--space-4);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-lg {
  padding: 0.75rem var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

.btn-icon {
  padding: 0.5625rem;
  width: 2.25rem;
  height: 2.25rem;
}

.btn-icon.btn-sm {
  padding: 0.375rem;
  width: 1.75rem;
  height: 1.75rem;
}

.btn-icon.btn-lg {
  padding: 0.75rem;
  width: 2.75rem;
  height: 2.75rem;
}

/* ─────────────────────────────────────────────────────────────
   7. FORM ELEMENTS (GLOWING FOCUS FIELDS)
   ───────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 0.625rem var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  outline: none;
  line-height: var(--leading-normal);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  background: var(--bg-surface);
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.15);
}

.form-input.error,
.form-select.error {
  border-color: var(--color-error-500);
}

.form-input.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
  padding-right: 2.75rem;
}

.form-group {
  margin-bottom: var(--space-5);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error-600);
  margin-top: var(--space-1);
}

/* Icon inputs */
.input-icon-wrapper {
  position: relative;
}

.input-icon-left {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-icon-right {
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.has-icon-left .form-input {
  padding-left: 2.75rem;
}

.has-icon-right .form-input {
  padding-right: 2.75rem;
}

/* Search bar styling */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.5rem var(--space-4);
  transition: all var(--transition-base);
}

.search-bar:focus-within {
  background: var(--bg-surface);
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
}

.search-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--text-sm);
  color: var(--text-primary);
  width: 100%;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--text-sm);
  color: var(--text-primary);
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────
   8. BADGES & LABELS
   ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  line-height: 1.3;
  white-space: nowrap;
}

.badge-primary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

.badge-accent {
  background: rgba(212, 168, 83, 0.15);
  color: var(--color-accent-600);
}

.badge-success {
  background: var(--color-success-100);
  color: var(--color-success-700);
}

.badge-warning {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}

.badge-error {
  background: var(--color-error-100);
  color: var(--color-error-700);
}

.badge-info {
  background: var(--color-info-100);
  color: var(--color-info-700);
}

.badge-neutral,
.badge-secondary {
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
}

.badge-purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.badge-danger {
  background: var(--color-error-100);
  color: var(--color-error-700);
}

[data-theme="dark"] .badge-primary {
  background: rgba(225, 29, 72, 0.2);
  color: var(--color-primary-300);
}

[data-theme="dark"] .badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

[data-theme="dark"] .badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

[data-theme="dark"] .badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

[data-theme="dark"] .badge-info {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
}

[data-theme="dark"] .badge-neutral,
[data-theme="dark"] .badge-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

[data-theme="dark"] .badge-purple {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
}

[data-theme="dark"] .badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   9. CARDS (FLOATING HOVER ACTIONS)
   ───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card-hover:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-primary-300);
  transform: translateY(-4px) scale(1.005);
}

[data-theme="dark"] .card-hover:hover {
  border-color: rgba(225, 29, 72, 0.4);
}

.card-glass {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .card-glass {
  background: rgba(11, 15, 25, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: linear-gradient(180deg, var(--bg-subtle), transparent);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

/* Stat Cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
  overflow: hidden;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: var(--radius-xl);
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--stat-accent, var(--gradient-primary));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.stat-card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--space-2);
}

.stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

/* Stat body */
.stat-body {
  flex: 1;
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--space-2);
}

/* ─────────────────────────────────────────────────────────────
   10. AVATARS
   ───────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-weight: var(--font-bold);
  background: var(--color-primary-50);
  color: var(--color-primary-600);
  vertical-align: middle;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs { width: 1.5rem;  height: 1.5rem;  font-size: 0.625rem; }
.avatar-sm { width: 2rem;    height: 2rem;    font-size: var(--text-xs); }
.avatar-md { width: 2.5rem;  height: 2.5rem;  font-size: var(--text-sm); }
.avatar-lg { width: 3rem;    height: 3rem;    font-size: var(--text-base); }
.avatar-xl { width: 3.75rem; height: 3.75rem; font-size: var(--text-xl); }

[data-theme="dark"] .avatar {
  background: rgba(225, 29, 72, 0.2);
  color: var(--color-primary-300);
}

/* ─────────────────────────────────────────────────────────────
   11. PROGRESS BARS
   ───────────────────────────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

[data-theme="dark"] .progress {
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  height: 100%;
  background: var(--color-primary-600);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.success { background: var(--color-success-500); }
.progress-bar.warning { background: var(--color-warning-500); }
.progress-bar.error   { background: var(--color-error-500); }
.progress-bar.accent  { background: linear-gradient(90deg, var(--color-accent-500), var(--color-accent-400)); }

.progress-bar.striped {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255, 255, 255, 0.15) 10px,
    rgba(255, 255, 255, 0.15) 20px
  );
  animation: stripeMove 1.5s linear infinite;
}

@keyframes stripeMove {
  to {
    background-position: 28px 0;
  }
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-track {
  fill: none;
  stroke: var(--color-neutral-200);
}

.progress-ring-bar {
  fill: none;
  stroke: var(--color-primary-600);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

[data-theme="dark"] .progress-ring-track {
  stroke: rgba(255, 255, 255, 0.08);
}

/* ─────────────────────────────────────────────────────────────
   12. TABLES (GAPPED & DE-GRIDDED LAYOUT)
   ───────────────────────────────────────────────────────────── */
.table-responsive {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table thead {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
}

.data-table thead th {
  padding: var(--space-4) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.data-table thead th.sortable {
  cursor: pointer;
}

.data-table thead th.sortable:hover {
  color: var(--text-primary);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-base);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.01);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.data-table tbody tr:hover {
  background: var(--bg-muted);
}

.data-table tbody td {
  padding: var(--space-4) var(--space-4);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table .td-actions {
  text-align: right;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─────────────────────────────────────────────────────────────
   13. SIDEBAR NAVIGATION CONTROLS (CRIMSON HIGHLIGHTS)
   ───────────────────────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.625rem var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  position: relative;
  outline: none;
}

.nav-item:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: rgba(225, 29, 72, 0.06);
  color: var(--color-primary-700);
  /* Faux bold to prevent layout shift */
  -webkit-text-stroke: 0.3px currentColor;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.04);
}

[data-theme="dark"] .nav-item.active {
  background: rgba(225, 29, 72, 0.15);
  color: var(--color-primary-300);
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.1);
}

.nav-item .nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-base);
}

.nav-item:hover .nav-icon {
  transform: scale(1.1);
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-4) var(--space-1);
  margin-top: var(--space-4);
}

.nav-submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-submenu.expanded {
  grid-template-rows: 1fr;
}

.submenu-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: var(--space-6);
  margin-top: var(--space-1);
}

.nav-submenu .nav-item {
  font-size: var(--text-xs);
  padding: 0.5rem var(--space-4);
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: 0.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  position: relative;
}

.nav-submenu .nav-item:hover {
  background: transparent;
  color: var(--color-primary-600);
  border-left-color: var(--color-primary-200);
  transform: translateX(4px);
}

.nav-submenu .nav-item.active {
  background: transparent;
  color: var(--color-primary-700);
  border-left-color: var(--color-primary-600);
  font-weight: var(--font-semibold);
  -webkit-text-stroke: 0;
  box-shadow: none;
}

.nav-submenu .nav-item::before {
  display: none !important;
}

[data-theme="dark"] .nav-submenu .nav-item:hover {
  color: var(--color-primary-400);
  border-left-color: rgba(225, 29, 72, 0.3);
}

[data-theme="dark"] .nav-submenu .nav-item.active {
  color: var(--color-primary-300);
  border-left-color: var(--color-primary-500);
  background: transparent;
  box-shadow: none;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 4px;
  background: var(--color-primary-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

[data-theme="dark"] .nav-item.active::before {
  background: var(--color-primary-500);
}

.sidebar-nav {
  position: relative;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}
.sidebar-nav::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Opera */
}

.sidebar-nav .nav-item {
  position: relative;
}

/* Chevron indicator */
.nav-chevron {
  color: var(--text-muted);
  transition: transform var(--transition-base), color var(--transition-base);
}
.nav-item.open .nav-chevron {
  transform: rotate(180deg);
}
.nav-item:hover .nav-chevron,
.nav-item.open .nav-chevron {
  color: var(--text-primary);
}
.nav-item.active .nav-chevron {
  color: var(--color-primary-600);
}
[data-theme="dark"] .nav-item.active .nav-chevron {
  color: var(--color-primary-400);
}

.nav-item.open {
  color: var(--text-primary);
  font-weight: var(--font-medium);
}
[data-theme="dark"] .nav-item.open {
  color: var(--text-primary);
}

/* Specificity override: keep active text color even when expanded/open */
.nav-item.active.open {
  color: var(--color-primary-700);
}
[data-theme="dark"] .nav-item.active.open {
  color: var(--color-primary-300);
}

/* ─────────────────────────────────────────────────────────────
   14. DROPDOWN COMPONENT
   ───────────────────────────────────────────────────────────── */
.dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: var(--space-2);
  min-width: 12rem;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: opacity var(--transition-fast), visibility var(--transition-fast),
              transform var(--transition-fast);
  transform-origin: top right;
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.5rem var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-muted);
}

.dropdown-item.danger {
  color: var(--color-error-600);
}

.dropdown-item.danger:hover {
  background: var(--color-error-50);
}

[data-theme="dark"] .dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.10);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-1) 0;
}

/* ─────────────────────────────────────────────────────────────
   15. MODAL PANELS (FROSTED CRIMSON LAYERS)
   ───────────────────────────────────────────────────────────── */
.modal-wrapper,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-wrapper.open,
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Let modal-backdrop act as its own overlay since it doesn't have a separate child */
.modal-backdrop {
  background: rgba(3, 7, 18, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 32rem;
  overflow: hidden;
  transform: translateY(16px) scale(0.95);
  transition: transform var(--transition-spring);
  z-index: 10;
}

.modal-wrapper.open .modal-panel,
.modal-backdrop.open .modal-panel {
  transform: translateY(0) scale(1);
}

.modal-panel.modal-sm { max-width: 22rem; }
.modal-panel.modal-md { max-width: 28rem; }
.modal-panel.modal-lg { max-width: 40rem; }
.modal-panel.modal-xl { max-width: 56rem; }

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-5) var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ─────────────────────────────────────────────────────────────
   16. TOAST NOTIFICATIONS
   ───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 24rem;
  width: 100%;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  align-items: start;
  gap: var(--space-3);
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
  overflow: hidden;
}

.toast.dismissing {
  animation: toastSlideOut 0.2s ease-in forwards;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--toast-accent, var(--color-primary-500));
}

.toast-success { --toast-accent: var(--color-success-500); }
.toast-error   { --toast-accent: var(--color-error-500); }
.toast-warning { --toast-accent: var(--color-warning-500); }
.toast-info    { --toast-accent: var(--color-info-500); }

.toast-icon {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--color-success-600); background: var(--color-success-50); }
.toast-error   .toast-icon { color: var(--color-error-600);   background: var(--color-error-50); }
.toast-warning .toast-icon { color: var(--color-warning-600); background: var(--color-warning-50); }
.toast-info    .toast-icon { color: var(--color-info-600);    background: var(--color-info-50); }

[data-theme="dark"] .toast-success .toast-icon { color: #34d399; background: rgba(16, 185, 129, 0.15); }
[data-theme="dark"] .toast-error   .toast-icon { color: #f87171; background: rgba(239, 68, 68, 0.15); }
[data-theme="dark"] .toast-warning .toast-icon { color: #fbbf24; background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .toast-info    .toast-icon { color: #38bdf8; background: rgba(14, 165, 233, 0.15); }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: var(--leading-snug);
}

.toast-close {
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
  background: var(--bg-muted);
}

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; max-height: 200px; margin-bottom: 0; }
  to   { transform: translateX(110%); opacity: 0; max-height: 0; padding: 0; margin-bottom: -8px; }
}

/* ─────────────────────────────────────────────────────────────
   17. SHIMMER LOADERS
   ───────────────────────────────────────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -600px 0;
  }
  100% {
    background-position: 600px 0;
  }
}

.skeleton {
  background: linear-gradient(90deg,
      var(--color-neutral-200) 25%,
      var(--color-neutral-100) 50%,
      var(--color-neutral-200) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg,
      rgba(255, 255, 255, 0.05) 25%,
      rgba(255, 255, 255, 0.09) 50%,
      rgba(255, 255, 255, 0.05) 75%);
  background-size: 600px 100%;
}

.skeleton-text {
  height: 0.875rem;
  border-radius: var(--radius-full);
}

.skeleton-title {
  height: 1.25rem;
  border-radius: var(--radius-full);
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 6rem;
  border-radius: var(--radius-xl);
}

/* ─────────────────────────────────────────────────────────────
   18. EMPTY STATES
   ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-6);
}

.empty-state-icon {
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
}

.empty-state-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 22rem;
  line-height: var(--leading-relaxed);
}

.empty-state-action {
  margin-top: var(--space-6);
}

/* ─────────────────────────────────────────────────────────────
   19. PAGE HEADER WRAPPER
   ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text-brand);
}

.breadcrumb-sep {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.breadcrumb .current {
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* ─────────────────────────────────────────────────────────────
   20. TABS CONTROLS
   ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-6);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-item {
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--color-primary-600);
  border-bottom-color: var(--color-primary-600);
  font-weight: var(--font-semibold);
}

[data-theme="dark"] .tab-item.active {
  color: var(--color-primary-400);
  border-bottom-color: var(--color-primary-400);
}

/* ─────────────────────────────────────────────────────────────
   21. ACCORDION WRAPPER
   ───────────────────────────────────────────────────────────── */
.accordion-item {
  border-bottom: 1px solid var(--border-color);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  text-align: left;
  gap: var(--space-3);
  transition: background-color var(--transition-fast);
}

.accordion-trigger:hover {
  background: var(--bg-muted);
}

.accordion-chevron {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.accordion-item.open .accordion-content {
  max-height: 500px;
}

.accordion-content-inner {
  padding: 0 var(--space-5) var(--space-4);
}

/* ─────────────────────────────────────────────────────────────
   22. LIGHT/DARK THEME TOGGLE
   ───────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.theme-toggle:hover {
  color: var(--color-primary-500);
  background: var(--bg-muted);
  border-color: var(--color-primary-500);
}

/* ─────────────────────────────────────────────────────────────
   23. UTILITIES & HELPER CLASSES
   ───────────────────────────────────────────────────────────── */
.surface {
  background: var(--bg-surface);
}

.surface-raised {
  background: var(--bg-surface-raised);
}

.text-primary-color {
  color: var(--text-primary);
}

.text-secondary-color {
  color: var(--text-secondary);
}

.text-muted-color {
  color: var(--text-muted);
}

.text-brand-color {
  color: var(--text-brand);
}

.border-base {
  border: 1px solid var(--border-color);
}

.divide-base > * + * {
  border-top: 1px solid var(--border-color);
}

.rounded-token {
  border-radius: var(--radius-xl);
}

.shadow-token {
  box-shadow: var(--shadow-card);
}

/* Line clamps */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Smooth page fade transition */
.page-enter {
  animation: pageEnter 0.25s ease-out;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Infinite Loading Spinners */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 0.75rem;
  height: 0.75rem;
}

.spinner-lg {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─────────────────────────────────────────────────────────────
   24. ANIMATIONS & DELAYS
   ───────────────────────────────────────────────────────────── */
.animate-fade-in {
  animation: fadeIn 0.3s ease-out both;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out both;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out both;
}

.animate-scale-in {
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* Micro delays */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* ─────────────────────────────────────────────────────────────
   25. RESPONSIVE GRID WRAPPERS
   ───────────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 640px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
}
@media (min-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }
}

/* ─────────────────────────────────────────────────────────────
   26. HELPER OVERRIDES (TAILWIND SYNERGY)
   ───────────────────────────────────────────────────────────── */
.divide-y > * + * {
  border-top-width: 1px;
  border-color: var(--border-color);
}
.divide-x > * + * {
  border-left-width: 1px;
  border-color: var(--border-color);
}

/* ─────────────────────────────────────────────────────────────
   27. PRINT STYLES
   ───────────────────────────────────────────────────────────── */
@media print {
  .ima-sidebar,
  .ima-header,
  .btn,
  #toast-container {
    display: none !important;
  }

  .ima-main,
  .main-content {
    margin: 0;
    padding: 1rem;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* ── Legacy Tailwind Color Override ─────────────────────────────────────────
   Maps old Tailwind color utilities to the IMA design system variables.
   Pages that have not yet been fully migrated will still render correctly.
   ─────────────────────────────────────────────────────────────────────────── */

/* Text */
.text-gray-900, .text-gray-800 { color: var(--text-primary) !important; }
.text-gray-700, .text-gray-600 { color: var(--text-secondary) !important; }
.text-gray-500, .text-gray-400 { color: var(--text-muted) !important; }
.text-blue-700, .text-blue-600, .text-blue-500 { color: var(--color-primary-600) !important; }
.text-indigo-600, .text-indigo-500 { color: var(--color-primary-600) !important; }
.text-green-700, .text-green-600 { color: var(--color-success-600) !important; }
.text-red-700, .text-red-600 { color: var(--color-error-600) !important; }
.text-amber-600, .text-amber-500, .text-yellow-600 { color: var(--color-warning-600) !important; }

/* Background (subtle overrides — not white) */
.bg-gray-50 { background-color: var(--bg-subtle) !important; }
.bg-gray-100 { background-color: var(--bg-muted) !important; }
.bg-blue-50, .bg-indigo-50 { background-color: rgba(225,29,72,0.04) !important; }

/* Border */
.border-gray-100, .border-gray-200, .border-gray-300 { border-color: var(--border-color) !important; }

/* Focus rings — use crimson instead of blue */
.focus\:ring-blue-500:focus, .focus\:border-blue-500:focus {
  --tw-ring-color: var(--color-primary-500) !important;
  border-color: var(--color-primary-500) !important;
}

/* --- Brand Logo Filter for Light Theme --- */
.brand-logo-img {
  transition: filter var(--transition-base, 250ms ease);
}
html:not([data-theme="dark"]) .brand-logo-img,
html[data-theme="light"] .brand-logo-img {
  filter: brightness(0) saturate(100%) invert(24%) sepia(86%) saturate(2331%) hue-rotate(334deg) brightness(94%) contrast(92%);
}
[data-theme="dark"] .brand-logo-img {
  filter: none;
}

