/* =========================================================================
   slips.css — Annex H of PC 2024-0013: the eKAS and the ePresS.

   LIFTED from truemed-yakap `public/css/slips.css` (D-079): the geometry IS the port. Sizes are
   in POINTS on purpose — one US-Letter LANDSCAPE sheet carries two ~337 × 515 pt slips side by
   side with a dashed cut line between them, and each slip also prints alone on a portrait page,
   so what the screen shows and what the printer lays down are the same object.

   What did NOT come across is OLD's Exam Summary sheet: it is the clinic's own artifact, not an
   Annex-H document, and PLAN §Phase 8 owns the two slips only.
   ========================================================================= */

:root {
  --slip-cond: "Franklin Gothic Medium Cond", "Arial Narrow", "Helvetica Neue Condensed",
    "Liberation Sans Narrow", Arial, sans-serif;
  --slip-serif: Georgia, "Times New Roman", "Nimbus Roman", serif;
  --slip-ink: #14181f;
  --slip-w: 337pt;
  --slip-h: 515pt;
}

.slips .sheet-scroll { overflow-x: auto; overflow-y: hidden; padding: 2px 0 30px; }

.annex-sheet {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 11pt; width: max-content; min-width: 100%; margin: 0 auto;
}
.annex-sheet.one { gap: 0; }

.sheet-col { display: block; }

/* the little no-print toolbar that sits over each slip */
.panel-tools {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.panel-tools .pt-name {
  font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin-right: 2px;
}

/* the dashed cut line, with the scissors at the bottom */
.sheet-cut {
  position: relative; align-self: stretch; width: 11pt; min-height: var(--slip-h);
  margin-top: 30px;   /* clears the panel toolbar so the line starts at the paper */
}
.sheet-cut::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  border-left: 1px dashed #9aa2ae;
}
.sheet-cut .cut-glyph {
  position: absolute; bottom: 8pt; left: 50%; transform: translateX(-50%);
  font-size: 11pt; line-height: 1; color: #6b7482; background: var(--bg, #fff); padding: 2pt 0;
}

/* ---- the paper ---- */
.aslip-wrap {
  position: relative; width: var(--slip-w); min-height: var(--slip-h);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: 0 18px 44px rgba(23, 28, 38, .14), 0 2px 8px rgba(23, 28, 38, .06);
  overflow: hidden;
}

.aslip {
  display: block; width: 100%; min-height: var(--slip-h);
  box-sizing: border-box; padding: 10pt 11pt 9pt;
  color: var(--slip-ink); background: #fff;
  font-family: var(--slip-cond); font-size: 6pt; line-height: 1.25;
  letter-spacing: -.005em;
}

/* ---- masthead ----
   PhilHealth's own artwork out of the Annex-H PDF (D-086), at the size and place the template
   sets it: 87 × 32 pt in the top-left corner of a ≈337 pt slip. The wordmark and the italic
   `Your Partner in Health` tagline live INSIDE the image — the template sets them as one mark,
   so the slip no longer re-letters either of them. */
.aslip-head { display: flex; align-items: center; gap: 7pt; padding-bottom: 5pt; }
.ph-mark { display: flex; align-items: center; flex: none; }
.ph-logo {
  display: block; width: 87pt; height: 32pt; object-fit: contain; object-position: left center;
}
.aslip-title {
  flex: 1; min-width: 0; text-align: right;
  font-family: var(--slip-serif); font-size: 8pt; font-weight: 700;
  letter-spacing: .01em; line-height: 1.2;
}

/* ---- the two banners ---- */
.aslip-banner {
  border: 1px solid var(--slip-ink); border-left: 0; border-right: 0;
  padding: 2.5pt 0; margin-bottom: 4pt;
  font-size: 6.2pt; font-weight: 700; text-align: center; letter-spacing: .01em;
}

/* ---- the facility grid ---- */
.fgrid { border: 1px solid var(--slip-ink); border-bottom: 0; margin-bottom: 5pt; }
.frow { display: grid; gap: 0; border-bottom: 1px solid var(--slip-ink); }
.frow.c2 { grid-template-columns: 1fr 1fr; }
.frow.c3 { grid-template-columns: 1.5fr 1fr 1fr; }
.frow.c3.mrow { grid-template-columns: 1.1fr 1.3fr 1fr; }
/* row 1 reads HCI NAME · Case No. / HCI Accrediation No. · Transaction No. */
.frow.quad { grid-template-columns: 1.45fr 1fr; }

.fc {
  min-width: 0; padding: 2pt 3pt 2.5pt; border-right: 1px solid var(--slip-ink);
  display: block;
}
.fc:last-child { border-right: 0; }
.frow.quad .fc:nth-child(1), .frow.quad .fc:nth-child(2) { border-bottom: 1px solid var(--slip-ink); }

.fc .fk {
  display: block; font-size: 4.9pt; font-weight: 700; line-height: 1.15;
  color: #3f474f; letter-spacing: 0;
}
.fc .fv {
  display: block; font-size: 6.4pt; font-weight: 700; line-height: 1.25;
  min-height: 8pt; padding-top: 1.5pt; overflow-wrap: anywhere;
}
.fc .fv:empty::before { content: "\00a0"; }

/* ☐ / ✔ + caption */
.tk { display: inline-flex; align-items: center; gap: 2pt; margin-right: 7pt; white-space: nowrap; }
.tkb {
  font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", var(--slip-cond), sans-serif;
  font-size: 7pt; line-height: 1;
}
.tkb.on { font-weight: 900; }
.tkl { font-size: 5.8pt; font-weight: 700; letter-spacing: .02em; }
/* the ePresS stacks MEMBER over DEPENDENT; the eKAS keeps them side by side */
.fc.mtype.stacked .fv.boxes { display: flex; flex-direction: column; gap: 1pt; }
.fc.mtype.stacked .tk { margin-right: 0; }

/* ---- the 13 Konsulta services ----
   The app theme styles bare <th>/<td> for its own data tables (uppercase headers, a hairline
   under every row, no border on the last one). A form is not a data table: everything the theme
   does is undone here, so the printed labels are the template's own words. */
.ktbl { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 4pt; }
.ktbl th, .ktbl td {
  border: 1px solid var(--slip-ink); padding: 1.3pt 3pt; vertical-align: middle;
  overflow-wrap: anywhere; color: var(--slip-ink); background: none;
}
.ktbl tr:last-child td { border-bottom: 1px solid var(--slip-ink); }
.ktbl th {
  font-size: 5.4pt; font-weight: 700; text-align: center; line-height: 1.15;
  text-transform: none; letter-spacing: 0;
}
.ktbl th .legend { display: block; font-size: 4.4pt; font-weight: 700; letter-spacing: .12em; }
.ktbl th.c-svc { text-align: left; }
.ktbl td { font-size: 5.6pt; font-weight: 700; height: 12pt; }
.ktbl .c-svc { width: 47%; text-align: left; }
.ktbl .c-perf { width: 13%; text-align: center; }
.ktbl .c-date { width: 19%; text-align: center; }
.ktbl .c-by { width: 21%; }
.ktbl .svc-sub { font-size: 4.6pt; font-weight: 700; color: #3f474f; }
.ktbl .mk { font-size: 6.6pt; font-weight: 900; }

.aslip-note { font-size: 5.4pt; font-weight: 700; padding: 1pt 0 3pt; }
.aslip-note.orphan-note { padding-bottom: 0; }
.orphan-note { font-weight: 700; }

/* ---- the tear line ---- */
.tear { position: relative; height: 9pt; margin: 1pt 0 3pt; }
.tear::before {
  content: ""; position: absolute; top: 50%; left: 0; right: 0; border-top: 1px dashed #6b7482;
}
.tear .tear-cut {
  position: absolute; top: 50%; left: 8pt; transform: translateY(-50%);
  background: #fff; padding: 0 2pt; font-size: 7.5pt; line-height: 1; color: #4c5563;
}

/* ---- the member's half ---- */
.reply { display: block; }
.reply .q { margin-bottom: 3.5pt; }
.reply .q-en { font-size: 6pt; font-weight: 700; }
.reply .q-tl { font-size: 5.4pt; font-style: italic; color: #3f474f; }
.reply .q-ans { margin-top: 1.5pt; }
.reply .yn { font-size: 6pt; font-weight: 700; margin-right: 14pt; }

.reply .faces { display: flex; gap: 16pt; margin-top: 2.5pt; padding-left: 6pt; }
.fc-face { display: inline-flex; align-items: center; gap: 3pt; }
.fc-face .face { width: 13pt; height: 13pt; color: var(--slip-ink); }
.fc-face .fc-cap { font-size: 5.4pt; font-weight: 700; letter-spacing: .04em; }

.reply .comment .wline { border-bottom: 1px solid var(--slip-ink); height: 9pt; margin-top: 2pt; }

.reply-foot { margin-top: 3pt; }
.reply-foot .foot-note { font-size: 5.2pt; font-weight: 700; line-height: 1.3; }
.reply-foot .orphan-note { font-size: 5.6pt; font-weight: 700; }
.pin-line { display: flex; align-items: flex-end; gap: 4pt; margin-top: 4pt; }
.pin-line .k { font-size: 5.6pt; font-weight: 700; white-space: nowrap; }
.pin-line .rule { flex: 1; border-bottom: 1px solid var(--slip-ink); height: 8pt; }

/* ---- ePresS: one open Rx box, no medicines table ---- */
.rxbox {
  border: 1px solid var(--slip-ink); padding: 5pt 6pt 5pt; margin-bottom: 3pt;
  min-height: 150pt; display: flex; flex-direction: column;
}
.rx-top { display: flex; align-items: flex-start; gap: 6pt; }
.rx-glyph {
  font-family: var(--slip-serif); font-size: 22pt; font-weight: 700; line-height: .9; flex: none;
}
.rx-generic {
  flex: 1; text-align: center; font-size: 7.5pt; font-weight: 700; letter-spacing: .06em;
  padding-top: 4pt;
}
.rx-lines { flex: 1; padding: 6pt 2pt 4pt 26pt; }
.rx-line { font-size: 6.4pt; font-weight: 700; line-height: 1.6; overflow-wrap: anywhere; }

.rx-foot { display: flex; align-items: flex-end; gap: 10pt; margin-top: 6pt; }
.rx-next { flex: 1; min-width: 0; }
.rx-next .k { font-size: 5.8pt; font-weight: 700; }
.rx-next .rule { display: block; border-bottom: 1px solid var(--slip-ink); height: 8pt; margin: 1pt 0; }
.rx-next .tl { font-size: 5pt; font-style: italic; color: #3f474f; }

.rx-doc { flex: none; width: 138pt; }
.rx-doc .dl { display: flex; align-items: flex-end; gap: 3pt; margin-top: 3pt; }
.rx-doc .dl .k { font-size: 5.6pt; font-weight: 700; text-align: right; width: 46pt; flex: none; }
.rx-doc .dl .rule {
  flex: 1; min-width: 0; border-bottom: 1px solid var(--slip-ink); height: 9pt;
  font-size: 5.8pt; font-weight: 700; text-align: center; overflow: hidden; white-space: nowrap;
}

/* ---- DRAFT watermark: an unfinalized encounter, on screen and on paper ---- */
.aslip-wrap.draft::after {
  content: attr(data-draft); position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 72pt; font-weight: 900; letter-spacing: .1em; color: rgba(229, 96, 59, .14);
  transform: rotate(-24deg);
}

@media (max-width: 880px) {
  .annex-sheet { justify-content: flex-start; }
}

/* =========================================================================
   PRINT

   The @page size itself is written by slips.js right before the dialog opens (landscape for
   the sheet, portrait for a single slip) — a page rule cannot be switched by a body class.
   Everything else is here.
   ========================================================================= */
@media print {
  /* A slip is a form on white paper. The app's own page tint is chrome, and an SSVT evidence
     PDF that carries a grey band down one side of PhilHealth's artwork looks like a defect. */
  body, .app, main, .slips { background: #fff !important; }
  .slips .topbar, .slips .note, .panel-tools, .no-print { display: none !important; }
  .slips .sheet-scroll { overflow: visible !important; padding: 0 !important; }
  .annex-sheet { width: auto !important; min-width: 0 !important; gap: 11pt; }

  /* NATIVE print (Cmd/Ctrl+P — no slip-printing class, so theme.css's default page applies):
     the fixed two-slip sheet is ~696pt wide against ~527pt of printable width and the flex items
     cannot shrink, so without help the ePresS half clips off the page. Scale the whole sheet to
     fit; the in-page buttons (which set the proper Letter-landscape @page) print at full size. */
  body:not(.slip-printing) .annex-sheet:not(.one) {
    transform: scale(0.74);
    transform-origin: top left;
  }

  .aslip-wrap {
    border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .aslip { color: #000 !important; }
  .aslip .fk, .aslip .q-tl, .aslip .svc-sub, .aslip .rx-next .tl { color: #222 !important; }
  /* The masthead is PhilHealth's own colour artwork (D-086). Browsers drop background graphics
     from a print by default, and a viewer that also strips foreground images would hand the SSVT
     an eKAS with an empty corner — so the mark is asked for explicitly, on both spellings. */
  .aslip .ph-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-cut { margin-top: 0 !important; }
  .sheet-cut .cut-glyph { background: #fff !important; }

  /* one slip on its own page: the other half and the cut line come off */
  body.slip-print-ekas .sheet-col[data-col="epress"],
  body.slip-print-ekas .sheet-cut,
  body.slip-print-epress .sheet-col[data-col="ekas"],
  body.slip-print-epress .sheet-cut { display: none !important; }
  body.slip-printing .card { display: none !important; }
}
