/* ============================================================
   صفحهٔ حساب.

   روی همان توکن‌های سایت سوار است (`tokens.css`) و هیچ رنگ تازه‌ای
   تعریف نمی‌کند، تا حالت روشن و تیره خودشان کار کنند.
   ============================================================ */

.account-page {
  --account-width: 1000px;
  --account-gutter: clamp(16px, 4vw, 32px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.account-page .skip-link {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: var(--account-gutter);
  z-index: 1000;
  transform: translateY(-150%);
  padding: 10px 16px;
  border-radius: var(--r);
  background: var(--fg);
  color: var(--bg);
}
.account-page .skip-link:focus { transform: translateY(0); }

.acc-shell,
.acc {
  width: 100%;
  max-width: var(--account-width, 900px);
  margin-inline: auto;
  padding-inline: var(--account-gutter, clamp(16px, 4vw, 32px));
}

.account-page .page-head {
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.page-head__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 14px;
}
.page-head__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.page-head__brand img { flex: none; filter: brightness(1.35) saturate(1.1); }
[data-theme="light"] .page-head__brand img { filter: none; }
.page-head__names { display: grid; gap: 3px; line-height: 1.4; }
.page-head__names strong { font-family: var(--font-display); font-size: var(--fs-base); }
.page-head__names small { color: var(--fg-2); font-size: var(--fs-xs); }
.page-head__inner nav { display: flex; flex-wrap: wrap; gap: 0 4px; }
.page-head__inner nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 10px;
  border-radius: var(--r);
  color: var(--fg-2);
  font-size: var(--fs-sm);
}
.page-head__inner nav a:hover { background: var(--surface-3); color: var(--fg); }

.account-page .page-foot {
  margin-block-start: auto;
  padding-block: 18px;
  border-block-start: 1px solid var(--line);
  color: var(--fg-2);
  font-size: var(--fs-sm);
}
.page-foot a,
.acc-content noscript a { text-decoration: underline; text-underline-offset: 3px; }

.acc {
  padding-block: clamp(24px, 4.5vw, 54px);
}
.acc-title { margin-block-end: clamp(14px, 2.5vw, 22px); font-size: clamp(1.75rem, 3vw, 2.35rem); }
.acc-content {
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.5vw, 24px);
}

/* ---- سرِ صفحه، وقتی وارد شده ---- */
.acc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: clamp(16px, 3vw, 25px);
  border: 1px solid var(--brand-line);
  border-radius: var(--r-lg);
  background: linear-gradient(115deg, var(--brand-soft), transparent 75%), var(--surface);
}
.acc-greeting { font-family: var(--font-display); font-size: var(--fs-h3); font-weight: 700; overflow-wrap: anywhere; }
.acc-head > div { flex: 1 1 215px; min-width: 0; }
.acc-head p { margin: 0; }
.acc-role { color: var(--fg-2); font-size: var(--fs-sm); }
.acc-phone { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.acc-head .acc-phone { display: inline-block; white-space: nowrap; }

/* ---- ناوبری حساب ---- */
.acc-layout {
  display: grid;
  grid-template-columns: minmax(155px, 215px) minmax(0, 1fr);
  gap: clamp(12px, 2.4vw, 24px);
  align-items: start;
}
.acc-switcher {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.acc-switcher button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
}
.acc-switcher button:hover { background: var(--surface-3); color: var(--fg); }
.acc-switcher button[aria-pressed="true"] {
  border-color: var(--brand-line);
  background: var(--brand-soft);
  color: var(--fg);
  font-weight: 700;
}
.acc-panel {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 14px;
}
.acc-panel > :empty { display: none; }
.acc:has(.acc-layout--auth), .acc:has(.acc-reset) {
  max-width: 565px;
}
.acc-layout--auth {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.acc-switcher--auth {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  margin: clamp(15px, 3vw, 26px) clamp(15px, 3vw, 26px) 0;
  background: var(--bg-2);
}
.acc-switcher--auth button { text-align: center; }
.acc-layout--auth .acc-panel { gap: 0; }
.acc-layout--auth .acc-form {
  border: 0;
  background: transparent;
  padding: clamp(15px, 3vw, 26px);
}
.acc-layout--auth .acc-forgot { margin: 0 clamp(15px, 3vw, 26px) clamp(15px, 3vw, 26px); }
.acc-layout--auth .acc-form > .btn--primary { width: 100%; }
@media (max-width: 680px) {
  .acc-layout { grid-template-columns: minmax(0, 1fr); }
  .acc-switcher--account { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .acc-switcher--account button { text-align: center; }
  .acc-switcher--account button:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---- فرم‌ها ---- */

.acc-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.acc-form h2 { font-size: var(--fs-h3); }
.acc-form small { color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.7; }

.acc-field { display: flex; flex-direction: column; gap: 6px; }
.acc-field span { font-size: var(--fs-sm); color: var(--fg); }
.acc-field input {
  min-width: 0;
  min-height: 44px;
  font: inherit;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--fg-3) 80%, var(--bg));
  border-radius: var(--r);
  background: var(--bg);
  color: inherit;
}
/* شمارهٔ موبایل همیشه چپ‌به‌راست است، حتی داخل صفحهٔ راست‌به‌چپ. */
.acc-field input[type="tel"] { direction: ltr; text-align: start; font-variant-numeric: tabular-nums; }
/* ایمیل هم چپ‌به‌راست؛ text-align: left تا در صفحهٔ فارسی از لبهٔ درستش شروع شود. */
.acc-field input[type="email"] { direction: ltr; text-align: left; }
.acc-field input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---- گذرواژهٔ فراموش‌شده ---- */
/* دکمه‌ای که شکل پیوند دارد: کاری در همین صفحه می‌کند، جایی نمی‌رود. */
.acc-link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.acc-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
.acc-forgot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
  padding: clamp(16px, 2.6vw, 22px);
  border: 1px dashed var(--line);
  border-radius: 18px;
}
.acc-forgot[hidden] { display: none; }
.acc-forgot .sub { width: 100%; margin: 0; }
.acc-forgot .acc-field { flex: 1 1 260px; }
.acc-reset { max-width: 460px; }

/* ---- پیام‌ها ---- */
.acc-msg {
  margin: 0;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid var(--line);
}
/* ⚠️ نه فقط رنگ. یک نویسه هم می‌گذارد، چون پیام خطا و پیام موفقیت
   نباید تنها با رنگ از هم جدا شوند — روی چاپ سیاه‌وسفید و برای کسی
   که سبز و قرمز را جدا نمی‌کند، رنگ هیچ نمی‌گوید. */
.acc-msg--error { border-color: #c0392b; }
.acc-msg--error::before { content: "⚠ "; font-weight: 700; }
.acc-msg--ok { border-color: var(--brand); }
.acc-msg--ok::before { content: "✓ "; font-weight: 700; }

.acc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.acc-price { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.acc-buy { border-color: var(--brand); }
.acc-kind { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; border: 0; padding: 0; margin: 4px 0; }
.acc-kind legend, .acc-kind__label { font-size: var(--fs-sm); color: var(--fg-2); margin-inline-end: 4px; padding: 0; }
.acc-radio { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.acc-payments { display: grid; gap: 8px; }
.acc-payment { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.acc-payment[data-status="failed"], .acc-payment[data-status="cancelled"] { opacity: .7; }
.acc-grant { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.acc-select { max-width: 100%; font: inherit; font-size: 13px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: inherit; }

.acc-card {
  margin: 0;
  padding: clamp(16px, 2.5vw, 22px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.8;
}
.acc-card p { margin: 0 0 8px; }
.acc-card p:last-child { margin: 0; }
.acc-good { color: var(--fg-2); }

/* ---- مدیریت ---- */
.acc-admin {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.acc-admin h2 { margin: 0; font-size: 18px; }
.acc-card h2 { margin: 0 0 10px; font-size: 18px; }
.acc-search {
  font: inherit;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: inherit;
  max-width: 340px;
}
.acc-users { display: flex; flex-direction: column; gap: 8px; }
.acc-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
}
.acc-user .btn { margin-inline-start: auto; }
.acc-tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink, inherit);
}
.acc-tag--off { background: #f0d5d1; color: #7a2016; }
.btn--small { padding: 6px 12px; font-size: 13px; }

/* ---- چاپ ----
   یک صفحهٔ حساب چیزی نیست که کسی چاپ کند، و اگر کرد نباید فرم و
   دکمه روی کاغذ بیفتد. */
@media print {
  .account-page .skip-link, .acc-form, .acc-admin, .acc-head .btn, .acc-search { display: none !important; }
  .acc { padding: 0; }
}

.acc-records,.record-save{margin-block:24px}.acc-records form,.record-save form{display:grid;gap:14px;margin-block:18px}.acc-records label,.record-save label{display:grid;gap:8px;line-height:1.8}.acc-records input:not([type=checkbox]),.acc-records textarea,.record-save input:not([type=checkbox]),.record-save select{width:100%;max-width:100%;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--fg);font:inherit}.record-consent{display:flex!important;align-items:flex-start;gap:10px!important}.record-consent input{margin-top:7px;flex-shrink:0}.record-card{border:1px solid var(--line);border-radius:12px;padding:18px;margin-block:14px}.record-assessment img{display:block;max-width:100%;max-height:600px;object-fit:contain;margin:auto}.record-table{overflow:auto}.record-table table{width:100%;border-collapse:collapse}.record-table th,.record-table td{padding:10px;text-align:start;border-bottom:1px solid var(--line)}.record-note{white-space:pre-wrap;overflow-wrap:anywhere}.record-sharing{border-block:1px solid var(--line);padding-block:18px}.sample-figure svg{max-width:260px}
.record-card .btn, .record-detail .btn, .acc-records .btn { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.record-programme{border-block-start:1px solid var(--line);margin-block-start:24px;padding-block-start:20px}
.record-programme details{margin-block:18px}.record-programme summary{cursor:pointer;font-weight:700;padding:12px;border:1px solid var(--line);border-radius:8px}
.record-programme select{width:100%;min-width:0;padding:12px;background:var(--surface);color:inherit;font:inherit;border:1px solid var(--line);border-radius:8px}
.record-programme fieldset{min-width:0;display:grid;gap:12px}.record-programme .rx__item{display:grid;grid-template-columns:minmax(110px,180px) minmax(0,1fr);gap:18px;align-items:center;margin-block:16px;padding:16px;border:1px solid var(--line);border-radius:12px}
.record-programme .rx__fig{width:100%;padding:0;border:0;background:transparent;color:inherit;cursor:pointer}.record-programme .rx__fig img,.record-programme .rx__fig svg{width:100%;height:auto;max-height:300px}.record-programme .rx__src{font-size:12px;line-height:1.8}.record-programme .is-open{grid-template-columns:1fr}.record-programme .rx__stills{display:none}
@media(max-width:540px){.record-programme .rx__item{grid-template-columns:1fr}.record-programme .rx__fig{max-width:220px;margin:auto}}
@media print{.record-programme form,.record-programme summary{display:none}.record-programme .rx__anim{display:none}.record-programme .rx__stills{display:flex}.record-programme .rx__stills img{width:48%}.record-programme .rx__item{break-inside:avoid}}

/* ------------------------------------------------------------------
   The clinic's front desk (js/account/crmPanel.js)

   Sized for a tablet standing on a reception desk: the search box and
   the buttons are finger targets, and the patient card is one column
   so it does not reflow when a name is long. Inherits the form styling
   above through .acc-crm, which is shaped like .acc-records.
   ------------------------------------------------------------------ */
.acc-crm{margin-block:24px}
.acc-crm form{display:grid;gap:14px;margin-block:18px}
.acc-crm label{display:grid;gap:8px;line-height:1.8}
.acc-crm input:not([type=checkbox]),.acc-crm textarea,.acc-crm select{width:100%;max-width:100%;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--fg);font:inherit}
.crm-search{margin-block:12px;font-size:16px}
.crm-status{min-height:1.5em;color:var(--fg-2)}
.crm-card{display:flex;gap:14px;align-items:center;justify-content:space-between;flex-wrap:wrap;border:1px solid var(--line);border-radius:12px;padding:14px 16px;margin-block:10px}
.crm-card h4{margin:0 0 4px}
.crm-card .sub{margin:0}
.crm-detail{margin-block:20px}
.crm-head h3{margin:0 0 4px}
.crm-actions{display:flex;gap:10px;flex-wrap:wrap;margin-block:16px}
.crm-note{white-space:pre-wrap;overflow-wrap:anywhere}

/* What has been agreed to, at a glance. The "nothing yet" chip is the
   one that has to be noticed, so it is the one that is outlined. */
.crm-chips{display:flex;gap:6px;flex-wrap:wrap;margin:6px 0 0}
.crm-chip{font-size:11.5px;line-height:1.6;padding:2px 9px;border-radius:999px;background:var(--surface-2,rgba(127,127,127,.14));color:var(--fg-2)}
.crm-chip--none{background:transparent;border:1px dashed var(--line);color:var(--fg-3)}

/* The gate, where the visit form would be. */
.crm-gate{border-inline-start:3px solid var(--line);padding:10px 14px;color:var(--fg-2);margin-block:16px}

.crm-visit,.crm-consent-row{border-top:1px solid var(--line);padding-block:12px}
.crm-visit p,.crm-consent-row p{margin:4px 0}
.crm-consent-row{display:flex;gap:12px;align-items:flex-start;justify-content:space-between;flex-wrap:wrap}
.crm-revoked{color:var(--fg-3)}

/* The consent form. The wording the patient agrees to is set apart so
   it reads as a statement rather than as more form furniture. */
.crm-consent-form{border:1px solid var(--line);border-radius:12px;padding:18px;margin-block:20px}
.crm-consent-text{background:var(--surface-2,rgba(127,127,127,.09));border-radius:8px;padding:12px 14px;line-height:1.9}
.crm-scopes{display:grid;gap:10px}
.crm-scope{display:flex!important;align-items:flex-start;gap:12px!important;border:1px solid var(--line);border-radius:10px;padding:12px 14px;cursor:pointer}
.crm-scope input{margin-top:5px;flex-shrink:0;width:20px;height:20px}
.crm-scope span{display:grid;gap:2px}
.crm-scope small{color:var(--fg-3)}

/* The pad is drawn on at the size it is shown; white because a
   signature is ink on paper in every theme. */
.crm-sign{width:100%;max-width:520px;height:auto;aspect-ratio:520/170;border:1px solid var(--line);border-radius:10px;background:#fff;touch-action:none;cursor:crosshair}

/* The reference price beside a discounted one (tools/shop.data.mjs).
   ⚠️ Only the live figure carries .product_price — that is the class
   Torob and Google read as the price. */
.product_was{color:var(--fg-3);font-size:.9em;margin-inline-end:6px}
.product_off{background:var(--brand);color:var(--on-brand);border-radius:var(--r-pill);
  padding:1px 8px;font-size:.8em;margin-inline-end:8px;white-space:nowrap}
