/* =====================================================
   GLOBAL THEME — Single Source of Truth
   Neonatology App Design System v2.0
   ===================================================== */

:root {
  /* ── Primary Blue ──────────────────────────────── */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  /* Main brand */
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  --primary-950: #172554;

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

  /* Secondary aliases (for backwards compat) */
  --secondary-50: var(--neutral-50);
  --secondary-100: var(--neutral-100);
  --secondary-200: var(--neutral-200);
  --secondary-300: var(--neutral-300);
  --secondary-400: var(--neutral-400);
  --secondary-500: var(--neutral-500);
  --secondary-600: var(--neutral-600);
  --secondary-700: var(--neutral-700);
  --secondary-800: var(--neutral-800);
  --secondary-900: var(--neutral-900);
  --secondary-950: var(--neutral-950);

  /* ── Accent / Cyan ─────────────────────────────── */
  --accent-500: #0891b2;
  --accent-600: #0e7490;

  /* ── Semantic — Success ────────────────────────── */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-200: #a7f3d0;
  --success-300: #6ee7b7;
  --success-400: #34d399;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;
  --success-800: #065f46;
  --success-900: #064e3b;
  --success: var(--success-500);
  --success-bg: var(--success-50);
  --success-text: var(--success-900);

  /* ── Semantic — Warning ────────────────────────── */
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-200: #fde68a;
  --warning-300: #fcd34d;
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --warning-800: #92400e;
  --warning-900: #78350f;
  --warning: var(--warning-500);
  --warning-bg: var(--warning-50);
  --warning-text: var(--warning-900);

  /* ── Semantic — Error ──────────────────────────── */
  --error-50: #fef2f2;
  --error-100: #fee2e2;
  --error-200: #fecaca;
  --error-300: #fca5a5;
  --error-400: #f87171;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #b91c1c;
  --error-800: #991b1b;
  --error-900: #7f1d1d;
  --error: var(--error-500);
  --error-bg: var(--error-50);
  --error-text: var(--error-900);

  /* ── Semantic — Info ───────────────────────────── */
  --info-50: #f0f9ff;
  --info-100: #e0f2fe;
  --info-200: #bae6fd;
  --info-300: #7dd3fc;
  --info-400: #38bdf8;
  --info-500: #0ea5e9;
  --info-600: #0284c7;
  --info-700: #0369a1;
  --info-800: #075985;
  --info-900: #0c4a6e;
  --info: var(--info-500);
  --info-bg: var(--info-50);
  --info-text: var(--info-900);

  /* ── Typography ────────────────────────────────── */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-primary: var(--font-sans);

  /* 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 */
  --text-6xl: 3.75rem;
  /* 60px */

  /* Font weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Line heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* ── Spacing (4px base) ────────────────────────── */
  --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 */
  --space-20: 5rem;
  /* 80px */
  --space-24: 6rem;
  /* 96px */
  --space-32: 8rem;
  /* 128px */

  /* ── Border Radius ─────────────────────────────── */
  --radius-sm: 0.25rem;
  /*  4px */
  --radius-md: 0.375rem;
  /*  6px */
  --radius-lg: 0.5rem;
  /*  8px */
  --radius-xl: 0.75rem;
  /* 12px */
  --radius-2xl: 1rem;
  /* 16px */
  --radius-3xl: 1.5rem;
  /* 24px */
  --radius-full: 9999px;

  /* ── Shadows ───────────────────────────────────── */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* Focus ring shadows */
  --shadow-focus-primary: 0 0 0 3px rgb(37 99 235 / 0.3);
  --shadow-focus-danger: 0 0 0 3px rgb(239 68 68 / 0.3);

  /* Glow variants */
  --shadow-glow-primary: 0 0 20px rgba(37, 99, 235, 0.25);
  --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.25);

  /* ── App semantic aliases ──────────────────────── */
  --bg-page: var(--neutral-50);
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--neutral-50);
  --bg-surface-hover: var(--neutral-100);
  --bg-card: #ffffff;

  --text-primary: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-tertiary: var(--neutral-400);

  --border-color: var(--neutral-200);
  --border-subtle: var(--neutral-200);
  --border-strong: var(--neutral-300);

  --primary-bg: var(--primary-600);
  --primary-fg: #ffffff;

  /* Header */
  --header-bg: #ffffff;
  --header-border: var(--neutral-200);
  --header-text: var(--neutral-900);
  --header-height: 64px;

  /* ── Animation / Timing ────────────────────────── */
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
  --duration-700: 700ms;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in: cubic-bezier(0.32, 0, 0.67, 0);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── Layout ────────────────────────────────────── */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --z-10: 10;
  --z-20: 20;
  --z-30: 30;
  --z-40: 40;
  --z-50: 50;
  --z-100: 100;

  /* ── Legacy aliases (used by styles-enhanced.css) ─ */
  --color-primary: var(--primary-600);
  --color-secondary: var(--neutral-500);
  --color-text-primary: var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --transition-colors: color 150ms ease, background-color 150ms ease, border-color 150ms ease;

  /* App color aliases */
  --app-primary: var(--primary-600);
  --app-primary-50: var(--primary-50);
  --app-success: var(--success-500);
  --app-success-light: var(--success-50);
  --app-warning: var(--warning-500);
  --app-warning-light: var(--warning-50);
  --app-error: var(--error-500);
  --app-error-light: var(--error-50);
}

/* ── DARK MODE ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --primary-50: #172554;
  --primary-100: #1e3a8a;
  --primary-200: #1e40af;
  --primary-300: #1d4ed8;
  --primary-400: #2563eb;
  --primary-500: #3b82f6;
  --primary-600: #60a5fa;
  --primary-700: #93c5fd;
  --primary-800: #bfdbfe;
  --primary-900: #dbeafe;
  --primary-950: #eff6ff;

  --bg-page: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-alt: #334155;
  --bg-surface-hover: #334155;
  --bg-card: #1e293b;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;

  --border-subtle: #334155;
  --border-strong: #475569;
  --border-color: #334155;

  --header-bg: #1e293b;
  --header-border: #334155;
  --header-text: #f8fafc;

  --success-bg: rgba(6, 78, 59, 0.5);
  --success-text: #6ee7b7;
  --warning-bg: rgba(120, 53, 15, 0.5);
  --warning-text: #fcd34d;
  --error-bg: rgba(127, 29, 29, 0.5);
  --error-text: #fca5a5;
  --info-bg: rgba(12, 74, 110, 0.5);
  --info-text: #7dd3fc;

  --shadow-focus-primary: 0 0 0 3px rgb(96 165 250 / 0.35);
  --shadow-focus-danger: 0 0 0 3px rgb(248 113 113 / 0.35);
}

/* ── GLOBAL RESET ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
[role="button"] {
  cursor: pointer;
}

/* Accessibility: focus visible only on keyboard nav */
:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Text selection */
::selection {
  background: var(--primary-200);
  color: var(--primary-900);
}

[data-theme="dark"] ::selection {
  background: var(--primary-800);
  color: var(--primary-100);
}