/* ============================================================================
   BVNH HOSPITAL DESIGN SYSTEM — CORE TOKENS & ACCESSIBLE PRIMITIVES
   Synthesized from NHS.UK, GOV.UK, CMS.gov & modern healthcare UI standards.
   Zero glassmorphism bloat, WCAG 2.1 AA/AAA contrast, 4px/8px spatial grid.
   ============================================================================ */

:root {
  /* 1. Brand & Institutional Palette */
  --bvnh-blue: #005eb8;
  --bvnh-blue-hover: #004a93;
  --bvnh-blue-active: #003870;
  --bvnh-blue-50: #eff6ff;
  --bvnh-blue-100: #dbeafe;

  --bvnh-navy: #0b2d52;
  --bvnh-navy-dark: #071f3a;
  --bvnh-navy-soft: #163f6b;

  --bvnh-teal: #0f766e;
  --bvnh-teal-hover: #115e59;
  --bvnh-teal-50: #f0fdfa;
  --bvnh-teal-100: #ccfbf1;

  /* 2. Neutral Surfaces & Borders */
  --bvnh-canvas: #f4f7fa;
  --bvnh-surface: #ffffff;
  --bvnh-surface-subtle: #f8fafc;
  --bvnh-border: #d9e2ec;
  --bvnh-border-strong: #bcccdc;

  /* 3. High-Contrast Typography Ink (WCAG AAA on white) */
  --bvnh-ink: #0f172a;
  --bvnh-ink-secondary: #334155;
  --bvnh-ink-muted: #52606d;

  /* 4. Semantic & Clinical States */
  --bvnh-success: #15803d;
  --bvnh-success-bg: #dcfce7;
  --bvnh-warning: #b45309;
  --bvnh-warning-bg: #fef3c7;
  --bvnh-danger: #b91c1c;
  --bvnh-danger-bg: #fee2e2;
  --bvnh-info: #0369a1;
  --bvnh-info-bg: #e0f2fe;
  --bvnh-focus: #ffdd00;

  /* 5. Backwards-compatible aliases for existing Razor pages */
  --brand-primary: var(--bvnh-blue);
  --brand-secondary: var(--bvnh-teal);
  --brand-dark: var(--bvnh-navy);
  --brand-accent: var(--bvnh-danger);
  --bg-page: var(--bvnh-canvas);
  --bg-card: var(--bvnh-surface);
  --text-main: var(--bvnh-ink);
  --text-muted: var(--bvnh-ink-muted);
  --border-color: var(--bvnh-border);

  /* 6. Typography Scale */
  --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 0.9375rem;/* 15px */
  --text-md: 1rem;       /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.3125rem;  /* 21px */
  --text-2xl: 1.625rem;  /* 26px */

  /* 7. Spacing Scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* 8. Radii & Crisp Clinical Elevation */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
  --shadow-xs: 0 1px 2px rgba(11, 45, 82, 0.05);
  --shadow-sm: 0 2px 6px rgba(11, 45, 82, 0.06), 0 1px 2px rgba(11, 45, 82, 0.04);
  --shadow-md: 0 8px 20px rgba(11, 45, 82, 0.08), 0 2px 6px rgba(11, 45, 82, 0.04);
  --shadow-lg: 0 14px 32px rgba(11, 45, 82, 0.12);

  /* 9. Motion */
  --ease-ui: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;
}

/* ===== ADMIN-SELECTABLE PORTAL THEME PRESETS ===== */
[data-theme="emerald-care"] {
  --bvnh-blue: #0f766e;
  --bvnh-blue-hover: #115e59;
  --bvnh-blue-50: #f0fdfa;
  --bvnh-blue-100: #ccfbf1;
  --bvnh-navy: #064e3b;
  --bvnh-navy-dark: #022c22;
  --bvnh-teal: #0284c7;
  --bvnh-teal-50: #f0f9ff;
}
[data-theme="royal-navy"] {
  --bvnh-blue: #1e40af;
  --bvnh-blue-hover: #1e3a8a;
  --bvnh-blue-50: #eff6ff;
  --bvnh-blue-100: #dbeafe;
  --bvnh-navy: #0f172a;
  --bvnh-navy-dark: #020617;
  --bvnh-teal: #0369a1;
  --bvnh-teal-50: #f0f9ff;
}
[data-theme="warm-classic"] {
  --bvnh-blue: #0e4c5c;
  --bvnh-blue-hover: #0a3844;
  --bvnh-blue-50: #ecfeff;
  --bvnh-blue-100: #cffafe;
  --bvnh-navy: #164e63;
  --bvnh-navy-dark: #083344;
  --bvnh-teal: #b45309;
  --bvnh-teal-50: #fffbeb;
}
[data-theme="teal-hospital"] {
  --bvnh-blue: #0284c7;
  --bvnh-blue-hover: #0369a1;
  --bvnh-blue-50: #f0f9ff;
  --bvnh-blue-100: #e0f2fe;
  --bvnh-navy: #0c4a6e;
  --bvnh-navy-dark: #082f49;
  --bvnh-teal: #0d9488;
  --bvnh-teal-50: #f0fdfa;
}
[data-theme="khanhhoa-gold"] {
  --bvnh-blue: #0f4c81;
  --bvnh-blue-hover: #0b3a63;
  --bvnh-blue-50: #f0f6fc;
  --bvnh-blue-100: #dbeafe;
  --bvnh-navy: #0a2e50;
  --bvnh-navy-dark: #061c33;
  --bvnh-teal: #b45309;
  --bvnh-teal-50: #fef3c7;
}

/* ===== ADMIN-SELECTABLE CARD RADIUS PRESETS ===== */
[data-radius="classic"] { --radius-md: 6px; --radius-lg: 8px; }
[data-radius="classic"] .card-box,
[data-radius="classic"] .action-card,
[data-radius="classic"] .bvnh-hero-card,
[data-radius="classic"] .bvnh-trans-card,
[data-radius="classic"] .bvnh-news-card,
[data-radius="classic"] .bvnh-featured-card { border-radius: 6px !important; }

[data-radius="soft"] { --radius-md: 16px; --radius-lg: 20px; }
[data-radius="soft"] .card-box,
[data-radius="soft"] .action-card,
[data-radius="soft"] .bvnh-hero-card,
[data-radius="soft"] .bvnh-trans-card,
[data-radius="soft"] .bvnh-news-card,
[data-radius="soft"] .bvnh-featured-card { border-radius: 18px !important; }

/* Accessible Keyboard Focus (NHS / GOV.UK Gold Standard) */
:focus-visible {
  outline: 3px solid var(--bvnh-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--bvnh-navy);
}

/* Reduced Motion Respect */
@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;
  }
}

/* Reusable Component Primitives: Badges, Skeleton, Empty State, Toast, Accordion */
.bvnh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.bvnh-badge-blue { background: var(--bvnh-blue-50); color: var(--bvnh-blue); border: 1px solid var(--bvnh-blue-100); }
.bvnh-badge-teal { background: var(--bvnh-teal-50); color: var(--bvnh-teal); border: 1px solid var(--bvnh-teal-100); }
.bvnh-badge-success { background: var(--bvnh-success-bg); color: var(--bvnh-success); }
.bvnh-badge-warning { background: var(--bvnh-warning-bg); color: var(--bvnh-warning); }
.bvnh-badge-danger { background: var(--bvnh-danger-bg); color: var(--bvnh-danger); }

.bvnh-new-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  width: fit-content;
  flex-shrink: 0;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 4px;
  background: #dc2626;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.45;
  vertical-align: middle;
  animation: bvnhNewPulse 2.4s ease-in-out infinite;
}
@keyframes bvnhNewPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.bvnh-empty-state {
  text-align: center;
  padding: 36px 20px;
  background: var(--bvnh-surface-subtle);
  border: 1px dashed var(--bvnh-border-strong);
  border-radius: var(--radius-md);
  color: var(--bvnh-ink-muted);
}
.bvnh-empty-state h4 {
  margin: 8px 0 4px;
  color: var(--bvnh-navy);
  font-size: 16px;
}

.bvnh-skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: bvnhShimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes bvnhShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.bvnh-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.bvnh-toast {
  background: var(--bvnh-navy);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-left: 4px solid var(--bvnh-teal);
}
.bvnh-toast.toast-error { border-left-color: #f87171; }
.bvnh-toast.toast-success { border-left-color: #4ade80; }

.bvnh-back-top {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--bvnh-navy);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: transform var(--dur-fast) var(--ease-ui), background var(--dur-fast) var(--ease-ui);
}
.bvnh-back-top.visible { display: inline-flex; }
.bvnh-back-top:hover { background: var(--bvnh-blue); transform: translateY(-2px); }

/* Mobile Input Zoom Prevention & 44px Touch Targets */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
  .btn, button, .nav-link {
    min-height: 44px;
  }
}

/* ============================================================================
   ADMIN-SELECTABLE PORTAL THEME PRESETS & CARD RADIUS MODES
   ============================================================================ */
[data-theme="emerald-care"] {
  --bvnh-blue: #0f766e;
  --bvnh-blue-hover: #115e59;
  --bvnh-blue-50: #f0fdfa;
  --bvnh-blue-100: #ccfbf1;
  --bvnh-navy: #064e3b;
  --bvnh-navy-dark: #022c22;
  --bvnh-teal: #0284c7;
  --brand-primary: #0f766e;
  --brand-dark: #064e3b;
}

[data-theme="royal-navy"] {
  --bvnh-blue: #1d4ed8;
  --bvnh-blue-hover: #1e40af;
  --bvnh-blue-50: #eff6ff;
  --bvnh-blue-100: #dbeafe;
  --bvnh-navy: #172554;
  --bvnh-navy-dark: #0f172a;
  --bvnh-teal: #0369a1;
  --brand-primary: #1d4ed8;
  --brand-dark: #172554;
}

[data-theme="warm-classic"] {
  --bvnh-blue: #0e4c5c;
  --bvnh-blue-hover: #093642;
  --bvnh-blue-50: #ecfeff;
  --bvnh-blue-100: #cffafe;
  --bvnh-navy: #164e63;
  --bvnh-navy-dark: #083344;
  --bvnh-teal: #b45309;
  --bvnh-teal-50: #fffbeb;
  --bvnh-teal-100: #fef3c7;
  --brand-primary: #0e4c5c;
  --brand-dark: #164e63;
}

[data-radius="classic"] {
  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 6px;
}
[data-radius="classic"] .card-box,
[data-radius="classic"] .bvnh-hero-card,
[data-radius="classic"] .action-card,
[data-radius="classic"] .bvnh-trans-card,
[data-radius="classic"] .bvnh-featured-card,
[data-radius="classic"] .bvnh-news-card {
  border-radius: 5px !important;
}

[data-radius="soft"] {
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
}
[data-radius="soft"] .card-box,
[data-radius="soft"] .bvnh-hero-card,
[data-radius="soft"] .action-card,
[data-radius="soft"] .bvnh-trans-card,
[data-radius="soft"] .bvnh-featured-card,
[data-radius="soft"] .bvnh-news-card {
  border-radius: 18px !important;
}

/* Hero Style Variants */
.bvnh-hero-row.hero-wide {
  grid-template-columns: 1fr !important;
}
.bvnh-hero-row.hero-wide .bvnh-hero-img {
  max-height: 390px;
}
.bvnh-hero-row.hero-wide .bvnh-hero-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.bvnh-hero-row.hero-minimal {
  grid-template-columns: 1fr !important;
}
.bvnh-hero-row.hero-minimal .bvnh-hero-card {
  display: none !important;
}
.bvnh-hero-row.hero-minimal .bvnh-hero-actions {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .bvnh-hero-row.hero-wide .bvnh-hero-actions,
  .bvnh-hero-row.hero-minimal .bvnh-hero-actions {
    grid-template-columns: 1fr !important;
  }
}
