/* =====================================================================
 *  OrthoPlan Pro — the documents (6 Nov 2026, package DOC).
 *
 *  Only what the existing containers do not already give: the Summary's
 *  one-line identity, its pillar cards and tooth figures (R-DOC-16/18), and
 *  the consent card's signed copy (R-DOC-07). Built on the existing cards,
 *  section heads and linked cards; package S restyles them through its
 *  design layer. Tokens from the top of public.css, logical properties
 *  only, so the same rules lay out the Arabic screen right to left.
 * ===================================================================== */

/* ---- The case in one line (R-DOC-16) ---- */
.op-frontend .op-summary-ident { padding-block: var(--op-sp-3); }
.op-frontend .op-summary-ident-line { margin: 0; font-size: 13px; line-height: 1.6; color: var(--op-text-muted); overflow-wrap: anywhere; }
.op-frontend .op-summary-ident-part[data-part="code"],
.op-frontend .op-summary-ident-part[data-part="name"] { font-weight: 800; color: var(--op-text); }
.op-frontend .op-summary-ident-sep { color: var(--op-text-soft); }

/* ---- The patient's instruction sheets, beside the exports (R-FUP-12) ----
   A row of their own under the parts, laid out like them but not one of
   them: the photos tick and the parts' scripts leave these links alone. */
.op-frontend .op-summary-instr {
    display: flex;
    flex-wrap: wrap;
    flex-basis: 100%;
    align-items: center;
    gap: var(--op-sp-2);
    margin-block-start: var(--op-sp-3);
    padding-block-start: var(--op-sp-3);
    border-top: 1px solid var(--op-border);
}
.op-frontend .op-summary-instr .op-field-label { width: 100%; }
/* An appliance's name is a word or two; on a phone each button is a full row. */
@media (max-width: 480px) {
    .op-frontend .op-summary-instr { flex-direction: column; align-items: stretch; }
    .op-frontend .op-summary-instr .op-btn { width: 100%; justify-content: flex-start; text-align: start; white-space: normal; }
}

/* ---- The journey says when it is finished (R-DOC-17) ---- */
.op-frontend .op-journey-finished { color: var(--op-success-text, var(--op-success)); }

/* ---- The diagnosis and the strategy at a glance (R-DOC-18) ---- */
.op-frontend .op-summary-visual { display: grid; gap: var(--op-sp-3); }
.op-frontend .op-summary-dx .op-summary-figs { margin-block-start: var(--op-sp-2); }
.op-frontend .op-summary-plan .op-summary-group:first-of-type { margin-block-start: 0; }
.op-frontend .op-summary-pillars { display: grid; gap: var(--op-sp-3); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.op-frontend .op-summary-pillar {
    border: 1px solid var(--op-border);
    border-inline-start: 4px solid var(--op-pillar, var(--op-border));
    border-radius: 10px;
    padding: var(--op-sp-3);
    background: var(--op-pillar-tint, var(--op-surface));
    min-width: 0;
}
.op-frontend .op-summary-pillar[data-group="dental"] { grid-column: 1 / -1; }
.op-frontend .op-summary-pillar .op-linked-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.op-frontend .op-summary-pillar .op-linked-card { background: var(--op-surface); }
.op-frontend .op-summary-group { margin-block-start: var(--op-sp-3); }
.op-frontend .op-summary-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--op-sp-2); margin-block-end: var(--op-sp-2); flex-wrap: wrap; }
.op-frontend .op-summary-group-head h4 { margin: 0; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--op-text-muted); }

/* ---- The three tooth figures: drawn to be read, not tapped ---- */
.op-frontend .op-summary-figs { display: grid; gap: var(--op-sp-3); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-block-start: var(--op-sp-4); }
.op-frontend .op-summary-fig { margin: 0; padding: var(--op-sp-2); border: 1px solid var(--op-border); border-radius: 10px; background: var(--op-surface); min-width: 0; overflow-x: auto; }
.op-frontend .op-summary-fig .tchart { margin: 4px 0 0; }
/* Left to right in every language: the chart is a picture of the patient
   (his right on the reader's left), not a line of text. */
.op-frontend .op-summary-fig .tchart-row { display: flex; align-items: flex-end; justify-content: center; gap: 1px; direction: ltr; }
.op-frontend .op-summary-fig .tchart-lower { align-items: flex-start; margin-block-start: 3px; padding-block-start: 3px; border-top: 1px dashed var(--op-border); }
.op-frontend .op-summary-fig .tchart-t { display: flex; flex-direction: column; align-items: center; }
.op-frontend .op-summary-fig .tchart-lower .tchart-t { flex-direction: column-reverse; }
.op-frontend .op-summary-fig .tchart-mid { margin-inline-end: 8px; }
/* fix/teeth18 (C17-PLN-06): the midline between 11 | 21 and 41 | 31, dashed like
   the arch line, through both rows. The chart is one column as wide as its
   widest row, each row centres teeth of the same widths on both sides, so the
   middle of every row is the midline, scrolled or not. */
.op-frontend .op-summary-fig .tchart { display: grid; grid-template-columns: minmax(max-content, 1fr); }
.op-frontend .op-summary-fig .tchart-row { position: relative; }
.op-frontend .op-summary-fig .tchart-row::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--op-border); pointer-events: none; }
.op-frontend .op-summary-fig .tchart-lower::after { top: -4px; }
.op-frontend .op-summary-fig .tchart-n { font-size: 11px; color: var(--op-text-muted); line-height: 1.4; }
.op-frontend .op-summary-fig .tchart-l { font-size: 11px; color: var(--op-text-soft); }
.op-frontend .op-summary-fig .tchart-key { display: flex; flex-wrap: wrap; gap: var(--op-sp-3); justify-content: center; margin-block-start: 6px; font-size: 11px; color: var(--op-text-muted); }
.op-frontend .op-summary-fig .tchart-key-i { display: inline-flex; align-items: center; gap: 4px; }
.op-frontend .op-summary-fig .tchart-sw { width: 11px; height: 11px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); }

/* ---- The consent card (R-DOC-05/07) ---- */
.op-frontend .op-consent-draft,
.op-frontend .op-consent-record { margin: 0; }
.op-frontend .op-consent-print-row { margin: 0; }
.op-frontend .op-consent-scan { display: inline-block; line-height: 0; }
.op-frontend .op-consent-scan img { display: block; max-width: 220px; max-height: 160px; width: auto; height: auto; border: 1px solid var(--op-border); border-radius: 8px; background: var(--op-bg-alt); }
.op-frontend .op-consent-scan-file { line-height: 1.4; font-weight: 600; }
.op-frontend .op-consent-upload.is-busy { opacity: .6; pointer-events: none; }
.op-frontend .op-consent-upload.is-dragover { border-color: var(--op-primary); }
.op-frontend .op-consent-changed { margin: 0; }
/* Signed on an older plan version (R-DOC-10, question 6): the warning, the
   signed sheet one click away, and the consents kept from earlier plans. */
.op-frontend .op-consent-outdated { margin: 0; display: grid; gap: var(--op-sp-1, 4px); }
.op-frontend .op-consent-outdated p { margin: 0; }
.op-frontend .op-consent-print-signed { font-weight: 600; }
/* "Open the printable consent · Treatment Plan 2" is a sentence on a phone
   (356px of it at 360): it wraps inside the card instead of running off the
   screen. Buttons are nowrap everywhere else, which is right for a word. */
.op-frontend .op-consent-card .op-consent-print,
.op-frontend .op-consent-record .op-btn { white-space: normal; max-width: 100%; text-align: start; }
.op-frontend .op-consent-earlier ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--op-text-muted); }
.op-frontend .op-consent-earlier li { overflow-wrap: anywhere; }
/* A consent for an older plan is not done: the warning's edge, not the
   success green, until the new plan's consent is recorded (review). */
.op-frontend .op-consent-card.is-outdated { border-inline-start: 3px solid var(--op-warning, #d98324); }
/* The copy of a consent already recorded, filed with it: a smaller box,
   and in the list of earlier consents a line of its own. */
.op-frontend .op-consent-upload-copy { padding: var(--op-sp-2) var(--op-sp-3); }
.op-frontend .op-consent-earlier .op-consent-upload-copy { display: inline-flex; margin: 4px 0 0; max-width: 100%; }
.op-frontend .op-consent-rules-link { margin: 0; font-size: 12px; }

/* ---- The clinic's consent rules (R-DOC-12), on the Appointments screen ---- */
.op-frontend .op-consent-rules-card summary { cursor: pointer; font-weight: 700; display: flex; gap: var(--op-sp-2); align-items: baseline; flex-wrap: wrap; }
.op-frontend .op-consent-rules-form { display: grid; gap: var(--op-sp-2); margin-block-start: var(--op-sp-3); }
.op-frontend .op-consent-rules-form textarea { width: 100%; min-height: 96px; }
.op-frontend .op-consent-rules-form .op-btn { justify-self: start; }

/* =====================================================================
 *  fix/jus (11 Nov 2026) — Justification and the consent
 * ===================================================================== */

/* ---- The Problem list in three columns; folded groups on a phone (R11-JUS-01) ----
   "Three columns side by side on the computer and the tablet, so it is
   compact; the phone has to be long, but collapsed by default." Each group
   is a <details>: its summary is the heading, the count and the sub-line. */
.op-frontend .op-pgroup > summary { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 var(--op-sp-2); }
.op-frontend .op-pgroup > summary::-webkit-details-marker { display: none; }
.op-frontend .op-pgroup-head .op-pgroup-title { grid-column: 1; min-width: 0; }
.op-frontend .op-pgroup-count { grid-column: 2; font-size: 12px; color: var(--op-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.op-frontend .op-pgroup-head .op-pgroup-sub { grid-column: 1 / -1; display: block; }
.op-frontend .op-pgroup .op-problem-item { break-inside: avoid; }
/* One numbering, 1 … N, through the three groups: written on each line, since a <details> starts a counter of its own. */
.op-frontend .op-plist .op-problem-item[data-n]::before { content: attr(data-n) '.'; }
/* The phone: one column, each group a row that opens on a tap, the whole row the target. */
@media (max-width: 767.98px) {
    .op-frontend .op-pgroup { padding-block: var(--op-sp-1); }
    .op-frontend .op-pgroup > summary { min-height: 44px; align-content: center; cursor: pointer; grid-template-columns: minmax(0, 1fr) auto auto; }
    .op-frontend .op-pgroup > summary::after { content: '▾'; grid-column: 3; grid-row: 1; font-size: 11px; color: var(--op-text-soft); }
    .op-frontend .op-pgroup:not([open]) > summary::after { content: '▸'; }
    [dir="rtl"] .op-frontend .op-pgroup:not([open]) > summary::after { content: '◂'; }
    .op-frontend .op-pgroup:not([open]) .op-pgroup-sub { display: none; }
}
/* The computer and the tablet: the groups side by side, always open. The
   Skeletal column keeps room for its Correct / Improve / Accept in one row. */
@media (min-width: 768px) {
    .op-frontend .op-plist { display: flex; flex-direction: row; align-items: flex-start; container-type: inline-size; }
    .op-frontend .op-plist > .op-pgroup { flex: 1 1 0; min-width: 0; padding-inline: var(--op-sp-3); }
    .op-frontend .op-plist > .op-pgroup.op-pillar-skeletal { min-width: min(16rem, 34%); }
    .op-frontend .op-pgroup > summary { cursor: default; pointer-events: none; }
    .op-frontend .op-pgroup .op-problem-list { padding-inline-start: 28px; }
    .op-frontend .op-pgroup .op-problem-item::before { inset-inline-start: -28px; inline-size: 22px; }
    /* Correct / Improve / Accept as one segmented row, never three rows. */
    .op-frontend .op-plist .op-problem-decision .op-chips { display: flex; flex-wrap: nowrap; gap: 4px; }
    /* The calm look lays the chips out on their field (.op-chips is display: contents there): the row is held there too. */
    .op-frontend .op-plist .op-problem-decision .op-field-chips { flex-wrap: nowrap; gap: 4px; }
    .op-frontend .op-plist .op-problem-decision .op-chip { flex: 1 1 auto; min-width: 0; padding-inline: 6px; justify-content: center; text-align: center; }
}
/* The long group (Dental, 15+ lines) is twice as wide and lays its lines in two columns when the list has the room. */
@container (min-width: 760px) {
    .op-frontend .op-plist > .op-pgroup.is-long { flex-grow: 2; }
    .op-frontend .op-pgroup.is-long .op-problem-list { column-count: 2; column-gap: var(--op-sp-6); }
}

/* ---- Objectives: three rows, a reason under each chosen one (R11-JUS-02/04) ----
   Skeletal, Dental and Soft tissue, each edged in the Problem list's colour
   for that group; the '+' and the Why line in the chips' column. */
/* The row is the chips' own two-column grid (op-diagnosis.css), so the '+'
   and the Why line sit exactly under the chips, not under the row's name. */
.op-frontend .op-obj-row {
    display: grid;
    grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr);
    column-gap: var(--op-sp-3);
    border-inline-start: 3px solid var(--op-pillar, var(--op-border));
    padding-inline-start: var(--op-sp-3);
}
.op-frontend .op-obj-row > .op-field-chips { grid-column: 1 / -1; }
.op-frontend .op-obj-row > .op-addopt,
.op-frontend .op-obj-row > .op-obj-why { grid-column: 2; margin-block-start: var(--op-sp-1); min-width: 0; }
.op-frontend .op-obj-why[hidden] { display: none; }
.op-frontend .op-obj-why-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--op-sp-2); margin: 0; }
.op-frontend .op-obj-why-field .op-field-label { margin: 0; color: var(--op-text-muted); }
.op-frontend .op-obj-why-field .op-input { width: 100%; min-width: 0; }
@media (max-width: 600px) {
    .op-frontend .op-obj-row { grid-template-columns: minmax(0, 1fr); }
    .op-frontend .op-obj-row > .op-addopt,
    .op-frontend .op-obj-row > .op-obj-why { grid-column: 1; }
}

/* ---- The red warning on Clinical Steps (R11-JUS-07) ----
   "A red message at the top … and even if you go past it, it stays." Red
   edge, red words and a red sign, in both looks; not dismissable, and it
   blocks nothing. One row on the computer (the words, then the two ways
   on), so the first field of Clinical Steps stays in the first screen. */
.op-frontend .op-consent-warning {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--op-sp-2) var(--op-sp-4);
    margin-block-end: var(--op-sp-3);
    padding: var(--op-sp-2) var(--op-sp-4);
    border: 1px solid var(--op-danger);
    border-inline-start-width: 4px;
    border-radius: var(--op-radius);
    background: var(--op-danger-bg);
    color: var(--op-danger-text);
}
/* The calm look fills no box with a status colour (spec: red at marker size);
   the edge, the words and the sign carry the red. */
.op-ds .op-consent-warning { background: var(--ds-surface); }
.op-frontend .op-consent-warning-text { flex: 1 1 22rem; min-width: 0; margin: 0; font-weight: 600; line-height: 1.5; }
.op-frontend .op-consent-warning-text .op-ic { color: var(--op-danger); }
.op-frontend .op-consent-warning-actions { display: flex; flex-wrap: wrap; gap: var(--op-sp-2); }
.op-frontend .op-consent-warning .op-btn { white-space: normal; text-align: start; }
/* "Go to the consent" is a step link (.op-goto-step: the tab switch lands on
   the card); the calm look draws those as words, so its target is set here. */
.op-frontend .op-consent-warning .op-consent-warning-actions .op-btn { min-height: 36px; margin-block: 0; }
@media (max-width: 480px) {
    .op-frontend .op-consent-warning { padding: var(--op-sp-3); }
    .op-frontend .op-consent-warning-actions { flex: 1 1 100%; flex-direction: column; align-items: stretch; }
    .op-frontend .op-consent-warning .op-btn { justify-content: center; }
}

/* Recorded under the typed name, its signed copy not uploaded yet (review): a line of the warning's colour, not the success green. */
.op-frontend .op-consent-unfiled { margin-block: var(--op-sp-2); }

/* ---- His own legal text, beside the clinic's rules (R11-JUS-06) ---- */
.op-frontend .op-consent-legal { display: grid; gap: var(--op-sp-2); }
.op-frontend .op-consent-legal textarea { width: 100%; min-height: 140px; }
.op-frontend .op-consent-legal-load { display: flex; flex-wrap: wrap; align-items: center; gap: var(--op-sp-2); }
.op-frontend .op-consent-legal-load .op-field-hint { margin: 0; }
.op-frontend .op-consent-signer-hint { display: block; margin-block-start: var(--op-sp-1); }

/* Touch: every control here at least 44 px on a coarse pointer. */
@media (pointer: coarse) {
    .op-frontend :is(.op-consent-legal-load .op-btn, .op-consent-rules-form .op-btn, .op-obj-why-field .op-input, .op-problem-decision .op-chip, .op-consent-card [data-sigpad-clear]) { min-height: 44px; }
    .op-frontend .op-consent-warning .op-consent-warning-actions .op-btn { min-height: 44px; }
}
/* ---------- end fix/jus ---------- */
