/* public/css/documents/five-disease-cert.css — ใบรับรองแพทย์ (5 โรค): A4 portrait by default, A5 from the toolbar's
   Paper toggle (the shell swaps body.page-A4 ↔ page-A5 and the @page rule). The standard Thai certificate as a
   clean typed sheet at a generous 11.5 pt — dotted blanks for values, the ก.พ. disease list, the physician's opinion
   under a bold heading on ruled lines, the footnotes pushed to the page bottom (editor.js fitPage). Everything inside the body is measured in em, so the
   A5 variant is the same sheet at a smaller type size; only the page geometry (letterhead, footer, print bands,
   margins) is in mm, with the OPD card's A5 values under .page-A5.
   Print: fixed letterhead + footer repeat on every page; the thead/tfoot spacer rows of table.doc-pages reserve
   their bands (same technique as the OPD card). */

@page { size: A4; margin: 0; } /* the shell's <style id="paper-size"> says A5 instead when that is chosen */

.five-cert { font-family: 'Sarabun', sans-serif; color: #111; font-size: 11.5pt; line-height: 1.55;
  --page-body: 271mm; } /* A4 297mm minus the 17mm + 9mm print bands */
.page-A5 .five-cert { font-size: 8.2pt; --page-body: 186mm; } /* A5 210mm minus the 15mm + 9mm bands */

/* ---- letterhead / footer (fixed bands in print) ---- */
.doc-letterhead { display: flex; align-items: center; gap: 4mm; height: 15mm; padding-bottom: 1.5mm; border-bottom: 1.2px solid #111; box-sizing: border-box; }
.lh-logo { height: 11mm; width: auto; }
.lh-text { flex: 1 1 auto; min-width: 0; }
.lh-name { font-weight: 700; font-size: 11pt; line-height: 1.2; }
.lh-line { font-size: 7.5pt; color: #333; line-height: 1.3; }
.doc-footer { height: 7mm; display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid #999; padding-top: 1mm; box-sizing: border-box; font-size: 6.5pt; color: #444; }
.doc-footer b { color: #111; }
.ft-id.is-empty { visibility: hidden; }
.page-A5 .doc-letterhead { gap: 3mm; height: 13mm; padding-bottom: 1mm; }
.page-A5 .lh-logo { height: 9.5mm; }
.page-A5 .lh-name { font-size: 9pt; line-height: 1.15; }
.page-A5 .lh-line { font-size: 6pt; line-height: 1.25; }
.page-A5 .doc-footer { font-size: 6pt; }

/* ---- generic pieces (em: they follow the paper size and the Text % control) ---- */
.doc-body { padding: 2mm 0 0; }
.title { text-align: center; font-size: 1.85em; font-weight: 700; margin: .2em 0 .35em; letter-spacing: .2px; line-height: 1.25; }
.lb { white-space: nowrap; }
.v, .mir { display: inline-block; border-bottom: 1px dotted #555; min-height: 1.3em; padding: 0 .45em; min-width: 3.5em; white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: baseline; box-sizing: border-box; }
.mir:empty { min-width: 11em; } /* no name yet: a blank to write it on */
.ln { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .6em; margin: .25em 0; }
.grow { flex: 1 1 9em; min-width: 0; }
.v-lic { min-width: 7em; text-align: center; }
.v-day { min-width: 2.6em; text-align: center; }
.v-month { min-width: 7em; text-align: center; }
.v-year { min-width: 3.8em; text-align: center; }
.v-place { min-width: 16em; text-align: center; }
.v-other { min-width: 6em; } /* short enough for the (6) hint to stay on the same line */
.tdate { display: inline-flex; align-items: baseline; gap: .45em; white-space: nowrap; }

/* the place and date, right-aligned under the title as on the official sheet */
.head-right { display: flex; flex-direction: column; align-items: flex-end; margin: 0 0 .5em; }
.head-right .ln { justify-content: flex-end; }

.part { margin-top: .35em; }
.certify .indent { padding-left: 2.2em; }
.diseases { list-style: none; margin: .1em 0 0; padding-left: 2.2em; }
.diseases li { margin: .05em 0; }
.diseases li.ln { display: flex; }
.hint { color: #333; font-size: .92em; flex: 1 1 12em; min-width: 0; } /* stays beside the (6) blank and wraps inside its own width */

/* the opinion: a bold heading, then three ruled lines the text sits on (more appear as the text grows). The rules
   are the bottom borders of a stack of line-high boxes behind the text, clipped to its height — as the field's own
   background they never printed (shell.css clears every editable field's background in print) */
.opinion { margin-top: .6em; }
.opinion > .lb { font-weight: 700; }
.ruled { position: relative; }
.rules { position: absolute; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; }
.rules > i { display: block; box-sizing: border-box; height: 2.2em; border-bottom: .25mm solid #777; }
.lines { display: block; border-bottom: none; min-height: 6.6em; line-height: 2.2em; padding: 0 .45em; min-width: 0; }

/* the physician's signature: a dotted line with the name in parentheses under it */
.sig { display: flex; align-items: flex-end; justify-content: flex-end; gap: .9em; margin: .9em 0 .3em; }
.sigbox { display: inline-flex; flex-direction: column; align-items: center; width: 17em; }
.sig-line { display: block; width: 100%; height: 2.4em; border-bottom: 1px dotted #555; }
.sig-name { font-size: .9em; margin-top: .15em; text-align: center; overflow-wrap: anywhere; }
.sig-name [data-doctor-name]:empty { display: inline-block; min-width: 11em; border-bottom: 1px dotted #777; vertical-align: baseline; }

/* the leftover page height goes here, so the footnotes sit at the page bottom (editor.js fitPage) */
.spacer { height: 0; }

/* footnotes */
.remarks { font-size: .88em; color: #222; margin-top: .6em; line-height: 1.45; }
.nt { display: flex; gap: .9em; align-items: flex-start; }
.nt-k { white-space: nowrap; font-weight: 700; }
.nt ul { list-style: none; margin: 0; padding: 0; }

/* screen-only helpers used by editor.js */
.empty { font-size: 9pt; color: #6b7280; padding: .4mm 0; display: flex; gap: 3mm; align-items: center; width: 100%; }
.notice.error { color: #b91c1c; font-size: 8pt; }

/* page skeleton: on screen the table is invisible plumbing; in print its thead/tfoot rows repeat on every page */
.doc-pages { width: 100%; border-collapse: collapse; }
.doc-pages > thead > tr > td, .doc-pages > tfoot > tr > td, .doc-pages > tbody > tr > td { padding: 0; vertical-align: top; }
.band { height: 0; }

/* ---------------- print ---------------- */
@media print {
  .doc-letterhead { position: fixed; top: 0; left: 14mm; right: 14mm; height: 15mm; padding-top: 2mm; background: #fff; }
  .doc-footer { position: fixed; bottom: 0; left: 14mm; right: 14mm; height: 7mm; background: #fff; padding-bottom: 1mm; }
  .band-top { height: 17mm; }      /* 15mm letterhead + 2mm gap — repeated by <thead> on every page */
  .band-bottom { height: 9mm; }    /* 7mm footer + 2mm gap — repeated by <tfoot> on every page */
  .page-A5 .doc-letterhead { left: 8mm; right: 8mm; height: 13mm; padding-top: 1.5mm; }
  .page-A5 .doc-footer { left: 8mm; right: 8mm; }
  .page-A5 .band-top { height: 15mm; } /* 13mm letterhead + 2mm gap */
  .doc-body { padding: 0; }
  .head-right, .ln, .sig, .remarks, .opinion { break-inside: avoid; page-break-inside: avoid; }
  .v, .mir { border-bottom-color: #444; }
  .empty, .notice { display: none !important; }
}
