/* Order, account and admin pages. Builds on the tokens in styles.css. */

.site-nav li:has(> a[hidden]) { display: none; }

.account-link {
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
  padding: 0 6px;
  white-space: nowrap;
}

.app-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) var(--gutter) 0;
}
.app-page-wide { max-width: var(--max); }

.page-head { max-width: 42rem; margin-bottom: clamp(24px, 4vw, 40px); }
.page-head h1 {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1.12;
  font-variation-settings: "opsz" 72;
}
:root[lang="ar"] .page-head h1 { font-weight: 700; line-height: 1.4; }
.page-head p { margin-top: 12px; color: var(--ink-soft); }
.page-head-row {
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.notice {
  margin-bottom: 28px;
  padding: 18px 20px;
  background: var(--glass);
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.notice p { max-width: 36em; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.loading, .empty { color: var(--ink-soft); padding: 24px 0; }
.muted { color: var(--ink-soft); font-weight: 400; }

/* ---------- Fields ---------- */

.field { display: grid; gap: 6px; margin-top: 18px; }
.field > span:first-child { font-weight: 600; font-size: var(--step--1); }
.field-inline { margin-top: 0; }
.field-help { font-size: 0.8125rem; color: var(--ink-soft); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  font-size: 1rem; /* 16px stops iOS zooming into fields */
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { resize: vertical; min-height: 88px; }
input:hover, select:hover, textarea:hover { border-color: #9fb0bf; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
input:disabled { background: var(--paper); color: var(--ink-soft); cursor: not-allowed; }
[aria-invalid="true"] { border-color: #b3261e !important; }

.field-error, .form-error {
  color: #b3261e;
  font-size: var(--step--1);
  font-weight: 500;
}
.field-error:empty, .form-error:empty { display: none; }
.field-errors { margin-top: 10px; display: grid; gap: 4px; }
.field-errors li { color: #b3261e; font-size: var(--step--1); font-weight: 500; }
.form-error { margin: 14px 0 0; }
.form-ok { margin-top: 10px; color: #1d6b3a; font-size: var(--step--1); font-weight: 500; }
.form-ok:empty { display: none; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.field-wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .field-grid { grid-template-columns: 1fr; } }

.btn-block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Order form ---------- */

.order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}
@media (max-width: 920px) { .order-layout { grid-template-columns: minmax(0, 1fr); } }
/* let the prescription table scroll inside its box instead of widening the page */
.order-steps, .order-summary { min-width: 0; }

/* the divider is a shadow, not a border, so the legend doesn't cut through it */
.step {
  margin: 0;
  padding: 28px 0 32px;
  border: 0;
  box-shadow: inset 0 1px 0 var(--line);
  min-width: 0;
}
.step:first-child { box-shadow: none; padding-top: 0; }
.step legend { float: inline-start; width: 100%; }
.step > :not(legend) { clear: both; }
.step legend {
  padding: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  font-variation-settings: "opsz" 48;
}
:root[lang="ar"] .step legend { font-weight: 700; font-size: var(--step-1); }
.step-num {
  font-family: "Bodoni Moda", Georgia, serif;
  color: var(--accent);
  min-width: 1.1em;
}
.step legend + * { margin-top: 18px; }
.step-empty { color: var(--ink-soft); font-size: var(--step--1); }

.sub-block { margin-top: 24px; }
.sub-h { font-size: var(--step-0); font-weight: 600; }
.sub-p { margin-top: 6px; font-size: var(--step--1); color: var(--ink-soft); max-width: 40em; }
.sub-h + .choice-grid, .sub-p + .choice-grid { margin-top: 12px; }
.optional { font-weight: 400; color: var(--ink-soft); font-size: var(--step--1); }

/* choice cards: the whole card is the radio/checkbox label */
.choice-grid { display: grid; gap: 10px; }
.choice-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-list { display: grid; gap: 10px; }
@media (max-width: 720px) {
  .choice-grid-3 { grid-template-columns: 1fr; }
  .choice-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) { .choice-grid-2 { grid-template-columns: 1fr; } }

.choice {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name price" "desc desc";
  gap: 4px 12px;
  padding: 14px 16px;
  padding-inline-start: 44px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.choice:hover { border-color: #9fb0bf; }
.choice input {
  position: absolute;
  inset-inline-start: 16px;
  top: 17px;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.choice-name { grid-area: name; font-weight: 600; }
.choice-desc { grid-area: desc; font-size: var(--step--1); color: var(--ink-soft); }
.choice-price { grid-area: price; font-size: var(--step--1); font-weight: 600; white-space: nowrap; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice:has(input[aria-invalid="true"]) { border-color: #b3261e; }
.choice-grid-3 .choice,
.choice-grid-4 .choice { grid-template-areas: "name" "desc" "price"; grid-template-columns: 1fr; align-content: start; }
.choice-grid-3 .choice-price,
.choice-grid-4 .choice-price { margin-top: 4px; }

/* segmented control for manual / upload */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 4px;
  gap: 4px;
  background: var(--glass);
  border-radius: 999px;
}
.segmented label {
  position: relative;
  display: inline-flex;
}
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--step--1);
  color: var(--ink-soft);
}
.segmented input:checked + span { background: var(--white); color: var(--ink); box-shadow: 0 2px 6px -3px rgba(5, 26, 55, 0.4); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented-small span { padding: 6px 14px; }

[data-rx-manual], [data-rx-upload] { margin-top: 18px; }

.rx-input-wrap { margin-top: 14px; overflow-x: auto; }
.rx-input { border-collapse: separate; border-spacing: 8px 8px; margin: -8px; }
.rx-input thead th {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-soft);
  text-align: start;
  padding-inline-start: 4px;
}
.rx-input tbody th {
  text-align: start;
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
  padding-inline-end: 8px;
}
:root[lang="ar"] .rx-input tbody th { text-align: left; }
.rx-input select, .rx-input input { min-width: 92px; font-variant-numeric: tabular-nums; }
.rx-input input { width: 92px; }
.rx-input [hidden] { display: none; }

/* phones: one block per eye, fields in a 2×2 grid with their own labels */
@media (max-width: 560px) {
  .rx-input, .rx-input tbody, .rx-input tr { display: block; margin: 0; }
  .rx-input thead { display: none; }
  .rx-input tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
  }
  .rx-input tr + tr { margin-top: 4px; }
  .rx-input tbody th { grid-column: 1 / -1; padding: 0; }
  .rx-input td { display: grid; gap: 4px; }
  .rx-input td::before {
    content: attr(data-label);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink-soft);
  }
  .rx-input select, .rx-input input { width: 100%; min-width: 0; }
  .rx-input-wrap { overflow: visible; }
}

.file-drop {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px;
  border: 1.5px dashed #9fb0bf;
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
}
.file-drop:hover { border-color: var(--ink); }
.file-drop { position: relative; }
/* the native input stays keyboard-focusable but our label does the talking */
.file-drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-drop-label { font-weight: 600; font-size: var(--step--1); word-break: break-all; }
.file-drop-label::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-end: 10px;
  vertical-align: -2px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--white), inset 0 0 0 10px var(--glass);
}

.pd-block { margin-top: 26px; }
.pd-block .segmented { margin-top: 10px; }
.pd-fields { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 12px; }
.pd-fields .field { width: 130px; }
.pd-fields [hidden] { display: none; }

/* summary */
.order-summary {
  position: sticky;
  top: 96px;
  padding: 24px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: 0 30px 50px -40px rgba(5, 26, 55, 0.5);
}
@media (max-width: 920px) { .order-summary { position: static; } }
.order-summary h2 { font-size: var(--step-2); }
.summary-empty { margin-top: 12px; color: var(--ink-soft); font-size: var(--step--1); }
.summary-lines { margin: 14px 0 0; }
.summary-lines div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--step--1);
}
.summary-lines dd { margin: 0; white-space: nowrap; font-weight: 600; }
.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 14px;
  font-weight: 600;
}
.summary-total strong { font-family: "Bodoni Moda", Georgia, serif; font-size: var(--step-2); font-weight: 500; }
.summary-total[hidden] { display: none; }
.summary-note { margin-top: 14px; font-size: var(--step--1); color: var(--ink-soft); }

.order-done {
  max-width: 40rem;
  padding: clamp(28px, 5vw, 48px);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
}
.order-done:focus { outline: none; }
.order-done h2 { font-family: var(--font-display); font-size: var(--step-3); font-weight: 500; }
.order-done p { margin-top: 12px; color: var(--ink-soft); }

/* ---------- Account ---------- */

.auth-card {
  max-width: 440px;
  padding: clamp(20px, 4vw, 32px);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
}
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.tabs [role="tab"] {
  flex: 1;
  padding: 12px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.auth-help { margin-top: 14px; font-size: var(--step--1); color: var(--ink-soft); }

.account-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(28px, 4vw, 44px);
}
.account-head h1 { font-family: var(--font-display); font-size: var(--step-3); font-weight: 500; }
:root[lang="ar"] .account-head h1 { font-weight: 700; }
.account-meta { margin-top: 6px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: var(--step--1); }

.orders-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.orders-head h2 { font-size: var(--step-2); }

.orders { display: grid; gap: 10px; }
.order-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.order-card summary {
  list-style: none;
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 20px;
  padding: 16px 20px;
  cursor: pointer;
}
.order-card summary::-webkit-details-marker { display: none; }
.order-card[open] summary { border-bottom: 1px solid var(--line); }
.order-number { font-weight: 600; font-variant-numeric: tabular-nums; }
.order-lens, .order-total { display: grid; font-size: var(--step--1); }
.order-total { font-weight: 600; text-align: end; }
.order-lens .muted, .order-total .muted { font-size: 0.8125rem; }
@media (max-width: 640px) {
  .order-card summary { grid-template-columns: 1fr auto; }
  .order-lens { grid-column: 1 / -1; grid-row: 2; }
  .order-total { text-align: start; }
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--glass);
  color: var(--ink);
  justify-self: end;
}
.pill-placed { background: #fff1d6; color: #6b4a00; }
.pill-paid { background: #dff3e6; color: #1d6b3a; }
.pill-confirmed { background: #F3EBDD; color: #6B4E1C; }
.pill-completed { background: #dff3e6; color: #1d6b3a; }
.pill-cancelled { background: #f2e0df; color: #8c1d18; }

.order-body { padding: 20px; }

/* unpaid orders: a strip under the card with the Pay now button */
.order-item:has(.pay-strip) .order-card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.pay-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 20px;
  background: #fff6e3;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  font-size: var(--step--1);
}
.pay-strip p { color: #6b4a00; font-weight: 500; }

.pay-banner {
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 500;
}
.pay-banner-ok { background: #dff3e6; color: #1d5a33; }
.pay-banner-warn { background: #fff1d6; color: #6b4a00; }
.pay-banner-error { background: #f2e0df; color: #8c1d18; }
.order-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 28px;
}
@media (max-width: 760px) { .order-detail { grid-template-columns: 1fr; } }
.detail-list { margin: 0; }
.detail-list > div {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--step--1);
}
.detail-list > div:first-child { padding-top: 0; }
.detail-list dt { font-weight: 600; color: var(--ink-soft); }
.detail-list dd { margin: 0; }
@media (max-width: 480px) { .detail-list > div { grid-template-columns: 1fr; gap: 2px; } }

.rx-mini { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rx-mini th, .rx-mini td { padding: 3px 12px 3px 0; text-align: start; }
.rx-mini thead th { font-size: 0.75rem; color: var(--ink-soft); }
.rx-mini tbody th { font-weight: 600; white-space: nowrap; }

.order-progress h3 { font-size: var(--step-0); margin-bottom: 12px; }
.timeline { display: grid; gap: 0; }
.timeline li {
  position: relative;
  display: grid;
  padding: 0 0 16px;
  padding-inline-start: 22px;
  font-size: var(--step--1);
}
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 17px;
  bottom: 2px;
  width: 1px;
  background: var(--line);
}
.timeline-status { font-weight: 600; }
.timeline-date, .timeline-note { color: var(--ink-soft); }

/* admin */
.customer-line { margin-bottom: 18px; font-size: var(--step--1); }
.status-form {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr) auto;
  align-items: end;
  gap: 0 16px;
}
.status-form h3 { grid-column: 1 / -1; font-size: var(--step-0); }
.status-form .field { margin-top: 10px; }
.status-form .btn { margin-top: 10px; min-height: 46px; }
.status-form .form-ok { grid-column: 1 / -1; }
@media (max-width: 640px) { .status-form { grid-template-columns: 1fr; } }
