/* ==========================================================================
   OSCAR Booking — patient booking surface
   Register: Stripe / Linear / Apple. Legible, neutral, branded not decorated.
   Light is the default for every viewer, including system-dark.
   Dark applies only when the reader explicitly stamps data-theme="dark".
   ========================================================================== */

:root {
  --ground: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef0f4;
  --ink: #10131a;
  --ink-soft: #545a67;
  --ink-faint: #878e9c;
  --line: #e4e7ec;
  --line-strong: #cbd1da;
  --accent: #0f7355;
  --accent-soft: #edf5f2;
  --accent-ink: #0b5741;
  --on-accent: #ffffff;
  --warn: #8a5300;
  --warn-soft: #fdf5e6;
  --danger: #a4231a;
  --danger-soft: #fdf1f0;
  --band-limited: #f0b100;
  --band-full: #e5261f;
  --shadow: 0 1px 2px rgba(16, 19, 26, 0.05);
  --shadow-lift: 0 1px 3px rgba(16, 19, 26, 0.08), 0 6px 16px rgba(16, 19, 26, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
}

:root[data-theme='dark'] {
  --ground: #0c0e13;
  --surface: #14171e;
  --surface-2: #1c2029;
  --ink: #eceef2;
  --ink-soft: #9ba3b0;
  --ink-faint: #6b7280;
  --line: #232833;
  --line-strong: #333a47;
  --accent: #2fa07c;
  --accent-soft: #14251f;
  --accent-ink: #6fc9a8;
  --on-accent: #06120e;
  --warn: #d9a441;
  --warn-soft: #241c0c;
  --danger: #e0685e;
  --danger-soft: #241413;
  --band-limited: #fbbf24;
  --band-full: #ff4d42;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lift: 0 1px 3px rgba(0, 0, 0, 0.6), 0 6px 16px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.021em; }
p { margin: 0; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ shell */

.shell {
  max-width: 620px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
  padding: 15px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backbtn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  margin: -6px 0 -6px -8px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  display: none;
  line-height: 0;
}
.backbtn.on { display: inline-flex; }
.backbtn:hover { background: var(--surface-2); color: var(--ink); }
.backbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.themetoggle {
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--ink-soft);
  cursor: pointer;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  flex: none;
}
.themetoggle:hover { background: var(--surface-2); color: var(--ink); }
.themetoggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------- progress */

.steps {
  display: flex;
  gap: 4px;
  padding: 0 24px 14px;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 54px;
  z-index: 19;
}
.steps .bar {
  height: 2px;
  flex: 1;
  background: var(--line);
}
.steps .bar.done { background: var(--accent); }

/* ---------------------------------------------------------------- panes */

main { flex: 1; padding: 22px 24px 132px; }

.pane { display: none; }
.pane.on { display: block; }

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.title { font-size: 26px; font-weight: 640; margin-bottom: 6px; line-height: 1.2; }
.sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 28px; max-width: 46ch; }

/* ------------------------------------------------------------- services */

.group-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 28px 0 10px;
}
.group-label:first-of-type { margin-top: 0; }

.card-list { display: flex; flex-direction: column; gap: 6px; }

/* Discipline tiles — step 1 of the funnel. Tap-first: the whole tile advances. */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 380px) { .cat-grid { grid-template-columns: 1fr; } }

.cat {
  text-align: left;
  padding: 16px;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ground);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.cat:hover { border-color: var(--accent); background: var(--accent-soft); }
.cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cat-name { font-weight: 600; font-size: 15px; line-height: 1.3; letter-spacing: -0.01em; }
.cat-meta { font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.svc {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ground);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.svc:hover { border-color: var(--line-strong); background: var(--surface); }
.svc:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.svc.on { border-color: var(--accent); background: var(--accent-soft); }

.svc-main { flex: 1; min-width: 0; }
.svc-name { font-weight: 550; font-size: 15px; line-height: 1.35; }
.svc-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; font-variant-numeric: tabular-nums; }
.svc-chev { color: var(--ink-faint); flex: none; line-height: 0; }

/* Classification tag — carries a fact, never decoration. */
.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 550;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  background: var(--ground);
  white-space: nowrap;
}
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }

/* ------------------------------------------------------------- calendar */

.cal { margin-bottom: 18px; }

/* Step 2 must fit calendar + times on one screen; its header is tighter. */
#pane-time .sub { margin-bottom: 14px; }

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.cal-month {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.cal-nav {
  border: 1px solid var(--line-strong);
  background: var(--ground);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  line-height: 0;
}
.cal-nav:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.cal-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.cal-dow, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-dow {
  margin-bottom: 4px;
}
.cal-dow span {
  text-align: center;
  font-size: 11px;
  font-weight: 550;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cal-pad { display: block; }

.cal-day {
  position: relative;
  /* Booksy-compact: fixed short rows so the whole month AND the day's times
     share one screen. Square tiles pushed the times below the fold. */
  height: 38px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  font: inherit;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.cal-num { font-size: 13.5px; font-weight: 550; font-variant-numeric: tabular-nums; line-height: 1; }

/* The availability band. Colour is never the only signal — a day that cannot
   be picked is also not a button and carries aria-disabled. */
.cal-bar {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.cal-day.limited .cal-bar { background: var(--band-limited); }
.cal-day.full .cal-bar { background: var(--band-full); }

button.cal-day { cursor: pointer; background: var(--surface); border-color: var(--line); }
button.cal-day:hover { border-color: var(--accent); background: var(--accent-soft); }
button.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* A full day is a door to the waitlist, so it stays a button — but its number
   is muted so the eye still reads the month by where the room is. */
button.cal-day.full { color: var(--ink-soft); }
button.cal-day.full:hover { border-color: var(--band-full); background: var(--danger-soft); }

.cal-day.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cal-day.on .cal-bar { background: var(--on-accent); opacity: 0.8; }

/* Closed, past, beyond — visible for orientation, plainly not choosable. */
.cal-day.closed { color: var(--ink-faint); }
.cal-day.past, .cal-day.beyond { color: var(--ink-faint); opacity: 0.4; }

.cal-day.loading .cal-num { opacity: 0.25; }
.cal-day.loading { background: var(--surface); border-color: var(--line); }

.cal-key {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 8px;
  line-height: 1.45;
}

/* --------------------------------------------------------------- slots */

.prov-block { margin-bottom: 26px; }
.prov-block:last-child { margin-bottom: 0; }
.prov-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.prov-name { font-weight: 570; font-size: 14px; }
.prov-disc { font-size: 13px; color: var(--ink-faint); }
.prov-count { margin-left: auto; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot {
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ground);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.slot:hover { border-color: var(--accent); background: var(--accent-soft); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.slot.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* --------------------------------------------------------------- forms */

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 6px;
  color: var(--ink);
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ground);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.field textarea { min-height: 72px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.field.err input, .field.err textarea, .field.err select {
  border-color: var(--danger);
}
.field.err input:focus, .field.err textarea:focus, .field.err select:focus {
  outline-color: var(--danger);
  border-color: var(--danger);
}
.field .field-error {
  font-size: 12px;
  font-weight: 550;
  color: var(--danger);
  margin-top: 5px;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 440px) { .row2 { grid-template-columns: 1fr; } }

/* Step-3 vertical rhythm: the patient-type toggle, the identity block, and
   the visit-details note are three distinct sections, not one undifferentiated
   stack of fields — a consistent, generous gap between them (not just one
   accidental gap before the footer) reads as intentional at both a 430px
   phone and a 1440px desktop frame. Each section keeps its own tight internal
   .field spacing; only the SPACE BETWEEN sections grows. */
.details-body { display: flex; flex-direction: column; gap: 30px; }
.details-body > .seg { margin-bottom: 0; }
.details-section { padding-top: 2px; }
.details-section .group-label { margin: 0 0 12px; }
@media (min-width: 720px) {
  .details-body { gap: 36px; padding-top: 4px; }
}

.seg {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 22px;
}
.seg button {
  flex: 1;
  padding: 10px 8px;
  border: 0;
  background: var(--ground);
  cursor: pointer;
  font-size: 14px;
  font-weight: 530;
  color: var(--ink-soft);
}
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* --------------------------------------------------------- simulated sms */
/* Demo-only "your phone" panel: shows the code/confirmation texts arriving
   as received SMS bubbles, reusing the exact dryrun message bodies the
   server actually generated (never a second, invented copy). Deliberately
   plain — a quiet phone-frame card, not a decorative device mockup. */
.pf-sim {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 16px;
}
.pf-sim-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.pf-sim-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.pf-sim-thread { display: flex; flex-direction: column; gap: 8px; }
.pf-sim-msg {
  align-self: flex-start;
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.45;
  animation: pf-sim-in 0.18s ease-out;
}
.pf-sim-msg .pf-sim-time {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-faint);
}
@keyframes pf-sim-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .pf-sim-msg { animation: none; }
}
.pf-fill {
  display: block;
  margin-top: 8px;
}

/* -------------------------------------------------------------- review */

.summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px 16px;
  margin-bottom: 20px;
}
.summary .r {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 0;
  font-size: 14px;
}
.summary .r + .r { border-top: 1px solid var(--line); }
.summary .k { color: var(--ink-soft); flex: none; }
.summary .v { font-weight: 550; text-align: right; }

.notice {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }
.notice.err { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }
.notice strong { font-weight: 640; }

/* Simulation tint band — quiet, not a warning. Sits above the booking card
   for a demo tenant. Uses the tenant's own accent-soft/accent-ink tokens so
   it never reads as an alarm and holds contrast in both themes. */
.simband {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 18px;
}
.simband-back {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  white-space: nowrap;
}
.simband-back:hover,
.simband-back:focus-visible {
  text-decoration-thickness: 2px;
}
.simband-back:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------------------------------------------------------------- cta */

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  background: var(--ground);
  border-top: 1px solid var(--line);
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
}
.footer-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
}

.cta {
  flex: 1;
  padding: 12px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 570;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.cta:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cta:disabled { opacity: 0.38; cursor: not-allowed; }
.cta.ghost {
  background: var(--ground);
  color: var(--ink);
  border-color: var(--line-strong);
  flex: none;
  padding: 12px 16px;
}
.cta.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-strong); }

/* Inline text action inside a .hint line (e.g. "Use my email instead") — no
   button chrome, just the accent underline the rest of the product already
   uses for links. */
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.linklike:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.footmeta { font-size: 13px; color: var(--ink-soft); line-height: 1.35; }
.footmeta b { display: block; color: var(--ink); font-weight: 570; }

/* ------------------------------------------------------------- states */

.empty {
  padding: 28px 20px;
  color: var(--ink-soft);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty b { display: block; color: var(--ink); font-weight: 570; margin-bottom: 4px; font-size: 15px; }

.skel {
  height: 58px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}

.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.done-mark {
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 8px auto 20px;
  font-size: 20px;
  line-height: 0;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}

.payload {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--ink-soft);
  margin-top: 12px;
}

.disclose {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}
.disclose summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-soft);
  list-style: none;
}
.disclose summary::-webkit-details-marker { display: none; }
.disclose summary:hover { color: var(--ink); }
.disclose summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- desktop */
/* The flow is one column by design (Booksy register); on a wide screen the
   column becomes a framed card on a tinted page instead of floating loose
   in white space. The fixed footer keeps the same 620px frame. */
@media (min-width: 720px) {
  body { background: var(--surface); }
  .shell {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
  .footer { background: transparent; border-top: none; padding: 0; pointer-events: none; }
  .footer-inner {
    pointer-events: auto;
    background: var(--ground);
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  }
}
