/* ============================================================
   Optix Blood Bank — print.css
   Print styles for blood issue receipts (.rcpt) and reports
   (.rpt), plus standalone print-window styling.

   Scope: this file may affect PRINT rendering only.
   It must NOT change any screen styles — every rule lives
   inside @media print, an @page block, or targets the
   standalone print-window documents (.rcpt / .rpt / body.print-doc).

   Notes:
   - No external resources (no @import, no url() assets) so the
     stylesheet works when linked from a document.write() page
     opened via window.open().
   - B&W-friendly: white background, dark text, black hairlines.
   - Receipt HTML structure (.rcpt) is defined in js/issues.js;
     this file only styles it, never requires changing it.
   ============================================================ */

@page {
  size: A4;
  margin: 14mm 12mm 16mm 12mm;
  /* Footer with page numbers on every printed page */
  @bottom-center {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 9px;
    font-family: Arial, Helvetica, sans-serif;
    color: #555;
  }
  @bottom-right {
    content: "Powered by System Optix";
    font-size: 9px;
    font-family: Arial, Helvetica, sans-serif;
    color: #777;
  }
}

/* ---------- App-shell print rules (for in-app Ctrl+P printing) ---------- */
@media print {
  /* Hide interactive / navigational chrome */
  .bb-sidebar,
  .bb-topbar,
  .toolbar,
  .no-print,
  #toasts,
  .modal-back,
  .modal,
  button,
  .btn,
  input,
  select,
  textarea,
  nav,
  aside,
  header.bb-topbar,
  footer.app-footer {
    display: none !important;
  }

  /* Expand the main area to full width */
  .bb-main,
  main,
  .content,
  .page,
  .print-area {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 13px;
  }

  /* Remove shadows / rounding that waste ink */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
    border-radius: 0 !important;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* Repeat table headers across pages and keep rows intact */
  thead {
    display: table-header-group !important;
  }
  tfoot {
    display: table-footer-group !important;
  }
  tr {
    page-break-inside: avoid !important;
  }
  table {
    page-break-inside: auto;
    border-collapse: collapse !important;
  }
}

/* ---------- Standalone print window (document.write via window.open) ---------- */
body.print-doc {
  padding: 24px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #000;
  background: #fff;
  margin: 0;
}

/* ============================================================
   .rcpt — Blood Issue Receipt  (HTML built in js/issues.js)
   ============================================================ */
.rcpt {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #000;
  background: #fff;
  max-width: 780px;
  margin: 0 auto;
}

/* Centered letterhead */
.rcpt .rcpt-head {
  text-align: center;
  margin-bottom: 6px;
}
.rcpt .rcpt-bank-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 2px 0;
  color: #000;
}
.rcpt .rcpt-bank-sub {
  font-size: 12px;
  color: #333;
  margin: 0;
}
.rcpt .rcpt-head img {
  max-width: 240px;
  max-height: 64px;
  margin-bottom: 4px;
}
/* Thick black rule under the letterhead */
.rcpt .rcpt-rule {
  border: 0;
  border-top: 3px solid #000;
  margin: 8px 0 10px 0;
}

/* Receipt title */
.rcpt .rcpt-title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0 0 10px 0;
  color: #000;
}

/* Meta grid: receipt no / date / issued by / patient / ward */
.rcpt .rcpt-meta {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 12.5px;
}
.rcpt .rcpt-meta td {
  padding: 3px 6px;
  vertical-align: top;
}
.rcpt .rcpt-meta td.k {
  font-weight: 700;
  white-space: nowrap;
  width: 1%;
}

/* Items table with full black hairline borders */
.rcpt .rcpt-items {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 10px 0;
  font-size: 12.5px;
}
.rcpt .rcpt-items th,
.rcpt .rcpt-items td {
  border: 1px solid #000;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.rcpt .rcpt-items thead th {
  background: #f2f2f2;
  font-weight: 700;
}
.rcpt .rcpt-items td.num,
.rcpt .rcpt-items th.num {
  text-align: right;
  white-space: nowrap;
}

/* Totals block, right-aligned */
.rcpt .rcpt-totals {
  text-align: right;
  margin: 0 0 26px 0;
  font-size: 13px;
}
.rcpt .rcpt-totals .trow {
  margin: 2px 0;
}
.rcpt .rcpt-totals .grand {
  font-size: 15px;
  font-weight: 800;
  border-top: 2px solid #000;
  display: inline-block;
  padding-top: 4px;
  margin-top: 4px;
  min-width: 220px;
}

/* Signature blocks — two columns */
.rcpt .rcpt-sign {
  display: table;
  width: 100%;
  margin: 34px 0 12px 0;
  page-break-inside: avoid;
}
.rcpt .rcpt-sign .sig {
  display: table-cell;
  width: 50%;
  vertical-align: bottom;
}
.rcpt .rcpt-sign .sig .line {
  border-top: 1px solid #000;
  margin-top: 44px;
  padding-top: 4px;
  font-size: 12px;
  font-weight: 700;
}
.rcpt .rcpt-sign .sig:first-child .line {
  margin-right: 24px;
}
.rcpt .rcpt-sign .sig:last-child {
  text-align: right;
}
.rcpt .rcpt-sign .sig:last-child .line {
  margin-left: 24px;
}

/* Footer note — small gray */
.rcpt .rcpt-foot {
  font-size: 10.5px;
  color: #666;
  text-align: center;
  margin-top: 10px;
  border-top: 1px solid #999;
  padding-top: 8px;
}

/* ============================================================
   .rpt — Report document  (HTML built in js/reports.js)
   ============================================================ */
.rpt {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #000;
  background: #fff;
  max-width: 1000px;
  margin: 0 auto;
}

/* Letterhead */
.rpt .rpt-head {
  text-align: center;
  margin-bottom: 6px;
}
.rpt .rpt-bank,
.rpt .rpt-bank-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 2px 0;
  color: #000;
}
.rpt .rpt-sub,
.rpt .rpt-bank-sub {
  font-size: 12px;
  color: #333;
  margin: 0;
}
.rpt .rpt-rule {
  border: 0;
  border-top: 2px solid #000;
  margin: 8px 0 10px 0;
}

/* Report title + generated/filter meta line */
.rpt .rpt-title {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin: 0 0 4px 0;
  color: #000;
}
.rpt .rpt-gen,
.rpt .rpt-meta {
  text-align: center;
  font-size: 11.5px;
  color: #333;
  margin: 0 0 12px 0;
}
.rpt .rpt-meta .f {
  display: inline-block;
  margin: 0 8px;
}
.rpt .rpt-section {
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 6px 0;
  page-break-after: avoid;
}

/* Tables with black hairline borders; thead repeats; rows never split.
   Printed tables come from js/reports.js with class "tbl". */
.rpt table.rpt-table,
.rpt table.tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 14px 0;
  font-size: 12.5px;
  page-break-inside: auto;
}
.rpt .rpt-table th,
.rpt .rpt-table td,
.rpt .tbl th,
.rpt .tbl td {
  border: 1px solid #000;
  padding: 5px 7px;
  text-align: left;
  vertical-align: top;
}
.rpt .rpt-table thead,
.rpt .tbl thead {
  display: table-header-group;
}
.rpt .rpt-table thead th,
.rpt .tbl thead th {
  background: #f2f2f2;
  font-weight: 700;
  page-break-inside: avoid;
}
.rpt .rpt-table tr,
.rpt .tbl tr {
  page-break-inside: avoid;
}
.rpt .rpt-table td.num,
.rpt .rpt-table th.num,
.rpt .tbl td.num,
.rpt .tbl th.num {
  text-align: right;
  white-space: nowrap;
}
.rpt .rpt-table td.c,
.rpt .rpt-table th.c,
.rpt .tbl td.c,
.rpt .tbl th.c {
  text-align: center;
}
.rpt .rpt-table tfoot,
.rpt .tbl tfoot {
  display: table-footer-group;
}
.rpt .rpt-table tfoot td,
.rpt .tbl tfoot td {
  font-weight: 700;
  background: #fafafa;
}

/* Keep related blocks together */
.rpt .rpt-group,
.rpt .rpt-summary {
  page-break-inside: avoid;
}

/* Report footer (in-flow note; page numbers come from @page) */
.rpt .rpt-foot {
  font-size: 10.5px;
  color: #666;
  text-align: center;
  margin-top: 12px;
  border-top: 1px solid #999;
  padding-top: 8px;
}

/* ============================================================
   Small generic print helpers (shared by .rcpt / .rpt docs)
   ============================================================ */
.pb-before { page-break-before: always; }
.pb-avoid  { page-break-inside: avoid; }

@media print {
  .pb-before { page-break-before: always !important; }
  .pb-avoid  { page-break-inside: avoid !important; }
}
