/* ==========================================================================
   MASTER DESIGN SYSTEM & TOKENS — DENTAL CRM (PHASE 2B VISUAL REDESIGN)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Poppins:wght@500;600&display=swap');

:root {
  /* --------------------------------------------------------------------------
     4-LEVEL ELEVATION SCALE (Tonal Layering Standard)
     -------------------------------------------------------------------------- */
  --elevation-1: #0a0d14; /* Level 1: Page Background (Darkest canvas tone) */
  --elevation-2: #121722; /* Level 2: Cards, Panels, Sidebar, Containers */
  --elevation-3: #1b2232; /* Level 3: Hover/Active Cards, Form Inputs, Sub-panels */
  --elevation-4: #232d42; /* Level 4: Modals, Popovers, Dropdowns, Floating Tooltips */

  --bg-primary: var(--elevation-1);
  --bg-secondary: var(--elevation-2);
  --bg-tertiary: var(--elevation-3);
  --bg-elevated: var(--elevation-4);
  --bg-dark: var(--elevation-1);
  --bg-card: var(--elevation-2);
  --bg-card-hover: var(--elevation-3);
  --bg-modal: var(--elevation-4);

  /* --------------------------------------------------------------------------
     TEXT CONTRAST TOKENS (WCAG AA & AAA Verified)
     -------------------------------------------------------------------------- */
  --text-primary: #f1f5f9;  /* Primary Text: Off-white (12.6:1 - 17.7:1 contrast) */
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8; /* Secondary Text: Soft slate gray (5.4:1 - 7.6:1 contrast) */
  --text-muted: #8a9cb5;    /* Muted Text: Soft blue-gray (4.92:1 on L4, 5.7:1 - 6.9:1 on L1-L3, WCAG AA compliant) */
  --text-subtle: #8a9cb5;

  /* --------------------------------------------------------------------------
     TUNED & SLIGHTLY DESATURATED ACCENT & STATUS COLORS
     -------------------------------------------------------------------------- */
  --accent-primary: #7c6ee6;       /* Calibrated Royal Purple */
  --accent-primary-hover: #8c80f0;
  --accent-primary-bg: rgba(124, 110, 230, 0.12);
  --accent-primary-border: rgba(124, 110, 230, 0.35);

  --accent-success: #22c55e;       /* Tuned Emerald Green */
  --accent-success-bg: rgba(34, 197, 94, 0.12);
  --accent-success-border: rgba(34, 197, 94, 0.3);

  --accent-warning: #f59e0b;       /* Tuned Amber Gold */
  --accent-warning-bg: rgba(245, 158, 11, 0.12);
  --accent-warning-border: rgba(245, 158, 11, 0.3);

  --accent-danger: #ef4444;        /* Tuned Coral Red */
  --accent-danger-bg: rgba(239, 68, 68, 0.12);
  --accent-danger-border: rgba(239, 68, 68, 0.3);

  --accent-info: #38bdf8;          /* Tuned Sky Cyan */
  --accent-info-bg: rgba(56, 189, 248, 0.12);
  --accent-info-border: rgba(56, 189, 248, 0.3);

  /* Legacy alias mappings */
  --accent-indigo: var(--accent-primary);
  --accent-blue: #3b82f6;
  --accent-cyan: var(--accent-info);
  --accent-emerald: var(--accent-success);
  --accent-amber: var(--accent-warning);
  --accent-rose: var(--accent-danger);

  /* --------------------------------------------------------------------------
     TYPOGRAPHY TOKENS (Phase 1 Standard)
     -------------------------------------------------------------------------- */
  --font-poppins: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-inter: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: var(--font-poppins);
  --font-body: var(--font-poppins);

  /* Strict 7-Role Type Scale */
  --type-page-title-size: 24px;
  --type-page-title-weight: 600;
  --type-page-title-lh: 1.3;
  --type-page-title-font: var(--font-heading);

  --type-section-heading-size: 18px;
  --type-section-heading-weight: 600;
  --type-section-heading-lh: 1.3;
  --type-section-heading-font: var(--font-heading);

  --type-modal-title-size: 15px;
  --type-modal-title-weight: 500;
  --type-modal-title-lh: 1.4;
  --type-modal-title-font: var(--font-heading);

  --type-body-size: 14px;
  --type-body-weight: 400;
  --type-body-lh: 1.6;
  --type-body-font: var(--font-body);

  --type-secondary-size: 13px;
  --type-secondary-weight: 400;
  --type-secondary-lh: 1.5;
  --type-secondary-font: var(--font-body);

  --type-label-size: 11px;
  --type-label-weight: 500;
  --type-label-lh: 1.4;
  --type-label-font: var(--font-body);

  --type-button-size: 14px;
  --type-button-weight: 500;
  --type-button-lh: 1;
  --type-button-font: var(--font-body);

  /* --------------------------------------------------------------------------
     8PX SPACING GRID
     -------------------------------------------------------------------------- */
  --space-4: 4px;
  --space-8: 8px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;

  /* --------------------------------------------------------------------------
     BORDERS & SUBTLE ELEVATION SHADOWS
     -------------------------------------------------------------------------- */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-accent: var(--accent-primary-border);

  /* Border Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 100px;

  /* Restrained Glows (Meaningful Moments Only) */
  --glow-primary-cta: 0 4px 16px rgba(124, 110, 230, 0.35);
  --glow-selected-card: 0 0 16px rgba(124, 110, 230, 0.3);
  --glow-critical-alert: 0 0 16px rgba(239, 68, 68, 0.4);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   APPROVED LIGHT MODE TOKENS (Crisp / Matte Pure White Identity)
   ========================================================================== */
[data-theme="light"] {
  /* 4-Level Elevation Scale for Light Mode */
  --elevation-1: #ffffff;                 /* Level 1: Canvas Background (Pure white) */
  --elevation-2: rgba(15, 23, 42, 0.02);  /* Level 2: Primary Panels & Cards */
  --elevation-3: rgba(15, 23, 42, 0.027); /* Level 3: Nested Panels & Inputs */
  --elevation-4: #ffffff;                 /* Level 4: Modals, Popovers, Dropdowns */

  --bg-primary: var(--elevation-1);
  --bg-secondary: var(--elevation-2);
  --bg-tertiary: var(--elevation-3);
  --bg-elevated: var(--elevation-4);
  --bg-dark: var(--elevation-1);
  --bg-card: var(--elevation-2);
  --bg-card-hover: var(--elevation-3);
  --bg-modal: var(--elevation-4);

  /* Approved Text Tokens (WCAG AAA & AA Compliant Slate Palette) */
  --text-primary: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-subtle: #64748b;

  --text-accent-primary: #4f46e5;
  --text-accent-success: #15803d;
  --text-accent-warning: #b45309;
  --text-accent-danger: #b91c1c;
  --text-accent-info: #0369a1;

  /* Approved Borders & Shadows */
  --border-subtle: rgba(15, 23, 42, 0.15);
  --border-medium: rgba(15, 23, 42, 0.18);
  --border-accent: rgba(124, 110, 230, 0.45);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.20);
}

/* Base Styles */
body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: var(--type-body-size);
  font-weight: var(--type-body-weight);
  line-height: var(--type-body-lh);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

/* Font Helper Utility Classes */
.font-heading, .font-poppins { font-family: var(--font-heading) !important; }
.font-body, .font-inter { font-family: var(--font-body) !important; }
.font-figtree { font-family: var(--font-figtree) !important; }
.font-inter { font-family: var(--font-inter) !important; }

/* Radial Glow Background Effect */
.bg-glow-radial {
  position: relative;
  background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.22) 0%, rgba(8, 10, 18, 0) 70%),
              linear-gradient(180deg, #0f1326 0%, #080a12 100%);
}

/* Gradient Text Masks */
.gradient-text-primary {
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-cyan {
  background: linear-gradient(135deg, #ffffff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-emerald {
  background: linear-gradient(135deg, #ffffff 0%, #34d399 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Glassmorphic Card Container */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: var(--transition-smooth);
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-3px);
}

.glass-card-glow {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(59, 130, 246, 0.06));
  border: 1px solid var(--border-glow);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  padding: 24px;
}

/* Button Suite */
.btn-ds {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-ds:active {
  transform: scale(0.97);
}

.btn-ds-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
  color: #ffffff;
  box-shadow: 0 4px 20px var(--indigo-glow);
}

.btn-ds-primary:hover {
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.btn-ds-glass {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-ds-glass:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glow);
  color: #ffffff;
}

.btn-ds-emerald {
  background: linear-gradient(135deg, #10b981, #25d366);
  color: #ffffff;
  box-shadow: 0 4px 20px var(--emerald-glow);
}

.btn-ds-emerald:hover {
  box-shadow: 0 10px 30px rgba(37, 211, 102, 0.5);
  transform: translateY(-2px);
}

.btn-ds-rose {
  background: linear-gradient(135deg, #ef4444, #f43f5e);
  color: #ffffff;
  box-shadow: 0 4px 20px var(--rose-glow);
}

.btn-ds-rose:hover {
  box-shadow: 0 10px 30px rgba(244, 63, 94, 0.5);
  transform: translateY(-2px);
}

/* Badge Tags & Pill Indicators */
.badge-ds {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-ds-urgency {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid var(--border-rose);
  color: #fca5a5;
}

.badge-ds-good {
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid var(--border-emerald);
  color: #6ee7b7;
}

.badge-ds-indigo {
  background: var(--glass-card-bg); backdrop-filter: var(--glass-shell-blur);
  border: 1px solid var(--border-glow);
  color: #a5b4fc;
}

.badge-ds-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* Input Form Controls */
.input-ds {
  width: 100%;
  background: rgba(15, 19, 34, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.input-ds:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--indigo-glow);
}
