/* ════════════════════════════════════════
   DOCWAVE — Design System & Stylesheet
   ════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  --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;
  --space-20: 5rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-default: 1160px;

  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;

  /* Layer brand colors */
  --color-ia: #0891b2;
  --color-ia-bg: #ecfeff;
  --color-online: #059669;
  --color-online-bg: #ecfdf5;
  --color-dom: #7c3aed;
  --color-dom-bg: #f5f3ff;
}

:root, [data-theme="light"] {
  --color-bg: #f4f7f9;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-surface-offset: #eef2f7;
  --color-border: #d1dce8;
  --color-divider: #e2eaf2;
  --color-text: #0f2235;
  --color-text-muted: #5a7086;
  --color-text-faint: #9ab0c4;
  --color-primary: #0369a1;
  --color-primary-hover: #0c4a6e;
  --color-primary-highlight: #bae6fd;
  --color-success: #059669;
  --color-error: #dc2626;
  --shadow-sm: 0 1px 3px rgba(15,34,53,0.07);
  --shadow-md: 0 4px 16px rgba(15,34,53,0.09);
  --shadow-lg: 0 12px 40px rgba(15,34,53,0.12);
}

[data-theme="dark"] {
  --color-bg: #0a1220;
  --color-surface: #111927;
  --color-surface-2: #162030;
  --color-surface-offset: #1a2638;
  --color-border: #263545;
  --color-divider: #1e2e40;
  --color-text: #c8dae9;
  --color-text-muted: #7090a8;
  --color-text-faint: #3d5568;
  --color-primary: #38bdf8;
  --color-primary-hover: #7dd3fc;
  --color-primary-highlight: #1e3a4a;
  --color-success: #34d399;
  --color-error: #f87171;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --color-ia: #22d3ee;
  --color-ia-bg: #0a2030;
  --color-online: #34d399;
  --color-online-bg: #061e18;
  --color-dom: #a78bfa;
  --color-dom-bg: #1a0f2e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0a1220;
    --color-surface: #111927;
    --color-surface-2: #162030;
    --color-surface-offset: #1a2638;
    --color-border: #263545;
    --color-divider: #1e2e40;
    --color-text: #c8dae9;
    --color-text-muted: #7090a8;
    --color-text-faint: #3d5568;
    --color-primary: #38bdf8;
    --color-primary-hover: #7dd3fc;
    --color-primary-highlight: #1e3a4a;
    --color-success: #34d399;
    --color-error: #f87171;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    --color-ia: #22d3ee;
    --color-ia-bg: #0a2030;
    --color-online: #34d399;
    --color-online-bg: #061e18;
    --color-dom: #a78bfa;
    --color-dom-bg: #1a0f2e;
  }
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: var(--space-16); -webkit-text-size-adjust: none; text-size-adjust: none; }
body { font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text); background: var(--color-bg); line-height: 1.6; min-height: 100dvh; }
img, svg { display: block; max-width: 100%; }
h1,h2,h3,h4 { font-family: var(--font-display); text-wrap: balance; line-height: 1.15; }
p, li { text-wrap: pretty; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul[role="list"] { list-style: none; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--color-primary-highlight); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.navbar-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex; align-items: center; gap: var(--space-4);
}
.logo {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--color-text); text-decoration: none;
  flex-shrink: 0;
}
.logo svg { color: var(--color-primary); }
.logo-brand { display: block; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.02em; color: var(--color-primary); }
.logo-sub { display: block; font-size: var(--text-xs); color: var(--color-text-muted); }
.nav-links { display: flex; align-items: center; gap: var(--space-5); margin-left: auto; }
.nav-links a { font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); transition: color var(--transition); padding: var(--space-2) 0; border-bottom: 2px solid transparent; }
.nav-links a:hover { color: var(--color-text); text-decoration: none; }
.btn-emergency {
  background: #dc2626; color: #fff;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.01em;
  transition: background var(--transition);
  animation: pulse-red 2s ease-in-out infinite;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-block;
  line-height: 1.5;
  overflow: visible;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
.btn-emergency:hover { background: #b91c1c; text-decoration: none; }
.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--color-surface-offset); color: var(--color-text); }
.hamburger { display: none; flex-direction: column; gap: 5px; padding: var(--space-2); }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--color-text); border-radius: 2px; }

/* ── Hero ── */
.hero-section {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 40%, #0891b2 70%, #06b6d4 100%);
  padding: var(--space-16) var(--space-6) var(--space-8);
  min-height: 520px;
}
.hero-bg-gradient {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 70% 50%, rgba(6,182,212,0.3) 0%, transparent 70%);
  pointer-events: none;
}
.hero-content {
  max-width: var(--content-default);
  margin: 0 auto var(--space-10);
  position: relative; z-index: 1;
  text-align: center;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #e0f7fa;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 500;
  margin-bottom: var(--space-6);
  backdrop-filter: blur(8px);
}
.badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: blink 1.5s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }
.hero-title {
  font-size: var(--text-2xl); font-weight: 800;
  color: #fff; margin-bottom: var(--space-4);
}
.text-accent { color: #7dd3fc; }
.hero-sub { font-size: var(--text-lg); color: rgba(255,255,255,0.8); max-width: 540px; margin: 0 auto; }

/* ── Intake Card ── */
.intake-card {
  position: relative; z-index: 1;
  max-width: var(--content-default);
  margin: 0 auto;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
}
.intake-header {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.intake-header svg { color: var(--color-primary); }
.intake-header h2 { font-size: var(--text-lg); font-weight: 700; }
.intake-form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-row-4 { display: grid; grid-template-columns: 2fr 1fr 1fr 1.5fr; gap: var(--space-4); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); }
input[type="text"], input[type="number"], input[type="tel"], input[type="date"], input[type="search"], input[type="email"], textarea, select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a7086' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.upload-zone svg { color: var(--color-text-faint); }
.upload-zone p { font-size: var(--text-sm); color: var(--color-text-muted); }
.upload-hint { font-size: var(--text-xs); color: var(--color-text-faint); }
.link-btn { color: var(--color-primary); cursor: pointer; background: none; border: none; font-size: inherit; text-decoration: underline; padding: 0; }
.file-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.file-chip {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs); color: var(--color-text-muted);
}
.file-chip button { color: var(--color-text-faint); font-size: 14px; line-height: 1; padding: 0; }
.file-chip button:hover { color: var(--color-error); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--color-primary); color: #fff;
  padding: var(--space-3) var(--space-8);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
  border: none;
}
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: none; }
.btn-submit { margin: 0 auto; }
.btn-outline {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: transparent; color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }

/* ── Layers Section ── */
.layers-section {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-16) var(--space-6);
}
.layers-header { text-align: center; margin-bottom: var(--space-10); }
.layers-header h2 { font-size: var(--text-xl); font-weight: 800; margin-bottom: var(--space-2); }
.layers-header p { color: var(--color-text-muted); font-size: var(--text-base); }

.layers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  align-items: start;
}

/* Layer Card */
.layer-card {
  position: relative;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-slow), box-shadow var(--transition-slow), opacity var(--transition-slow);
  overflow: hidden;

  /* Cards start invisible */
  opacity: 0;
  transform: translateY(30px);
}
.layer-card.shown {
  opacity: 0.38;
  transform: translateY(0);
}
.layer-card.visible {
  opacity: 1;
  transform: translateY(0);
}
.layer-card.locked { pointer-events: none; }

/* Staggered reveal delays */
.layer-card:nth-child(1) { transition-delay: 0.1s; }
.layer-card:nth-child(2) { transition-delay: 0.3s; }
.layer-card:nth-child(3) { transition-delay: 0.5s; }

.layer-card:not(.locked):hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }

/* Lock overlay */
.layer-lock {
  position: absolute; inset: 0;
  background: rgba(var(--color-bg-rgb, 244,247,249), 0.85);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-2xl);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-3);
  z-index: 5;
  text-align: center; padding: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  transition: opacity var(--transition-slow);
}
[data-theme="dark"] .layer-lock { background: rgba(10,18,32,0.88); }
.layer-lock svg { color: var(--color-text-faint); opacity: 0.7; }
.layer-lock.hidden { opacity: 0; pointer-events: none; }

/* Layer content */
.layer-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700;
  margin-bottom: var(--space-4); letter-spacing: 0.02em;
}
.badge-free { background: #d1fae5; color: #065f46; }
.badge-paid { background: #dbeafe; color: #1e40af; }
.badge-premium { background: #ede9fe; color: #5b21b6; }
[data-theme="dark"] .badge-free { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-paid { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-premium { background: #2e1065; color: #c4b5fd; }

.layer-icon { margin-bottom: var(--space-5); }
.layer-num { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-text-faint); margin-bottom: var(--space-2); }
.layer-title { font-size: var(--text-lg); font-weight: 800; margin-bottom: var(--space-3); }
.layer-desc { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-5); line-height: 1.65; }
.layer-features { list-style: none; margin-bottom: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); }
.layer-features li { font-size: var(--text-sm); color: var(--color-text-muted); padding-left: var(--space-1); }

/* Layer buttons */
.btn-layer {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm); font-weight: 600;
  transition: all var(--transition);
  border: 1.5px solid transparent;
}
.btn-ia { background: var(--color-ia); color: #fff; }
.btn-ia:hover { background: #0e7490; transform: translateY(-1px); }
.btn-online { background: var(--color-online); color: #fff; }
.btn-online:hover { background: #047857; transform: translateY(-1px); }
.btn-domicilio { background: var(--color-dom); color: #fff; }
.btn-domicilio:hover { background: #6d28d9; transform: translateY(-1px); }

/* Layer 1 border accent */
.layer-ia { border-top: 4px solid var(--color-ia); }
.layer-online { border-top: 4px solid var(--color-online); }
.layer-domicilio { border-top: 4px solid var(--color-dom); }

/* Doctor List */
.doctor-filter { margin-bottom: var(--space-4); }
.select-sm { width: 100%; padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.doctor-list { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.doctor-card {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.doctor-card:hover { border-color: var(--color-online); box-shadow: var(--shadow-sm); }
.doctor-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--color-online-bg), var(--color-online));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  font-size: 20px; line-height: 1;
}
.doctor-info { flex: 1; min-width: 0; }
.doctor-name { font-size: var(--text-sm); font-weight: 700; }
.doctor-spec { font-size: var(--text-xs); color: var(--color-text-muted); }
.doctor-exp { font-size: var(--text-xs); color: var(--color-text-faint); }
.doctor-rating { font-size: var(--text-xs); color: #f59e0b; font-weight: 700; white-space: nowrap; }
.btn-reserve {
  background: var(--color-online); color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs); font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition);
}
.btn-reserve:hover { background: #047857; }

/* Domicilio Form */
.domicilio-form { display: flex; flex-direction: column; gap: var(--space-3); }

/* ── DB Section ── */
.db-section {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-16) var(--space-6);
}
.db-inner { max-width: var(--content-default); margin: 0 auto; }
.db-header {
  display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.db-header h2 { font-size: var(--text-xl); font-weight: 800; margin-bottom: var(--space-1); }
.db-header p { color: var(--color-text-muted); font-size: var(--text-sm); }
.db-search {
  position: relative; margin-bottom: var(--space-5);
  max-width: 360px;
}
.db-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-faint); pointer-events: none; }
.db-search input { padding-left: 40px; }
.db-table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-xl); }
.db-table { width: 100%; border-collapse: collapse; }
.db-table thead tr { background: var(--color-surface-offset); }
.db-table th { padding: var(--space-3) var(--space-4); text-align: left; font-size: var(--text-xs); font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.07em; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.db-table td { padding: var(--space-3) var(--space-4); font-size: var(--text-sm); border-bottom: 1px solid var(--color-divider); vertical-align: middle; }
.db-table tbody tr:last-child td { border-bottom: none; }
.db-table tbody tr:hover { background: var(--color-surface-2); }
.patient-name { font-weight: 600; }
.patient-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  background: var(--color-primary-highlight); color: var(--color-primary);
  margin-right: var(--space-2); flex-shrink: 0;
  vertical-align: middle;
}
.level-badge {
  display: inline-flex; align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600;
}
.level-1 { background: #cffafe; color: #0e7490; }
.level-2 { background: #d1fae5; color: #065f46; }
.level-3 { background: #ede9fe; color: #5b21b6; }
[data-theme="dark"] .level-1 { background: #0a2030; color: #22d3ee; }
[data-theme="dark"] .level-2 { background: #061e18; color: #34d399; }
[data-theme="dark"] .level-3 { background: #1a0f2e; color: #a78bfa; }
.status-active { color: var(--color-success); font-weight: 600; font-size: var(--text-xs); }
.status-pending { color: #f59e0b; font-weight: 600; font-size: var(--text-xs); }
.btn-view { background: var(--color-primary); color: #fff; padding: var(--space-1) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-xs); font-weight: 600; transition: background var(--transition); }
.btn-view:hover { background: var(--color-primary-hover); }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-height: 90vh;
  overflow: hidden;
  transform: translateY(24px) scale(0.97);
  transition: transform var(--transition);
  display: flex; flex-direction: column;
}
.modal-overlay.open .modal-card { transform: translateY(0) scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-title-row { display: flex; align-items: center; gap: var(--space-3); }
.modal-header h3 { font-size: var(--text-lg); font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  font-size: 16px; line-height: 1;
  color: var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* AI Chat */
.chat-modal { max-width: 560px; }
.ai-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #0891b2, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.status-dot { font-size: var(--text-xs); color: var(--color-success); font-weight: 600; }
.status-dot::before { content: "●"; margin-right: 4px; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: var(--space-5) var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-4);
  scroll-behavior: smooth;
}
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.msg-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm); line-height: 1.55;
}
.bot .msg-bubble { background: var(--color-surface-offset); color: var(--color-text); border-bottom-left-radius: var(--radius-sm); }
.user .msg-bubble { background: var(--color-primary); color: #fff; border-bottom-right-radius: var(--radius-sm); }
.msg-time { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-1); padding: 0 var(--space-2); }
.msg-image { max-width: 200px; border-radius: var(--radius-lg); margin-top: var(--space-2); overflow: hidden; }
.msg-image img { width: 100%; height: auto; }
.chat-input-row {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
#chatInput { flex: 1; border-radius: var(--radius-full); padding: var(--space-3) var(--space-5); }
.image-scan-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted); border: 1.5px solid var(--color-border);
  cursor: pointer; flex-shrink: 0;
  transition: all var(--transition);
}
.image-scan-btn:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-highlight); }
.btn-send {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background var(--transition), transform var(--transition);
}
.btn-send:hover { background: var(--color-primary-hover); transform: scale(1.05); }
.typing-dots { display: flex; gap: 4px; padding: var(--space-3) var(--space-4); }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-text-faint); animation: typing 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-8px)} }

/* Video Modal */
.video-modal { max-width: 700px; }
.video-container {
  position: relative; flex: 1;
  background: #0a1220;
  min-height: 380px;
  overflow: hidden;
}
.video-remote {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 380px;
}
.video-placeholder {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  color: #4a6074;
}
.video-placeholder p { font-size: var(--text-sm); }
.video-local {
  position: absolute; bottom: var(--space-4); right: var(--space-4);
  width: 120px; height: 90px;
  background: #1a2638; border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.video-placeholder-sm svg { color: #4a6074; }
.video-name-tag {
  position: absolute; bottom: var(--space-2); left: var(--space-3);
  background: rgba(0,0,0,0.6);
  color: #fff; font-size: var(--text-xs); font-weight: 600;
  padding: 2px var(--space-2); border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
}
.video-controls {
  display: flex; align-items: center; justify-content: center; gap: var(--space-4);
  padding: var(--space-5);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.ctrl-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--color-surface-offset);
  color: var(--color-text);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  border: 1.5px solid var(--color-border);
}
.ctrl-btn:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.ctrl-btn.active { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.ctrl-end { background: #dc2626; color: #fff; border-color: #dc2626; }
.ctrl-end:hover { background: #b91c1c; border-color: #b91c1c; }

/* Patient Modal */
.patient-modal { max-width: 600px; }
.patient-detail { padding: var(--space-6); overflow-y: auto; flex: 1; }
.patient-detail h4 { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-3); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: var(--text-xs); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-6); }
.detail-field label { font-size: var(--text-xs); color: var(--color-text-faint); display: block; margin-bottom: var(--space-1); }
.detail-field p { font-size: var(--text-sm); font-weight: 500; }
.scan-grid { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.scan-thumb {
  width: 80px; height: 80px; border-radius: var(--radius-lg);
  background: var(--color-surface-offset); border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scan-thumb svg { color: var(--color-text-faint); }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  z-index: 300; display: flex; flex-direction: column; gap: var(--space-2);
}
.toast {
  background: var(--color-text); color: var(--color-bg);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-xl); font-size: var(--text-sm); font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  max-width: 320px;
}
.toast.success { background: var(--color-success); color: #fff; }
.toast.error { background: var(--color-error); color: #fff; }
@keyframes toast-in { from { opacity:0; transform: translateY(12px) scale(0.95); } to { opacity:1; transform:none; } }

/* ── Footer ── */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-6);
}
.footer-inner {
  max-width: var(--content-default); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4);
}
.footer-logo { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 800; font-size: var(--text-base); color: var(--color-primary); }
.footer-copy, .footer-contact { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── Responsive ── */
@media (max-width: 960px) {
  .layers-grid { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .nav-links.open { display: flex; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: var(--space-4) var(--space-6); z-index: 99; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .form-row-4 { grid-template-columns: 1fr; }
  .intake-card { padding: var(--space-5); }
  .hero-section { padding: var(--space-10) var(--space-4) var(--space-6); }
  .layers-section { padding: var(--space-10) var(--space-4); }
  .layer-card { padding: var(--space-5); }
  .db-section { padding: var(--space-10) var(--space-4); }
  .footer-inner { flex-direction: column; text-align: center; }
}
