/* DentaPlan PDF layouts (VORAAA-7): HKP data sheet, cost agreement, consent form.
 * A4 portrait, black-and-white safe (colour is only an accent). Needs tokens.css.
 * The same HTML is shown as a preview on screen (class .pdf on <body>) and printed
 * to PDF. Spec with the page anatomy: docs/design/pdf-layouts.md
 */
@page { size: A4; margin: var(--pdf-margin-top) var(--pdf-margin-side) var(--pdf-margin-bottom); }
@page { @bottom-left { content: element(pdf-foot); } @bottom-right { content: "Seite " counter(page) " von " counter(pages); font: 7.5pt var(--font); color: #555; } }

body.pdf { margin: 0; background: #e9eef0; font-family: var(--font); font-size: var(--pdf-fs); line-height: 1.38; color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdf .page { width: 210mm; min-height: 297mm; margin: 12px auto; padding: var(--pdf-margin-top) var(--pdf-margin-side) var(--pdf-margin-bottom); background: #fff; box-shadow: var(--shadow); position: relative; }
.pdf h1 { font-size: var(--pdf-fs-h1); margin: 0 0 1mm; letter-spacing: -.01em; }
.pdf h2 { font-size: var(--pdf-fs-h2); margin: 5mm 0 2mm; padding-bottom: 1mm; border-bottom: .4mm solid var(--accent); }
.pdf h3 { font-size: var(--pdf-fs); margin: 3mm 0 1mm; }
.pdf p { margin: 0 0 2mm; }
.pdf .sm { font-size: var(--pdf-fs-sm); color: #444; }

/* header: practice block left, document block right, accent rule below */
.pdf-head { display: grid; grid-template-columns: 1fr auto; gap: 6mm; padding-bottom: 3mm; border-bottom: .6mm solid var(--accent); margin-bottom: 4mm; }
.pdf-head .practice { font-size: var(--pdf-fs-sm); line-height: 1.35; }
.pdf-head .practice b { font-size: 10.5pt; display: block; }
.pdf-head .docmeta { text-align: right; font-size: var(--pdf-fs-sm); }
.pdf-head .docmeta b { display: block; font-size: var(--pdf-fs-h2); color: var(--accent-700); }

/* key/value grid for patient + insurance data */
.pdf .kv { display: grid; grid-template-columns: 34mm 1fr 34mm 1fr; gap: 1.2mm 3mm; font-size: var(--pdf-fs-sm); }
.pdf .kv dt { color: #555; }
.pdf .kv dd { margin: 0; font-weight: 600; }

/* boxes */
.pdf .box { border: .3mm solid var(--pdf-line); border-radius: 1.5mm; padding: 2.5mm 3mm; margin: 2mm 0; break-inside: avoid; }
.pdf .box.fill { background: var(--pdf-fill); border-color: var(--pdf-fill); }
.pdf .box.accent { border-color: var(--accent); }

/* tables */
.pdf table { width: 100%; border-collapse: collapse; font-size: var(--pdf-fs-sm); }
.pdf th { text-align: left; font-weight: 700; border-bottom: .4mm solid #333; padding: 1.2mm 1.5mm 1.2mm 0; }
.pdf td { border-bottom: .2mm solid var(--pdf-line); padding: 1.1mm 1.5mm 1.1mm 0; vertical-align: top; }
.pdf td.r, .pdf th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; padding-left: 3mm; } /* gap between adjacent right-aligned columns (VORAAA-41) */
.pdf tr.sum td { border-bottom: 0; border-top: .4mm solid #333; font-weight: 700; }
.pdf tr.grand td { font-size: 10.5pt; font-weight: 800; border-top: .6mm double #333; }
.pdf thead { display: table-header-group; } /* repeat on page break */
.pdf tr { break-inside: avoid; }

/* tooth chart on paper: 16 columns per jaw, rows TP / R / B above, B / R / TP below */
.pdf .hkp-chart { table-layout: fixed; font-size: 7.5pt; text-align: center; margin: 2mm 0; }
.pdf .hkp-chart th, .pdf .hkp-chart td { border: .2mm solid var(--pdf-line); padding: .8mm 0; text-align: center; height: 5.2mm; }
.pdf .hkp-chart th:first-child, .pdf .hkp-chart td:first-child { width: 9mm; font-weight: 700; background: var(--pdf-fill); }
.pdf .hkp-chart .no { font-weight: 700; background: var(--pdf-fill); }
.pdf .hkp-chart .mid { border-left: .6mm solid #333; }
.pdf .hkp-chart .bridge { box-shadow: inset 0 -.8mm 0 #333; }  /* bridge span: bar under B row */
.pdf .hkp-chart .saddle { box-shadow: inset 0 -.8mm 0 #c77; }  /* removable denture saddle */

/* amounts summary (the patient share is the one number that stands out) */
.pdf .totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2mm; margin: 3mm 0; }
.pdf .totals div { border: .3mm solid var(--pdf-line); border-radius: 1.5mm; padding: 2mm 3mm; }
.pdf .totals small { display: block; font-size: 7.5pt; color: #555; }
.pdf .totals b { font-size: 12pt; font-variant-numeric: tabular-nums; }
.pdf .totals .me { border: .5mm solid var(--accent); }
.pdf .totals .me b { color: var(--accent-700); }

/* checkboxes printed as squares, ticked when chosen */
.pdf .cb { display: flex; gap: 2mm; align-items: flex-start; margin: 1.2mm 0; }
.pdf .cb i { flex: none; width: 3.6mm; height: 3.6mm; border: .3mm solid #333; border-radius: .5mm; margin-top: .4mm; position: relative; }
.pdf .cb.on i::after { content: ""; position: absolute; left: .9mm; top: .1mm; width: 1.2mm; height: 2.2mm; border: solid #111; border-width: 0 .5mm .5mm 0; transform: rotate(45deg); }

/* illustrations (consent form): small before/after pair */
.pdf .ill { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; margin: 2mm 0; }
.pdf .ill figure { margin: 0; }
.pdf .ill img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 1.5mm; background: var(--ill-bg); }
.pdf .ill figcaption { font-size: 7.5pt; color: #555; margin-top: .8mm; }

/* signatures: always at the end, never split from the declaration above */
.pdf .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; margin-top: 8mm; break-inside: avoid; }
.pdf .sig { min-height: 22mm; display: flex; flex-direction: column; justify-content: flex-end; }
.pdf .sig img { height: 16mm; object-fit: contain; object-position: left bottom; }
.pdf .sig .line { border-top: .3mm solid #111; padding-top: 1mm; font-size: 7.5pt; color: #444; }
.pdf .sig .stamp { font-size: 7pt; color: #555; }
.pdf .keep { break-inside: avoid; }
.pdf .pagebreak { break-before: page; }

/* footer: running element on each page (practice line + document id) */
.pdf-foot { position: running(pdf-foot); font-size: 7.5pt; color: #555; }
.pdf .page > .pdf-foot { position: absolute; left: var(--pdf-margin-side); right: var(--pdf-margin-side); bottom: 8mm; display: flex; justify-content: space-between; border-top: .2mm solid var(--pdf-line); padding-top: 1.5mm; }

@media print {
  body.pdf { background: #fff; }
  .pdf .page { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .pdf .page + .page { break-before: page; }
  .pdf .page > .pdf-foot { position: static; }
}

/* production additions (VORAAA-9): two-column blocks, list of pros/cons, notes */
.pdf .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; }
.pdf .cols ul { margin: 0; padding-left: 4mm; }
.pdf .facts-t th { width: 32mm; font-weight: 600; border-bottom: .2mm solid var(--pdf-line); }
.pdf .note { font-size: var(--pdf-fs-sm); color: #444; }
.pdf .qbox { min-height: 25mm; white-space: pre-wrap; }
.pdf .warn { color: #8a4b00; }
.pdf .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 7.5pt; }

/* "Herleitung" annex of the HKP overview (VORAAA-36) */
.pdf .hl-block { break-inside: avoid; margin: 0 0 3mm; border-left: 0.6mm solid #b9c6cc; padding-left: 2.5mm; }
.pdf .hl-block h4 { margin: 0 0 0.6mm; font-size: var(--pdf-fs); }
.pdf ol.hl-steps { margin: 0.8mm 0 0; padding-left: 5mm; }
.pdf ol.hl-steps li { margin: 0 0 1.2mm; }
.pdf .hl-badge { display: inline-block; font-size: 7pt; font-weight: 700; padding: 0 1.2mm; border-radius: 1mm; margin-right: 1mm; vertical-align: 0.3mm; }
.pdf .hl-badge.n { background: #e3eef3; color: #0d4b63; }
.pdf .hl-badge.d { background: #fdf0d9; color: #7a4a00; }
.pdf .hl-badge.amb { background: #fde3e0; color: #8b1d12; }
.pdf .hl-ref { display: block; font-size: var(--pdf-fs-sm); color: #333; margin-top: 0.4mm; }
.pdf .hl-ref q { font-style: italic; color: #555; }
.pdf .hl-ref a { color: #0d4b63; word-break: break-all; }
.pdf .hl-hash { font-family: ui-monospace, monospace; font-size: 6.5pt; word-break: break-all; color: #444; }
.pdf table.hl-data td { font-size: var(--pdf-fs-sm); padding: 0.6mm 1mm; }
