/* פורטל מטפלים — provider/clinic lens. Rides the CRM shell + tokens from
   portal.css + advisor.css; adds the availability editor + booking inbox. */

/* ---- Provider lens = PURPLE (the "one case, many lenses" colour system:
   patient=teal, advisor=gold, provider=purple). Remap the shared --brand*
   accent to purple, scoped to the provider app only, so every existing
   var(--brand) usage in provider.js/.css flips to purple with no logic
   change. AA-checked against white/wash. */
[data-lens="provider"] {
  --brand: #5a3ec8; --brand-deep: #48309e; --brand-ink: #4c2fa6; --brand-wash: #ece7fb;
  --brand-mark-color: #5a3ec8;
}
[data-lens="provider"] .brand-mark { color: var(--brand-mark-color); }
/* Workspace descriptor + demo chips follow the purple lens, not the gold default. */
[data-lens="provider"] .brand-context,
[data-lens="provider"] .demo-badge { color: var(--brand-ink); background: var(--brand-wash); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-lens="provider"],
  [data-lens="provider"]:not([data-theme="light"]) {
    --brand: #b6a2f0; --brand-deep: #cbbcf7; --brand-ink: #cbbcf7; --brand-wash: #241a3d;
    --brand-mark-color: #cbbcf7;
  }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Clinical-governance footer (mockup v5 p15/p16): the structured-care contract
   the whole provider workspace runs under — ICD-9 codes + structured actions,
   never a free-text SOAP note. Flex-pinned to the base of the CRM shell. */
.crm-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 8px clamp(14px, 2.5vw, 26px); background: var(--surface); border-block-start: 1px solid var(--line); font-size: .78rem; }
.cf-gov { font-weight: 700; color: var(--brand-ink); }
.cf-ver { color: var(--ink-faint); }

.clinic-switch select { font: inherit; font-weight: 600; font-size: .9rem; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); max-width: 220px; }

.clinic-head { display: grid; gap: 3px; }
.clinic-title { flex-wrap: wrap; row-gap: 6px; }
.verified-pending { color: var(--warn); background: var(--warn-wash); }
.clinic-title { font-size: 1.02rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.clinic-sub { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
.verified { font-size: .72rem; font-weight: 800; color: var(--ok); background: var(--ok-wash); border-radius: 999px; padding: 2px 9px; }
.fd-open { margin-top: 8px; align-self: start; }
.fd-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.fd-form .fld { flex: 1 1 200px; }
.fd-form input { font: inherit; font-weight: 600; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); color: var(--ink); min-height: 44px; width: 100%; }
.fd-list { display: grid; gap: 8px; }
.fd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; }
.fd-status { font-size: .8rem; font-weight: 800; border-radius: 999px; padding: 3px 11px; }
.fd-pending { color: var(--gold-ink); background: var(--gold-wash); }
.fd-approved { color: var(--ok); background: var(--ok-wash); }
.fd-denied { color: var(--ink-faint); background: var(--surface); }

/* Continuity brief + handoff */
.brief { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 2px 0 8px; }
.brief-note { font-size: .8rem; color: var(--ink-faint); margin: 0 0 10px; }
.brief-sec { padding: 8px 0; border-top: 1px solid var(--line); }
.brief-sec:first-of-type { border-top: 0; }
.brief-sec h3 { font-size: .8rem; font-weight: 800; color: var(--brand-ink); margin: 0 0 6px; text-transform: none; }
.brief-sec p { margin: 0; font-size: .92rem; }
.brief-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.brief-chip { font-size: .8rem; font-weight: 700; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; }
.brief-chip.meds { border-color: var(--gold); color: var(--gold-ink); }
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: .92rem; }
.ho-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; margin-bottom: 8px; }
.handoff-in { border-inline-start: 3px solid var(--brand); margin-top: 14px; }

/* Booking inbox */
.inbox { display: flex; flex-direction: column; gap: 10px; }
.bk { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); }
.bk-requested { border-inline-start: 3px solid var(--gold); }
.bk-accepted { border-inline-start: 3px solid var(--ok); }
.bk-completed { border-inline-start: 3px solid var(--brand); }
.bk-declined, .bk-cancelled { opacity: .62; }
.bk-status.bk-completed { color: var(--brand-ink); background: var(--brand-wash); }
.bk-main { display: grid; gap: 3px; min-width: 0; }
.bk-name { font-weight: 800; font-size: 1rem; }
.bk-track { font-weight: 700; font-size: .78rem; color: var(--brand-ink); background: var(--brand-wash); border-radius: 999px; padding: 2px 9px; margin-inline-start: 6px; }
.bk-when { font-size: .86rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.pre-ok { color: var(--ok); font-weight: 700; }
.pre-warn { color: var(--warn); font-weight: 700; }
.bk-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.bk-status { font-size: .82rem; font-weight: 800; border-radius: 999px; padding: 4px 12px; }
.bk-status.bk-accepted { color: var(--ok); background: var(--ok-wash); }
.bk-status.bk-declined, .bk-status.bk-cancelled { color: var(--ink-faint); background: var(--surface-2); }

/* Availability editor */
.avail .avail-sec { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.av-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.av-row select, .av-row input { font: inherit; font-weight: 600; font-size: .92rem; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--ink); min-height: 40px; }
.av-row input[type="time"], .av-row input[type="date"] { min-width: 120px; }
.av-row input[type="number"] { width: 76px; }
.av-row input[type="text"] { flex: 1 1 140px; min-width: 120px; }
.av-row span { color: var(--ink-soft); font-size: .88rem; font-weight: 700; }
.av-del { margin-inline-start: auto; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; font-size: .9rem; }
.av-del:hover { border-color: var(--crit); color: var(--crit); background: var(--crit-wash); }
.avail-empty { padding: 6px 0; }
.avail-save { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

/* V5 structured signup */
.join-sec { font-size: .95rem; font-weight: 800; color: var(--brand-ink); margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.join-multi { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.join-multi .cg-opt { min-height: 38px; font-size: .9rem; }
.join-note { font-size: .86rem; margin: 0 0 6px; }

/* Prescription (Rx) inline form — the treatment-loop write to the shared case */
.rx-host { grid-column: 1 / -1; }
.rx-form { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 2px 0 8px; }
.rx-note { font-size: .84rem; color: var(--ink-soft); margin: 0 0 10px; }
.rx-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rx-fields .rx-name { flex: 1 1 200px; }
.rx-fields .rx-dose { flex: 0 1 140px; }
.rx-fields input { min-height: 40px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; }
.rx-current { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .84rem; }

/* ICD-9 diagnosis (Treatment → Clinical → Rights) */
.dx-host { grid-column: 1 / -1; }
.dx-form { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 2px 0 8px; }
.dx-search-wrap { position: relative; }
.dx-search { width: 100%; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; }
.dx-results { margin-top: 6px; }
.dx-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow-y: auto; }
.dx-pick { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; cursor: pointer; font: inherit; }
.dx-pick:hover, .dx-pick:focus-visible { border-color: var(--brand); background: var(--surface-2); }
.dx-code { font-weight: 800; color: var(--brand-ink); flex: 0 0 auto; }
.dx-desc { color: var(--ink-soft); font-size: .9rem; }
.dx-none, .dx-more { font-size: .84rem; margin: 6px 2px 0; }
.dx-chip { border-color: var(--brand); }

/* Document provision panel */
.docs-host { grid-column: 1 / -1; }
.docs-form { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 2px 0 8px; }
.docs-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-chip { font-size: .84rem; font-weight: 700; border-radius: 999px; padding: 5px 13px; border: 1px solid var(--line); background: var(--surface); font-family: inherit; }
button.doc-chip.doc-add { cursor: pointer; border-color: var(--brand); color: var(--brand-ink); }
button.doc-chip.doc-add:hover, button.doc-chip.doc-add:focus-visible { background: var(--brand); color: #fff; }
.doc-chip.doc-have { border-color: var(--ok, #2e7d32); color: var(--ok, #2e7d32); }

/* Care-continuity indicator on bookings */
.bk-series { font-size: .8rem; color: var(--ink-soft); margin-top: 3px; }
.bk-series-warn { color: var(--warn, #b26a00); font-weight: 700; }
.bk-series-end { color: var(--danger, #c0392b); font-weight: 800; }

/* ---- Redesign v1.3 (mockup p11): schedule inbox ---- */
.bk-day { font-size: .9rem; font-weight: 800; color: var(--ink-soft); margin: 18px 2px 8px; display: flex; align-items: baseline; gap: 8px; }
.bk-day:first-child { margin-top: 0; }
.bk-day-past { color: var(--ink-faint); border-top: 1px solid var(--line); padding-top: 14px; }
.bk-time { flex: 0 0 auto; font-weight: 800; font-size: 1rem; color: var(--brand-ink); font-variant-numeric: tabular-nums; background: var(--brand-wash); border-radius: var(--r-sm); padding: 6px 10px; align-self: flex-start; }
.bk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.bk .bk-main { flex: 1 1 auto; }

/* ---- Clinical cockpit (mockup v5 p15): schedule · detail · messages ----
   Three columns on wide screens; the day schedule (right) selects the patient
   shown in the centre detail column, clinical messages sit on the left. Stacks
   to one column on phones. The detail reuses the booking card (.bk + hosts). */
.ck-cockpit { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.ck-col { min-width: 0; }
.ck-col-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; }
.ck-col-head h2 { font-size: 1rem; font-weight: 800; margin: 0; }
.ck-schedule, .ck-messages { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 14px; box-shadow: var(--shadow); }
.ck-day { font-size: .82rem; font-weight: 800; color: var(--ink-soft); margin: 14px 2px 7px; display: flex; align-items: baseline; gap: 6px; }
.ck-day:first-of-type { margin-top: 2px; }
.ck-day-past { color: var(--ink-faint); border-top: 1px solid var(--line); padding-top: 12px; }
.ck-appt { display: flex; align-items: center; gap: 10px; inline-size: 100%; text-align: start; background: var(--surface-2); border: 1px solid var(--line); border-inline-start: 3px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; margin-block-end: 7px; cursor: pointer; font: inherit; color: var(--ink); }
.ck-appt:hover { border-color: var(--brand); }
.ck-appt.selected { border-color: var(--brand); border-inline-start-color: var(--brand); background: var(--brand-wash); box-shadow: 0 0 0 1px var(--brand); }
.ck-appt.bk-requested { border-inline-start-color: var(--gold); }
.ck-appt.bk-accepted { border-inline-start-color: var(--ok); }
.ck-appt.bk-completed, .ck-appt.selected { border-inline-start-color: var(--brand); }
.ck-appt-time { flex: 0 0 auto; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-ink); }
.ck-appt-name { flex: 1 1 auto; font-weight: 700; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-appt-status { flex: 0 0 auto; }
.ck-detail .bk { box-shadow: var(--shadow); }
.ck-empty { padding: 14px 6px; }
@media (min-width: 820px) {
  .ck-cockpit { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
  .ck-messages { grid-column: 1 / -1; }
}
@media (min-width: 1160px) {
  .ck-cockpit { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(220px, 280px); }
  .ck-messages { grid-column: auto; }
}

/* ---- Redesign v1.3 (mockup p12): availability week grid ---- */
.avail-grid-card { margin-bottom: 14px; }
.ag-wrap { display: flex; gap: 6px; }
.ag-hours { display: flex; flex-direction: column; justify-content: space-between; padding-block: 26px 0; font-size: .68rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; text-align: center; flex: 0 0 auto; }
.ag-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; flex: 1 1 auto; min-inline-size: 0; }
.ag-col { display: grid; grid-template-rows: auto 1fr; gap: 4px; min-inline-size: 0; }
.ag-day { text-align: center; font-size: .74rem; font-weight: 800; color: var(--ink-soft); }
.ag-track { position: relative; block-size: 320px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background-image: repeating-linear-gradient(to bottom, transparent, transparent calc(100% / 14 - 1px), var(--line) calc(100% / 14 - 1px), var(--line) calc(100% / 14)); }
.ag-block { position: absolute; inset-inline: 3px; border-radius: 6px; display: grid; place-items: center; font-size: .68rem; font-weight: 700; overflow: hidden; }
.ag-block span { padding: 2px; }
.ag-avail { background: var(--ok-wash); color: var(--ok); border: 1px solid var(--ok); }
.ag-window { background: var(--gold-wash); color: var(--gold-ink); border: 1px dashed var(--gold); }
.ag-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .8rem; color: var(--ink-soft); }
.ag-key { display: inline-block; inline-size: 14px; block-size: 14px; border-radius: 4px; }
.ag-key.ag-avail, .ag-key.ag-window { position: static; }
@media (max-width: 900px) { .ag-track { block-size: 220px; } .ag-day { font-size: .66rem; } }
