/* Alpine Sky Design System */
:root {
  --sky: #38BDF8;
  --sky-deep: #0284C7;
  --sky-50: #F0F9FF;
  --sky-100: #E0F2FE;
  --meadow: #34D399;
  --meadow-deep: #059669;
  --meadow-50: #ECFDF5;
  --slate-900: #0F172A;
  --slate-700: #334155;
  --slate-500: #64748B;
  --slate-200: #E2E8F0;
  --amber-400: #FBBF24;
  --amber-50: #FFFBEB;
  --amber-700: #B45309;
  --rose-500: #F43F5E;
  --violet-50: #F5F3FF;
  --violet-600: #7C3AED;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--sky-50);
  color: var(--slate-900);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* ─── Header ─── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(2, 132, 199, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.header-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.header-search-wrap {
  flex: 1;
  max-width: 520px;
}
.header-search {
  width: 100%;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 9999px;
  color: white;
  padding: 0 1.25rem 0 2.75rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.header-search::placeholder { color: rgba(255,255,255,0.45); }
.header-search:focus {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.18);
}
.header-search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.5);
  pointer-events: none;
}
.header-search-container {
  position: relative;
}
.header-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}
.header-nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  transition: color 0.15s, background 0.15s;
}
.header-nav a:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}

/* ─── Hero ─── */
.hero {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 50%, #38bdf8 100%);
  padding: 4rem 1.5rem 3.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 60%, rgba(52, 211, 153, 0.15) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 1; max-width: 680px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}
.hero h1 span { color: var(--meadow); }
.hero p {
  color: rgba(255,255,255,0.75);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* Hero search */
.hero-search-form {
  display: flex;
  gap: 0;
  max-width: 580px;
  margin: 0 auto 2rem;
  background: white;
  border-radius: 1rem;
  padding: 0.375rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.hero-search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.625rem 1rem;
  font-size: 1rem;
  background: transparent;
  color: var(--slate-900);
  border-radius: 0.75rem 0 0 0.75rem;
}
.hero-search-input::placeholder { color: var(--slate-500); }
.hero-search-btn {
  background: var(--sky-deep);
  color: white;
  border: none;
  padding: 0.625rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.hero-search-btn:hover { background: #0369a1; }

/* Stat pills */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.stat-pill {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stat-pill-value { font-size: 1.25rem; font-weight: 700; }
.stat-pill-label { font-size: 0.8rem; color: rgba(255,255,255,0.7); }

/* ─── Main layout ─── */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.page-body {
  padding: 2rem 0;
}

/* ─── Cards ─── */
.card {
  background: white;
  border-radius: 1rem;
  border: 1px solid var(--slate-200);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  padding: 1.25rem;
  transition: box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
}
.card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

/* Doctor card */
.doctor-card { display: flex; gap: 1rem; align-items: flex-start; }
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky-100), var(--sky));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--sky-deep);
  flex-shrink: 0;
}
.card-info { flex: 1; min-width: 0; }
.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
  align-items: center;
}
.card-detail {
  font-size: 0.825rem;
  color: var(--slate-500);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.card-detail-row {
  margin-top: 0.375rem;
  font-size: 0.825rem;
  color: var(--slate-500);
}

/* Hospital card */
.hospital-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--meadow-50), var(--meadow));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-teaching { background: var(--sky-100); color: var(--sky-deep); }
.badge-community { background: var(--meadow-50); color: var(--meadow-deep); }
.badge-private { background: var(--amber-50); color: var(--amber-700); }
.badge-nmc { background: var(--violet-50); color: var(--violet-600); }
.badge-specialty { background: var(--sky-50); color: var(--sky-deep); border: 1px solid var(--sky-100); }
.badge-qual { background: #F8FAFC; color: var(--slate-700); border: 1px solid var(--slate-200); }

.confidence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.confidence-high { background: var(--meadow); }
.confidence-medium { background: var(--amber-400); }
.confidence-low { background: var(--rose-500); }

/* ─── Search page ─── */
.search-header {
  background: white;
  border-bottom: 1px solid var(--slate-200);
  padding: 1.25rem 1.5rem;
}
.search-intent-label {
  font-size: 0.875rem;
  color: var(--slate-500);
  margin-bottom: 0.25rem;
}
.search-intent-label strong { color: var(--slate-900); }
.result-count { font-size: 0.8rem; color: var(--slate-500); }

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
@media (max-width: 768px) {
  .results-grid { grid-template-columns: 1fr; }
}

.result-section h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.result-list { display: flex; flex-direction: column; gap: 0.75rem; }

.load-more-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.625rem;
  background: var(--sky-50);
  border: 1px solid var(--sky-100);
  border-radius: 0.75rem;
  color: var(--sky-deep);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}
.load-more-btn:hover { background: var(--sky-100); }

/* NMC card */
.nmc-card {
  background: var(--violet-50);
  border-color: #EDE9FE;
}
.nmc-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--violet-600);
  font-variant-numeric: tabular-nums;
}
.nmc-fallback {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--amber-700);
  margin-top: 0.5rem;
}

/* ─── Detail pages ─── */
.detail-hero {
  background: linear-gradient(135deg, var(--sky-deep) 0%, var(--sky) 100%);
  border-radius: 1rem;
  padding: 2rem;
  color: white;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.detail-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.detail-hospital-icon {
  width: 72px;
  height: 72px;
  border-radius: 1rem;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}
.detail-name {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.detail-subtitle { color: rgba(255,255,255,0.75); font-size: 0.95rem; margin-top: 0.25rem; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.detail-badge {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.detail-item {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 0.875rem;
  padding: 1rem 1.125rem;
}
.detail-item-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.detail-item-value {
  font-size: 0.975rem;
  color: var(--slate-900);
  font-weight: 500;
}
.detail-item-value a { color: var(--sky-deep); text-decoration: none; }
.detail-item-value a:hover { text-decoration: underline; }

.section-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--sky-100);
}

/* Map container */
.map-container {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 0.875rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
#map { height: 280px; width: 100%; }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--sky-deep);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.back-link:hover { color: #0369a1; }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--slate-500);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; color: var(--slate-700); margin-bottom: 0.5rem; }

/* ─── Loading spinner (htmx-indicator) ─── */
.search-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.htmx-request .search-spinner,
.htmx-request.search-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--slate-200) 25%, #eee 50%, var(--slate-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 0.5rem;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Footer ─── */
.footer {
  background: var(--slate-900);
  color: rgba(255,255,255,0.5);
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
  font-size: 0.8rem;
  margin-top: 3rem;
}
.footer a { color: var(--sky); text-decoration: none; }

/* ─── Quick links home ─── */
.quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 2rem;
}
@media (max-width: 480px) { .quick-links { grid-template-columns: 1fr; } }
.quick-link-card {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 1rem;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.15s;
}
.quick-link-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.1); transform: translateY(-2px); }
.quick-link-icon {
  width: 52px;
  height: 52px;
  border-radius: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.quick-link-icon.blue { background: var(--sky-100); }
.quick-link-icon.green { background: var(--meadow-50); }
.quick-link-title { font-size: 1rem; font-weight: 700; color: var(--slate-900); }
.quick-link-desc { font-size: 0.825rem; color: var(--slate-500); margin-top: 0.1rem; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .header { padding: 0 1rem; gap: 0.75rem; }
  .header-logo span { display: none; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .results-grid { grid-template-columns: 1fr; }
  .detail-hero { flex-direction: column; text-align: center; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
