/* ── Shared CSS variables and utilities ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700;800&display=swap');

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

:root {
  --blue:        #2563eb;
  --blue-mid:    #3b82f6;
  --blue-light:  #eff6ff;
  --blue-dark:   #1e40af;
  --navy:        #1e3a5f;
  --red:         #dc2626;
  --red-light:   #fef2f2;
  --amber:       #d97706;
  --amber-light: #fffbeb;
  --green:       #16a34a;
  --green-light: #f0fdf4;
  --purple:      #7c3aed;
  --purple-light:#f5f3ff;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-700:    #334155;
  --gray-900:    #0f172a;
  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md:   0 4px 20px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
}

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spin {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spin-sm {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Visit form step labels ──────────────────────────────────────────────── */
.step-label {
  display: flex; align-items: center; gap: 7px; margin-bottom: 5px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--blue); color: white;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.step-title { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.step-req   { font-size: 12px; color: var(--red); font-weight: 700; }

/* ── Loader overlay ──────────────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; background: white;
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-wrap {
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
  height: 8px;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--blue);
  transition: width .5s ease;
}
.progress-bar.green  { background: var(--green); }
.progress-bar.amber  { background: var(--amber); }
.progress-bar.red    { background: var(--red); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 10px;
  display: inline-block;
}
.bd-blue   { background: var(--blue-light);   color: var(--blue); }
.bd-green  { background: var(--green-light);  color: var(--green); }
.bd-red    { background: var(--red-light);    color: var(--red); }
.bd-amber  { background: var(--amber-light);  color: var(--amber); }
.bd-gray   { background: var(--gray-100);     color: var(--gray-500); }
.bd-purple { background: var(--purple-light); color: var(--purple); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 11px 16px;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-blue  { background: var(--blue);     color: white; }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-green { background: white; border: 1.5px solid var(--green); color: var(--green); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: var(--gray-400);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 72px; left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900); color: white;
  padding: 9px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  z-index: 500; pointer-events: none;
  white-space: nowrap;
  opacity: 0; transition: opacity .2s;
}
.toast.on { opacity: 1; }
