/* ================================================================
   receipt.css — Receipt preview layout
   This file controls BOTH the on-screen receipt and the PDF output.
   Any change here must render correctly in both contexts.

   NON-NEGOTIABLE CONSTRAINTS:
   - #receipt-preview width is fixed at 595px (A4 at 72dpi)
   - Font must remain system-ui (no web fonts — required for PDF rendering)
   - Do not change any element ids
   - Do not use CSS variables that rely on browser theme (PDF renderer ignores them)
   ================================================================ */

/* ── Receipt preview panel — frames the white receipt ─────────── */
.receipt-preview-panel {
  overflow-x: auto;
  padding: 0;
}

/* Dark-canvas framing for the white receipt document */
#receipt-preview {
  width: 595px;               /* A4 width at 72dpi — do not change */
  min-height: 842px;          /* A4 height at 72dpi */
  padding: 40px;
  background: #ffffff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #000000;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow:
    0 0 0 1px rgba(60, 255, 208, 0.15),
    0 4px 24px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

/* Light mode: subtler shadow, no mint glow */
[data-theme="light"] #receipt-preview {
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* ── Receipt header ──────────────────────────────────────────── */
.receipt-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
}

.receipt-header__logo {
  flex-shrink: 0;
}

.receipt-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.receipt-header__clinic {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.receipt-clinic-name {
  font-weight: 700;
  font-size: 15px;
}

.receipt-clinic-name-zh {
  font-weight: 600;
  font-size: 13px;
}

.receipt-clinic-address {
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-line;
}

.receipt-clinic-contact {
  font-size: 11px;
  margin-top: 4px;
}

.receipt-header__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.receipt-doc-title {
  font-weight: 700;
  font-size: 15px;
}

.receipt-number-display {
  font-size: 12px;
  font-weight: 600;
}

.receipt-date-display {
  font-size: 12px;
}

/* ── Divider ─────────────────────────────────────────────────── */
.receipt-divider {
  height: 1px;
  background: #000000;
  margin: 16px 0;
}

/* ── Patient section ─────────────────────────────────────────── */
.receipt-patient-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.receipt-field-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: baseline;
}

.receipt-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.receipt-field-value {
  font-size: 13px;
}

/* ── Service table ───────────────────────────────────────────── */
.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.receipt-table thead tr {
  border-bottom: 1px solid #000;
}

.receipt-table th {
  padding: 6px 8px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}

.receipt-table td {
  padding: 8px;
  vertical-align: top;
}

.receipt-table__col-service  { width: 38%; }
.receipt-table__col-date     { width: 22%; }
.receipt-table__col-qty      { width: 12%; text-align: center; white-space: nowrap; }
.receipt-table__col-amount   { width: 28%; text-align: right; }

.receipt-table th:last-child,
.receipt-table td:last-child {
  text-align: right;
}

.receipt-table th:nth-child(3),
.receipt-table td:nth-child(3) {
  text-align: center;
}

.receipt-table tfoot tr {
  border-top: 1px solid #000;
}

.receipt-table__total-label {
  font-weight: 700;
  font-size: 13px;
  text-align: right;
  padding: 8px;
}

.receipt-table__total-value {
  font-weight: 700;
  font-size: 15px;
  text-align: right;
  padding: 8px;
}

/* ── Practitioner section ────────────────────────────────────── */
.receipt-practitioner {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-top: 8px;
}

.receipt-practitioner__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.receipt-signature-img {
  max-height: 60px;
  width: auto;
  object-fit: contain;
}

.receipt-practitioner__name {
  font-weight: 700;
  font-size: 13px;
}

.receipt-practitioner__title {
  font-size: 12px;
}

.receipt-practitioner__reg {
  font-size: 11px;
  opacity: 0.7;
}

/* Signature line — shown when digital signature is hidden, provides blank space for physical signing */
.receipt-signature-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 160px;
}

.receipt-signature-line__space {
  height: 48px;
}

.receipt-signature-line__rule {
  width: 100%;
  height: 1px;
  background: #000000;
}

.receipt-signature-line__label {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.6;
}

/* Signature position variants (applied via JS from settings) */
.receipt-practitioner.sig-pos-next {
  flex-direction: row;
  align-items: flex-end;
}

.receipt-practitioner.sig-pos-above {
  flex-direction: column-reverse;
  align-items: flex-start;
}

.receipt-practitioner.sig-pos-below {
  flex-direction: column;
  align-items: flex-start;
}
