/* Patients directory + profile (web/js/staff/patients.js). Classes are prefixed .pt- */

.pt-page { max-width: var(--content-w); margin-inline: auto; min-width: 0; }
.pt-head { margin-bottom: var(--s-5); }
.pt-head-text { min-width: 0; }

/* ---------------------------------------------------------------- toolbar */
.pt-toolbar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--safe-top));
  z-index: 5;
  display: grid;
  gap: var(--s-3);
  margin: 0 -16px var(--s-4);
  padding: var(--s-2) 16px var(--s-3);
  background: linear-gradient(180deg, var(--bg) 78%, rgba(246, 244, 240, 0));
}
.pt-search { position: relative; min-width: 0; }
.pt-search .input { height: 52px; font-size: 16px; padding-right: 48px; border-radius: var(--radius-pill); box-shadow: var(--shadow-1); }
.pt-search:has(.pt-search-clear:not([hidden])) .input { padding-right: 88px; }
.pt-search .input::-webkit-search-cancel-button { display: none; }
.pt-search-spin { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); display: grid; }
.pt-search:has(.pt-search-clear:not([hidden])) .pt-search-spin { right: 54px; }
.pt-search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.pt-filters { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pt-filters::-webkit-scrollbar { display: none; }
.pt-filters .chip { flex: none; min-height: 38px; }

/* ---------------------------------------------------------------- list */
.pt-results { min-width: 0; transition: opacity var(--dur-2) var(--ease); }
.pt-results.is-busy { opacity: .6; }
.pt-list {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.pt-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "av main chev" "av next chev";
  align-items: center;
  column-gap: 14px;
  row-gap: 6px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  border-top: 1px solid var(--line-soft);
  transition: background-color var(--dur-2) var(--ease);
}
.pt-row:first-child { border-top: 0; }
.pt-row > .avatar { grid-area: av; align-self: start; }
.pt-row-main { grid-area: main; min-width: 0; display: grid; gap: 3px; }
.pt-row-next { grid-area: next; min-width: 0; }
.pt-row-chevron { grid-area: chev; color: var(--ink-muted); }
a.pt-row:hover { background: var(--purple-light); color: inherit; }
a.pt-row:focus-visible { outline-offset: -2px; background: var(--purple-light); }
.pt-row.is-family { padding-left: 34px; background: var(--surface-2); }
.pt-row.is-family::before {
  content: "";
  position: absolute;
  left: 37px;
  top: -1px;
  height: 22px;
  width: 1px;
  background: var(--line-strong);
}
.pt-row.is-family:hover { background: var(--purple-light); }
.pt-row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.pt-row-name { font-weight: 600; font-size: 16px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.pt-row-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pt-row-badges .badge { font-size: 11.5px; }
.pt-tag-badge { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.pt-row-family-names { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.pt-row-family-names svg { color: var(--ink-muted); }
.pt-row-next { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.pt-next-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.pt-next-text { display: flex; flex-wrap: wrap; gap: 0 8px; min-width: 0; }
.pt-next-when { font-weight: 600; color: var(--ink); white-space: nowrap; }
.pt-next-who { color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-row-next.is-empty .pt-next-who { color: var(--ink-muted); }
.pt-row-skel { pointer-events: none; }
.pt-more { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-6) 0 var(--s-2); }

@media (min-width: 900px) {
  .pt-row {
    grid-template-columns: auto minmax(0, 1.25fr) minmax(0, 1fr) auto;
    grid-template-areas: "av main next chev";
    padding: 14px 20px;
  }
  .pt-row.is-family { padding-left: 40px; }
  .pt-row.is-family::before { left: 41px; }
  .pt-row-next { justify-self: stretch; }
}
@media (min-width: 640px) {
  .pt-toolbar { margin-inline: -24px; padding-inline: 24px; }
}
@media (min-width: 1024px) {
  .pt-toolbar { margin-inline: -32px; padding-inline: 32px; }
}
@media (min-width: 1380px) {
  .pt-toolbar { grid-template-columns: minmax(280px, 480px) minmax(0, 1fr); align-items: center; }
}

/* ---------------------------------------------------------------- create sheet */
.pt-create { display: grid; gap: var(--s-4); }
.pt-create .segmented { width: 100%; }
.pt-create .segmented-item { flex: 1; }
.pt-family-note { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--purple-light); color: var(--purple-dark); font-size: 14px; }
.pt-family-note svg { color: var(--purple); flex: none; }
.pt-form-error:empty { display: none; }

/* ---------------------------------------------------------------- profile */
.pt-profile { display: grid; gap: var(--s-5); min-width: 0; }
.pt-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: start;
  min-height: 36px;
  margin: -6px 0 -8px -6px;
  padding: 0 10px 0 4px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
}
.pt-back:hover { background: rgba(22, 0, 85, .06); color: var(--ink); }
.pt-notfound, .pt-error { max-width: 560px; margin: var(--s-10) auto; }

.pt-hero {
  position: relative;
  display: grid;
  gap: var(--s-5);
  padding: var(--s-6);
  border-radius: var(--radius-lg);
  background: var(--grad-soft);
  overflow: hidden;
}
.pt-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}
.pt-hero > * { position: relative; z-index: 1; }
.pt-hero-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-4); align-items: center; }
.pt-hero-id { display: grid; gap: 8px; min-width: 0; }
.pt-hero-name { font-size: clamp(26px, 4vw, 38px); overflow-wrap: anywhere; }
.pt-hero-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-hero-badges:empty { display: none; }
.pt-hero-badges .badge { background: rgba(255, 255, 255, .72); }
.pt-hero-badges .badge-purple { background: var(--purple); color: var(--cream-light); }
.pt-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; color: var(--ink-2); font-size: 14px; }
.pt-hero-phone { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; text-decoration: none; }
.pt-hero-phone:hover { color: var(--purple); }
.pt-hero-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pt-hero-actions .btn { flex: 1 1 160px; }
.pt-family { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding-top: var(--s-4); border-top: 1px solid rgba(22, 0, 85, .08); }
.pt-family-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pt-family-list { display: flex; flex-wrap: wrap; gap: var(--s-2); min-width: 0; }
.pt-fam {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 6px 14px 6px 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.pt-fam:hover { background: var(--surface); color: var(--ink); }
.pt-fam:active { transform: scale(.98); }
.pt-fam-text { display: grid; line-height: 1.2; min-width: 0; }
.pt-fam-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-fam-rel { font-size: 12px; color: var(--ink-2); }
.pt-fam-add { border: 1px dashed rgba(37, 0, 142, .35); background: transparent; color: var(--purple); padding-left: 8px; }
.pt-fam-plus { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--purple-tint); }

@media (min-width: 900px) {
  .pt-hero { padding: var(--s-8); }
  .pt-hero-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .pt-hero-actions { grid-column: auto; flex-wrap: nowrap; align-self: start; }
  .pt-hero-actions .btn { flex: none; }
}

/* stats */
.pt-stats { display: grid; gap: var(--s-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pt-stats .stat { padding: var(--s-4); }
.pt-stats .stat-value { font-size: clamp(22px, 5vw, 30px); overflow-wrap: anywhere; }
.pt-stat-leona { background: linear-gradient(160deg, var(--success-tint), var(--surface) 70%); }
.pt-stat-leona .stat-value { color: var(--success-ink); }
.pt-stats-line { margin-top: calc(var(--s-3) * -1); }
@media (min-width: 900px) {
  .pt-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
  .pt-stats .stat { padding: var(--s-5); }
}

/* columns + cards */
.pt-cols { display: grid; gap: var(--s-5); align-items: start; min-width: 0; }
.pt-col { display: grid; gap: var(--s-5); min-width: 0; }
@media (min-width: 1100px) {
  .pt-cols { grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); }
}
.pt-card {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.pt-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-width: 0; }
.pt-card-title { font-size: var(--fs-md); font-weight: 600; letter-spacing: var(--track-tight); font-family: var(--font-display); }
.pt-card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.pt-count { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--purple-tint); color: var(--purple); font-size: 13px; font-weight: 600; }
.pt-none { padding: var(--s-2) 0; }
.pt-toggle-history { justify-self: center; }
.pt-offers { display: grid; gap: var(--s-2); }
.pt-offer-timer { display: flex; align-items: center; gap: 6px; margin-top: 2px; }

/* appointment rows */
.pt-appts { display: grid; gap: var(--s-2); }
.pt-appt {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "date price" "main main";
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  padding: 12px 14px 12px 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
@media (min-width: 640px) {
  .pt-appt {
    grid-template-columns: 104px minmax(0, 1fr) auto;
    grid-template-areas: "date main price" "date main chev";
    gap: 2px 14px;
  }
}
.pt-appt::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 4px;
  background: var(--doc, var(--violet));
}
.pt-appt:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.pt-appt:active { transform: scale(.995); }
.pt-appt-date { grid-area: date; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; line-height: 1.25; min-width: 0; }
.pt-appt-day { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.pt-appt-time { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: var(--track-tight); white-space: nowrap; }
@media (min-width: 640px) { .pt-appt-date { display: grid; } }
.pt-appt-main { grid-area: main; display: grid; gap: 3px; min-width: 0; }
.pt-appt-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.pt-appt-sub { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-appt-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.pt-appt-badges .badge { font-size: 11.5px; }
.pt-appt-price { grid-area: price; justify-self: end; font-weight: 600; font-size: 14px; }
.pt-appt-chevron { grid-area: chev; justify-self: end; color: var(--ink-muted); }
@media (max-width: 639px) { .pt-appt-chevron { display: none; } }
.pt-appt.is-past { background: var(--surface-2); }
.pt-appt.is-past .pt-appt-time { color: var(--ink-2); }
.pt-appt.is-cancelled .pt-appt-title { color: var(--ink-2); }
.pt-appt.is-cancelled .pt-appt-price { color: var(--ink-muted); text-decoration: line-through; }

/* editor */
.pt-editor.is-dirty { border-color: rgba(37, 0, 142, .28); box-shadow: 0 0 0 4px rgba(37, 0, 142, .06), var(--shadow-1); }
.pt-editor-form { display: grid; gap: var(--s-4); }
.pt-editor-row { display: grid; gap: var(--s-4); }
@media (min-width: 520px) {
  .pt-editor-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.pt-editor-foot {
  position: static;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: 0 calc(var(--s-5) * -1) calc(var(--s-5) * -1);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
}
.pt-editor.is-dirty .pt-editor-foot { position: sticky; z-index: 2; box-shadow: 0 -8px 24px rgba(22, 0, 85, .06); }
@media (min-width: 1024px) {
  .pt-editor-foot { bottom: 12px; }
}
.pt-save-state { margin-right: auto; }
.pt-tags-wrap { display: grid; gap: 10px; }
.pt-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-tags:empty { display: none; }
.pt-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 4px 0 12px;
  border-radius: var(--radius-pill);
  background: var(--purple-tint);
  color: var(--purple);
  font-size: 13.5px;
  font-weight: 500;
}
.pt-tag-x { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--purple); }
.pt-tag-x:hover { background: rgba(37, 0, 142, .1); }
.pt-tag-add { display: flex; align-items: center; gap: 8px; }
.pt-tag-add .input { height: 40px; }
.pt-tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-tag-suggest:empty { display: none; }
.pt-tag-sug {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 12px 0 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-size: 13px;
}
.pt-tag-sug:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-light); }

/* waitlist & recalls */
.pt-wl-list { display: grid; gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.pt-wl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; }
.pt-wl-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--warning-tint); color: var(--warning-ink); }
.pt-wl-icon.is-recall { background: var(--success-tint); color: var(--success-ink); }
.pt-wl-main { display: grid; gap: 2px; min-width: 0; }
.pt-wl-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; }
.pt-wl-sub { font-size: 13px; color: var(--ink-2); }
.pt-wl-note { font-size: 13px; color: var(--ink-2); font-style: italic; }

/* messages */
.pt-msgs { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.pt-msg { display: grid; gap: 3px; max-width: 88%; }
.pt-msg.is-in { justify-self: start; }
.pt-msg.is-out { justify-self: end; justify-items: end; }
.pt-msg-bubble { padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.pt-msg.is-in .pt-msg-bubble { background: var(--cream); border-bottom-left-radius: 6px; }
.pt-msg.is-out .pt-msg-bubble { background: var(--purple-light); border-bottom-right-radius: 6px; }
.pt-msg-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pt-msg-btn { padding: 3px 10px; border-radius: var(--radius-pill); background: var(--surface); color: var(--purple); font-size: 12.5px; font-weight: 500; }
.pt-msg-meta { font-size: 12px; color: var(--ink-muted); }

@media (max-width: 639px) {
  .pt-hero { padding: var(--s-5); }
  .pt-hero-top > .avatar { --av-size: 56px !important; }
  .pt-card { padding: var(--s-4); }
  .pt-editor-foot { margin: 0 calc(var(--s-4) * -1) calc(var(--s-4) * -1); padding-inline: var(--s-4); }
  .pt-hero-top { align-items: start; }
}
