/* ==========================================================================
   DevPed PH — Design tokens
   ========================================================================== */
:root {
  --navy: #16324f;
  --teal: #0f8b7a;
  --teal-dark: #0b6d60;
  --teal-tint: #eaf6f2;
  --green: #3fae5c;
  --green-tint: #e9f7ec;
  --pink: #e0577a;
  --pink-tint: #fbe9ee;
  --purple: #8b6fd9;
  --purple-tint: #efeafb;
  --orange: #e8905c;
  --orange-tint: #fcefe5;

  --bg: #f7f9f9;
  --surface: #ffffff;
  --border: #e7ecec;
  --text: #1b2430;
  --text-secondary: #6b7680;
  --text-muted: #9aa4ab;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 40, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 40, 40, 0.08);

  --header-h: 0px; /* set dynamically by JS not required; header scrolls with content */
  --bottomnav-h: 68px;

  --font: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--bottomnav-h) + 12px);
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 560px;
    box-shadow: var(--shadow-md);
    min-height: 100vh;
  }
  body { background: #eef2f2; }
}

.page { padding: 12px 16px 8px; animation: fadeIn 0.18s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Top bar / header
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 4px;
  background: var(--surface);
}
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--radius-pill);
  color: var(--navy);
  position: relative;
}
.icon-btn:active { background: var(--teal-tint); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--surface);
}

.brand-header {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 16px 16px;
  background: var(--surface);
}
.brand-mascot { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--teal-tint); }
.brand-text h1 { margin: 0; font-size: 26px; line-height: 1.1; letter-spacing: -0.5px; }
.brand-text h1 .brand-dev { color: var(--navy); font-weight: 800; }
.brand-text h1 .brand-ped { color: var(--teal); font-weight: 800; }
.brand-text h1 .brand-ph { color: var(--green); font-weight: 800; }
.brand-tagline { margin: 4px 0 0; font-size: 13.5px; color: var(--teal-dark); font-weight: 600; }

/* ==========================================================================
   Search bar
   ========================================================================== */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  margin: 4px 0 12px;
  box-shadow: var(--shadow-sm);
}
.search-bar svg { flex-shrink: 0; color: var(--text-secondary); }
.search-bar input {
  border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ==========================================================================
   Filter row
   ========================================================================== */
.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.filter-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 8px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 56px;
  text-align: left;
}
.filter-chip .filter-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-secondary); font-weight: 500;
}
.filter-chip .filter-value {
  font-size: 12.5px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filter-chip svg { flex-shrink: 0; }
.filter-chip.active .filter-value { color: var(--teal); }

/* ==========================================================================
   Stats grid
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}
.stat-card { display: flex; align-items: center; gap: 10px; }
.stat-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.icon-green { background: var(--green-tint); color: var(--green); }
.stat-icon.icon-teal { background: #e3f1fb; color: #2f8fd6; }
.stat-icon.icon-purple { background: var(--purple-tint); color: var(--purple); }
.stat-icon.icon-orange { background: var(--orange-tint); color: var(--orange); }
.stat-number { font-size: 19px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 11.5px; color: var(--text-secondary); line-height: 1.25; }
.stat-source { font-size: 9.5px; color: var(--text-muted); }

/* ==========================================================================
   Section headers
   ========================================================================== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title { display: flex; align-items: center; gap: 6px; }
.section-title h2 { font-size: 16px; margin: 0; font-weight: 700; }
.section-title .sub { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0 22px; }
.section-header .view-all {
  font-size: 13px; font-weight: 700; color: var(--teal);
  display: flex; align-items: center; gap: 2px;
}

/* ==========================================================================
   Location chips
   ========================================================================== */
.location-chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px;
  scrollbar-width: none;
}
.location-chips::-webkit-scrollbar { display: none; }
.location-chip {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.location-chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.location-chip.more { color: var(--text-secondary); }

/* ==========================================================================
   Clinic list card
   ========================================================================== */
.clinic-card {
  display: flex; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
}
.clinic-thumb {
  width: 64px; height: 64px; border-radius: 12px; object-fit: cover;
  background: var(--teal-tint); flex-shrink: 0;
}
.clinic-info { flex: 1; min-width: 0; }
.clinic-name { font-size: 14.5px; font-weight: 700; margin: 0 0 2px; }
.clinic-city { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 6px; }
.clinic-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
.verified-badge {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--green); font-weight: 700; font-size: 12px;
}
.clinic-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.action-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: 6px 10px; font-size: 12px; font-weight: 700;
  color: var(--teal-dark); white-space: nowrap;
}
.action-btn.call { color: var(--teal-dark); }
.action-btn.map { color: var(--navy); }
.clinic-chevron { display: flex; align-items: center; color: var(--text-muted); }
.clinic-row { display: flex; align-items: center; gap: 8px; }

/* ==========================================================================
   Quick access grid
   ========================================================================== */
.quick-access {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 8px;
  margin: 16px 0 20px;
}
.quick-access-title { font-size: 15px; font-weight: 700; margin: 0 0 14px 10px; }
.quick-access-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick-item { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: none; }
.quick-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.quick-icon.blue { background: #e7f1fb; color: #3f7fc9; }
.quick-icon.green { background: var(--green-tint); color: var(--green); }
.quick-icon.pink { background: var(--pink-tint); color: var(--pink); }
.quick-icon.gray { background: #eef1f2; color: var(--text-secondary); }
.quick-label { font-size: 11px; text-align: center; color: var(--text); font-weight: 600; }

/* ==========================================================================
   Bottom navigation
   ========================================================================== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  height: var(--bottomnav-h);
  z-index: 50;
}
@media (min-width: 900px) { .bottom-nav { max-width: 560px; } }
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; color: var(--text-secondary);
}
.nav-item.active { color: var(--teal); }
.nav-item span { font-size: 11px; font-weight: 600; }

/* ==========================================================================
   Doctor profile page
   ========================================================================== */
.profile-hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 16px; text-align: center; margin-bottom: 14px;
}
.profile-avatar {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--teal-tint); display: flex; align-items: center; justify-content: center;
  color: var(--teal); font-size: 30px; font-weight: 800;
  border: 3px solid var(--teal-tint);
}
.profile-name { font-size: 19px; font-weight: 800; margin: 0 0 2px; }
.profile-specialty { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; }
.profile-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700;
}
.badge.verified { background: var(--green-tint); color: var(--green); }
.badge.rating { background: #fff6e0; color: #c9891a; }

.info-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 12px;
}
.info-card h3 { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.info-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-row .icon { color: var(--teal); flex-shrink: 0; }
.affiliation-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.affiliation-item:last-child { border-bottom: none; }
.affiliation-name { font-weight: 700; font-size: 13.5px; }
.affiliation-schedule { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.source-tag {
  display: inline-block; background: var(--teal-tint); color: var(--teal-dark);
  font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: var(--radius-pill);
  margin: 2px 4px 2px 0;
}

.review-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.review-item:last-child { border-bottom: none; }
.review-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.review-author { font-weight: 700; font-size: 13px; }
.review-stars { color: #eab308; font-size: 12px; }
.review-comment { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.review-date { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.btn-primary {
  width: 100%; background: var(--teal); color: #fff; border: none;
  border-radius: var(--radius-md); padding: 13px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px;
}
.btn-secondary {
  width: 100%; background: var(--surface); color: var(--navy); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 13px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px;
}
.btn-report {
  width: 100%; background: var(--pink-tint); color: var(--pink); border: none;
  border-radius: var(--radius-md); padding: 12px; font-size: 13.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* ==========================================================================
   Form elements (review + report)
   ========================================================================== */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; display: block; }
.form-input, .form-textarea, .form-select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.form-textarea { min-height: 90px; resize: vertical; }
.star-picker { display: flex; gap: 6px; font-size: 26px; color: #d8dcdc; }
.star-picker .star.active { color: #eab308; }

/* ==========================================================================
   Empty / loading states
   ========================================================================== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state svg { margin-bottom: 10px; color: var(--text-muted); }
.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 37%, #eee 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   Map page
   ========================================================================== */
#map-canvas { width: 100%; height: 340px; border-radius: var(--radius-md); overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border); }
.leaflet-popup-content b { color: var(--navy); }

/* ==========================================================================
   About / More page
   ========================================================================== */
.more-list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 13px 14px; margin-bottom: 8px;
}
.more-list-item .icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--teal-tint); color: var(--teal); flex-shrink: 0; }
.more-list-item .text { flex: 1; }
.more-list-item .title { font-size: 14px; font-weight: 700; }
.more-list-item .subtitle { font-size: 12px; color: var(--text-secondary); }

.toast {
  position: fixed; bottom: calc(var(--bottomnav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
