:root {
  --bg: #f4f7f9;
  --bg-tint-1: rgba(13, 148, 136, 0.07);
  --bg-tint-2: rgba(239, 108, 77, 0.06);
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --text: #1f2a37;
  --muted: #64748b;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.1);
  --accent: #ef6c4d;
  --accent-soft: rgba(239, 108, 77, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --line: #e6ebf1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(620px circle at 8% -5%, var(--bg-tint-1), transparent 60%),
    radial-gradient(560px circle at 100% 0%, var(--bg-tint-2), transparent 55%),
    var(--bg);
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 28px auto 40px;
  display: grid;
  gap: 16px;
}

/* ---------- Cards / surfaces ---------- */
.hero-card,
.panel,
.notice-card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.hero-card {
  padding: 32px;
  display: grid;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.06), transparent 55%),
    var(--surface);
}

.hero-card.compact {
  min-height: auto;
}

.eyebrow {
  margin: 0 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.9rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-secondary,
.hero-copy,
.panel-footnote,
.notice-card p {
  margin: 0;
  color: var(--muted);
}

.hero-secondary {
  margin-top: 8px;
  font-size: 1.02rem;
  color: var(--text);
  font-weight: 500;
}

.hero-copy {
  margin-top: 10px;
  max-width: 660px;
  font-size: 0.98rem;
}

/* ---------- Buttons & pills ---------- */
.language-switcher {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 5px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  width: fit-content;
}

.lang-button,
.secondary-button,
.ghost-button,
.primary-button,
.prompt-chip {
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}

.lang-button {
  padding: 8px 16px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
}

.lang-button:hover {
  color: var(--text);
}

.lang-button.is-active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.secondary-button,
.ghost-button {
  padding: 11px 16px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover {
  border-color: rgba(13, 148, 136, 0.4);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.primary-button {
  padding: 12px 22px;
  background: var(--primary);
  color: white;
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.28);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.ghost-button:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* ---------- Notice ---------- */
.notice-card {
  padding: 16px 20px;
  display: grid;
  gap: 6px;
  background: var(--surface);
  border-left: 4px solid var(--primary);
}

.notice-card p {
  font-size: 0.9rem;
}

.notice-emergency {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Layout ---------- */
.content-grid {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 22px;
}

.prompt-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  padding: 11px 14px;
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--line);
  text-align: left;
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.35;
}

.prompt-chip:hover {
  border-color: rgba(13, 148, 136, 0.4);
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.location-controls {
  display: grid;
  gap: 10px;
}

.location-controls input,
.chat-form textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  padding: 13px 15px;
  font: inherit;
  color: var(--text);
  background: var(--surface-muted);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.location-controls input:focus,
.chat-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- Chat ---------- */
.chat-panel {
  display: grid;
  gap: 16px;
}

.chat-messages {
  min-height: 340px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(100%, 760px);
  padding: 13px 16px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 0.96rem;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.response-list-item {
  padding-left: 2px;
}

.response-bullets {
  margin: -4px 0 12px;
  padding-left: 22px;
}

.response-bullets li {
  margin: 4px 0;
}

.message.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.message.user .bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 6px;
}

.debug-badge {
  width: fit-content;
  margin: 0 0 0 2px;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.debug-badge.is-llm {
  background: var(--primary-soft);
  border: 1px solid rgba(13, 148, 136, 0.22);
  color: var(--primary-dark);
}

.debug-badge.is-template {
  background: var(--accent-soft);
  border: 1px solid rgba(239, 108, 77, 0.22);
  color: var(--accent);
}

.response-block {
  display: grid;
  gap: 14px;
}

/* ---------- Summary & filters ---------- */
.summary-card,
.filter-row {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
}

.summary-title {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.summary-chips,
.filter-group,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chip,
.filter-button,
.action-link {
  border-radius: var(--radius-pill);
  padding: 7px 13px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.summary-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.filter-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.filter-button:hover {
  border-color: rgba(13, 148, 136, 0.4);
}

.filter-button.is-active {
  background: var(--primary-soft);
  border-color: rgba(13, 148, 136, 0.4);
  color: var(--primary-dark);
}

.filter-button.clear {
  background: transparent;
  color: var(--muted);
}

.filter-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.action-link {
  background: var(--primary-soft);
  border: 1px solid transparent;
  color: var(--primary-dark);
  transition: background 120ms ease;
}

.action-link:hover {
  background: rgba(13, 148, 136, 0.18);
  text-decoration: none;
}

.emergency-banner {
  margin: 0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(180, 35, 24, 0.18);
  color: var(--danger);
  font-weight: 600;
}

/* ---------- Clinic cards ---------- */
.clinic-grid {
  display: grid;
  gap: 12px;
}

.clinic-card {
  border-radius: var(--radius-sm);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 150ms ease, transform 150ms ease;
}

.clinic-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.clinic-card h3,
.resource-slide h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.clinic-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.clinic-card p strong {
  color: var(--text);
  font-weight: 600;
}

.why-list,
.language-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Resource carousel ---------- */
.resource-carousel {
  border-radius: var(--radius);
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.05), rgba(239, 108, 77, 0.04));
  border: 1px solid var(--line);
}

.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.carousel-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.carousel-nav {
  display: flex;
  gap: 8px;
}

.carousel-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary-dark);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 120ms ease, transform 120ms ease, opacity 120ms ease;
}

.carousel-arrow:hover:not(:disabled) {
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.carousel-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.carousel-viewport {
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.carousel-track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-padding: 0;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.resource-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: start;
  box-shadow: var(--shadow-sm);
}

.resource-badge {
  width: fit-content;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  background: var(--accent-soft);
  color: var(--accent);
}

.resource-instructions {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.resource-instructions strong {
  color: var(--text);
  font-weight: 600;
}

.resource-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.why-chosen {
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: var(--primary-soft);
  border: 1px solid rgba(13, 148, 136, 0.16);
}

.why-chosen-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-dark);
}

.why-chosen-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 0.9rem;
}

.why-chosen-list li::marker {
  color: var(--primary);
}

.resource-details {
  display: grid;
  gap: 2px;
}

.resource-details p {
  margin: 2px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.resource-details p strong {
  color: var(--text);
  font-weight: 600;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.18);
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.carousel-dot:hover {
  background: rgba(15, 23, 42, 0.32);
}

.carousel-dot.is-active {
  background: var(--primary);
  transform: scale(1.35);
}

/* ---------- Feedback & form ---------- */
.feedback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

.feedback-actions {
  display: flex;
  gap: 8px;
}

.chat-form {
  display: grid;
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.page-footer {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 6px 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid;
  gap: 16px;
}

.metric-card {
  padding: 22px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.metric-card strong {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.metric-card.wide {
  grid-column: span 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 860px) {
  .hero-card {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .content-grid {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }

  .location-controls {
    grid-template-columns: 1fr auto;
  }

  .clinic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card.wide {
    grid-column: span 2;
  }
}

@media (max-width: 859px) {
  .page-shell {
    margin: 12px auto 20px;
    gap: 12px;
    width: calc(100% - 16px);
  }

  .hero-card {
    padding: 16px 20px;
    gap: 8px;
  }

  .hero-copy {
    display: none; /* Save space on mobile */
  }

  .notice-card {
    padding: 10px 14px;
  }

  .content-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .chat-panel {
    order: -1; /* Move chat to top on mobile */
  }

  .panel {
    padding: 16px;
  }
}

.phone-link {
  color: var(--primary-dark);
  text-decoration: underline;
  font-weight: 600;
}

.phone-link:hover {
  color: var(--primary);
}

/* ---------- Modal Dialog ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.is-open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  max-width: 800px;
  width: min(800px, calc(100% - 32px));
  padding: 24px;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  display: grid;
  gap: 16px;
  animation: modalFadeIn 200ms ease-out;
}

.modal-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .modal-columns {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.modal-column h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  transition: color 120ms ease;
}

.modal-close:hover {
  color: var(--text);
}

.modal-content {
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.55;
  display: grid;
  gap: 12px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 4px;
}

.modal-content ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.modal-content li strong {
  color: var(--primary-dark);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.footer-separator {
  color: var(--line);
}

.footer-link-button {
  background: transparent;
  border: none;
  color: var(--primary-dark);
  text-decoration: underline;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.footer-link-button:hover {
  color: var(--primary);
}
