/* Your Clinic — visual system. Deep-teal healthcare identity.
   Independent of any other product. Mobile-first, high-contrast, calm. */

:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --surface-2: #f4f8f7;
  --border: #e2eae8;
  --border-strong: #cdd9d6;

  --ink: #12302c;
  --ink-2: #526661;
  --ink-3: #86988f;

  --brand: #0d9488;
  --brand-strong: #0f766e;
  --brand-deep: #0b5f57;
  --brand-tint: #e4f3f1;
  --brand-tint-2: #d3ebe7;

  --amber: #b45309;
  --amber-tint: #fbf0e2;
  --rose: #b4413b;
  --rose-tint: #f8e9e8;
  --green: #197a53;
  --green-tint: #e4f2eb;
  --slate: #465a68;
  --slate-tint: #eef2f4;

  --shadow-sm: 0 1px 2px rgba(18, 48, 44, 0.06);
  --shadow: 0 4px 16px rgba(18, 48, 44, 0.08);
  --shadow-lg: 0 12px 32px rgba(18, 48, 44, 0.14);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-full: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 460px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  line-height: 1.45;
}

body { min-height: 100dvh; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

.tnum { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---------- App frame ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 18px 28px;
  flex: 1;
}
.screen--wide { max-width: 1080px; }

/* ---------- Top bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(241, 245, 244, 0.86);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 18px;
}
.appbar--wide .appbar__inner { max-width: 1080px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--brand); display: grid; place-items: center; color: #fff;
}
.brand__mark svg { width: 18px; height: 18px; }
.brand__name {
  font-weight: 650; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; /* never collide with the role switch */
}

/* Demo role switcher — deliberately secondary */
.roleswitch {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-full); padding: 3px;
}
.roleswitch button {
  font-size: 12.5px; font-weight: 550; color: var(--ink-2);
  padding: 5px 11px; border-radius: var(--r-full); line-height: 1;
}
.roleswitch button[aria-pressed="true"] { background: var(--surface); color: var(--brand-deep); box-shadow: var(--shadow-sm); }
.roleswitch__label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; margin-right: 2px; align-self: center; }
.roleswitch { flex: none; }

/* Narrow phones: slim the switch, then go icon-only brand, so the wordmark
   and the role switch never collide (group keeps its aria-label). */
@media (max-width: 400px) {
  .roleswitch__label { display: none; }
  .roleswitch button { padding: 5px 9px; }
}
@media (max-width: 340px) {
  .brand__name { display: none; }
}

/* ---------- Typography helpers ---------- */
.h1 { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.15; }
.h2 { font-size: 19px; font-weight: 640; letter-spacing: -0.01em; }
.eyebrow { font-size: 12px; font-weight: 620; text-transform: uppercase; letter-spacing: 0.09em; color: var(--brand-strong); }
.muted { color: var(--ink-2); }
.muted-3 { color: var(--ink-3); }
.center { text-align: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card--pad { padding: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 16px; padding: 15px 20px; border-radius: var(--r);
  min-height: 52px; transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
  width: 100%;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(13,148,136,0.28); }
.btn--primary:hover { background: var(--brand-strong); }
.btn--primary:disabled { background: var(--border-strong); color: #fff; box-shadow: none; cursor: not-allowed; }
.btn--ghost { background: var(--surface); border: 1px solid var(--border-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--surface); border: 1px solid var(--rose-tint); color: var(--rose); }
.btn--sm { min-height: 40px; padding: 9px 14px; font-size: 14px; width: auto; border-radius: var(--r-sm); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: 100%; }

/* ---------- Sticky action footer (booking) ---------- */
.actionbar {
  position: sticky; bottom: 0; z-index: 20;
  background: linear-gradient(to top, var(--bg) 68%, rgba(241,245,244,0));
  padding: 12px 0 calc(10px + var(--safe-bottom));
  margin-top: 8px;
}

/* ---------- Patient home ---------- */
.hero { padding: 8px 0 4px; }
.hero__badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 560;
  color: var(--brand-deep); background: var(--brand-tint); padding: 5px 11px; border-radius: var(--r-full); margin-bottom: 14px;
}
.hero__badge svg { width: 14px; height: 14px; flex: none; }
.hero__title { font-size: 30px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.hero__sub { margin-top: 10px; font-size: 16px; color: var(--ink-2); max-width: 34ch; }

.infogrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.infocard { padding: 13px 14px; }
.infocard__k { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.infocard__v { font-size: 14.5px; font-weight: 560; margin-top: 3px; }
.infocard__v.open { color: var(--green); }

.docstrip { display: flex; gap: 10px; margin-top: 16px; }
.docmini { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: var(--r-full); flex: none;
  background: var(--brand-tint); color: var(--brand-deep); display: grid; place-items: center;
  font-weight: 640; font-size: 14px;
}
.avatar--lg { width: 52px; height: 52px; font-size: 17px; }
.docmini__name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.docmini__role { font-size: 12px; color: var(--ink-3); }

/* ---------- Booking flow ---------- */
.flowhead { display: flex; align-items: center; gap: 12px; margin: 2px 0 16px; }
.backbtn {
  width: 40px; height: 40px; border-radius: var(--r-full); flex: none;
  border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--ink);
}
.backbtn:hover { background: var(--surface-2); }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { height: 4px; border-radius: var(--r-full); background: var(--border-strong); flex: 1; transition: background .2s; }
.steps span.done { background: var(--brand); }
.steps span.active { background: var(--brand); }

.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px; border: 1.5px solid var(--border); border-radius: var(--r);
  background: var(--surface); margin-bottom: 10px; transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--border-strong); }
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); }
.choice__body { flex: 1; min-width: 0; }
.choice__title { display: block; font-weight: 620; font-size: 16px; }
.choice__sub { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.choice__chev { color: var(--ink-3); flex: none; }

/* Date strip */
.datestrip { display: flex; gap: 9px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.datestrip::-webkit-scrollbar { display: none; }
.datechip {
  flex: none; scroll-snap-align: start; width: 62px; padding: 11px 0; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--surface); text-align: center; transition: border-color .12s, background .12s;
}
.datechip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: #fff; }
.datechip__dow { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; opacity: .85; }
.datechip__day { font-size: 21px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.datechip__mon { font-size: 11px; opacity: .8; }

/* Time slots */
.slotgroup { margin-top: 6px; }
.slotgroup__label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 620; color: var(--ink-2); margin: 16px 0 10px; }
.slotgroup__label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.slot {
  min-height: 52px; border-radius: var(--r-sm); border: 1.5px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 15px; color: var(--ink); transition: border-color .1s, background .1s;
}
.slot:hover:not(:disabled) { border-color: var(--brand); }
.slot[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(13,148,136,.3); }
.slot:disabled { color: var(--ink-3); background: var(--surface-2); border-color: var(--border); opacity: .55; cursor: not-allowed; text-decoration: line-through; }

/* Forms */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.input, textarea.input {
  width: 100%; padding: 14px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.input:focus, textarea.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
textarea.input { resize: vertical; min-height: 76px; }
.segrow { display: flex; gap: 9px; }
.seg {
  flex: 1; padding: 13px; border-radius: var(--r-sm); border: 1.5px solid var(--border);
  background: var(--surface); font-weight: 560; font-size: 14.5px; color: var(--ink-2); text-align: center;
}
.seg[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-deep); }
.chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: var(--r-full); border: 1.5px solid var(--border);
  background: var(--surface); font-size: 14px; font-weight: 540; color: var(--ink-2);
}
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-deep); }

/* Summary / review */
.summary { padding: 4px 2px; }
.summary__row { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.summary__row:last-child { border-bottom: none; }
.summary__k { font-size: 13.5px; color: var(--ink-2); width: 96px; flex: none; }
.summary__v { font-size: 15px; font-weight: 580; }
.paychoice { display: grid; gap: 10px; margin-top: 6px; }

/* Confirmation */
.confirm { text-align: center; padding: 20px 6px; }
.confirm__tick {
  width: 78px; height: 78px; border-radius: var(--r-full); margin: 6px auto 16px;
  background: var(--green-tint); color: var(--green); display: grid; place-items: center;
  animation: pop .35s ease;
}
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.confirm__title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.confirm__ref { display: inline-block; margin-top: 10px; font-weight: 640; letter-spacing: 0.08em; background: var(--surface-2); border: 1px solid var(--border); padding: 8px 14px; border-radius: var(--r-full); }
.ticket { text-align: left; margin: 20px 0 6px; overflow: hidden; }
.ticket__top { padding: 16px; display: flex; align-items: center; gap: 12px; background: var(--brand-tint); border-bottom: 1px dashed var(--border-strong); }
.ticket__body { padding: 4px 16px 10px; }

/* ---------- WhatsApp demo notices ---------- */
.wa-note {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  font-size: 13px; font-weight: 550; color: var(--green);
  margin-top: 10px;
}
.wa-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.wa-note--card {
  background: var(--green-tint); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 14px; margin-top: 14px;
}
.wa-note__btn {
  font-size: 12.5px; font-weight: 620; color: var(--brand-deep);
  text-decoration: underline; text-underline-offset: 2px; padding: 2px 0;
}
.wa-box {
  margin-top: 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); padding: 12px 14px; text-align: left;
}
.wa-box__tag { font-size: 11px; font-weight: 640; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.wa-box__msg {
  font-family: inherit; font-size: 14px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; margin: 8px 0 6px;
}
.wa-box__note { font-size: 12px; color: var(--ink-3); }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 620; padding: 4px 10px; border-radius: var(--r-full); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--booked { color: var(--slate); background: var(--slate-tint); }
.pill--waiting { color: var(--amber); background: var(--amber-tint); }
.pill--with-doctor { color: var(--brand-strong); background: var(--brand-tint-2); }
.pill--completed { color: var(--green); background: var(--green-tint); }
.pill--cancelled, .pill--no-show { color: var(--rose); background: var(--rose-tint); }
.pill--paid { color: var(--green); background: var(--green-tint); }
.pill--pay-at-clinic { color: var(--slate); background: var(--slate-tint); }

/* ---------- Clinic / Doctor operations ---------- */
.opshead { margin-bottom: 14px; }
.opshead .h1 { font-size: 23px; }
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 18px; }
.stat { padding: 14px 12px; text-align: center; }
.stat__n { font-size: 26px; font-weight: 720; line-height: 1; letter-spacing: -0.02em; }
.stat__l { font-size: 12px; color: var(--ink-2); margin-top: 5px; font-weight: 540; }
.stat--accent .stat__n { color: var(--brand-strong); }

.board { display: flex; flex-direction: column; gap: 10px; }
.appt { display: flex; align-items: stretch; gap: 12px; padding: 13px 14px; }
.appt__time { width: 62px; flex: none; text-align: left; padding-top: 1px; }
.appt__time .t { font-weight: 700; font-size: 15px; }
.appt__time .p { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.appt__main { flex: 1; min-width: 0; }
.appt__name { font-weight: 620; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.appt__meta { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.appt__meta b { color: var(--ink); font-weight: 600; }
.appt__actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.appt--free { border-style: dashed; color: var(--ink-3); }
.appt--free .appt__name { color: var(--ink-3); font-weight: 560; }
.appt--next { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }

.divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 6px; font-size: 12.5px; font-weight: 620; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Doctor next-patient hero */
.nextcard { padding: 18px; margin-bottom: 8px; border: 1.5px solid var(--brand); background: linear-gradient(180deg, var(--brand-tint) 0%, var(--surface) 60%); }
.nextcard__tag { font-size: 12px; font-weight: 640; color: var(--brand-deep); text-transform: uppercase; letter-spacing: .08em; }
.nextcard__name { font-size: 24px; font-weight: 720; letter-spacing: -0.02em; margin-top: 6px; }
.nextcard__facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 4px; }
.nextcard__fact .k { font-size: 11.5px; color: var(--ink-2); }
.nextcard__fact .v { font-size: 15px; font-weight: 620; }
.reasonbox { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-sm); border: 1px solid var(--border); }
.reasonbox .k { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.reasonbox .v { font-size: 15px; margin-top: 3px; }

/* Search + list */
.search { position: relative; margin-bottom: 14px; }
.search input { padding-left: 42px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }

/* Filter row */
.filterrow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.filterrow::-webkit-scrollbar { display: none; }

/* Empty states */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty svg { color: var(--border-strong); margin-bottom: 10px; }
.empty__title { font-weight: 620; color: var(--ink-2); font-size: 15px; }

/* ---------- Bottom nav (clinic/doctor mobile) ---------- */
.tabbar {
  position: sticky; bottom: 0; z-index: 25;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar__inner { max-width: var(--maxw); margin: 0 auto; display: flex; }
.tab {
  flex: 1; padding: 9px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-3); font-size: 11px; font-weight: 560;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="true"] { color: var(--brand-strong); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 540; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--rose); }

/* ---------- Loading ---------- */
.spinner { width: 26px; height: 26px; border: 3px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.settings-list .summary__row { padding: 15px 2px; }
.fee-badge { font-size: 15px; font-weight: 640; color: var(--brand-deep); }

/* ---------- Desktop refinements ---------- */
@media (min-width: 900px) {
  .screen--ops { max-width: 1080px; }
  .ops-grid { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
  .ops-grid__side { position: sticky; top: 84px; }
  .statrow { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: center; gap: 12px; text-align: left; }
  .stat__n { font-size: 30px; }
  .stat__l { margin-top: 0; }
  .tabbar { position: static; background: none; border: none; }
  .tabbar__inner { flex-direction: column; max-width: none; gap: 2px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; border-radius: var(--r-sm); font-size: 14.5px; }
  .tab[aria-current="true"] { background: var(--brand-tint); }
  .board .slots { grid-template-columns: repeat(4, 1fr); }
  .patient-desktop { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; max-width: 940px; }
  .patient-desktop__aside { position: sticky; top: 90px; }
}
@media (min-width: 900px) {
  .screen:not(.screen--ops):not(.patient-desktop-wrap) { }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
