/* ==========================================================================
   BioTrack Pro — Print (application-level)

   This file governs printing the APPLICATION window (Ctrl+P on a screen).
   It hides all interactive chrome and prints the content region only.

   Documents with their own page geometry — receipt (A5/80mm), pathology
   report (A4), barcode label (50x25mm), transfer manifest (A4) — are NOT
   printed from here. They are rendered into a dedicated print window by
   js/print/printer.js with their own stylesheet from css/print/, because
   incompatible @page rules cannot coexist in one document.
   ========================================================================== */

@media print {
  /* ---------- Page geometry ------------------------------------------- */
  @page {
    size: A4 portrait;
    margin: 14mm 12mm;
  }

  /* ---------- Reset the shell ------------------------------------------ */
  html,
  body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 10pt;
  }

  .app,
  .app[data-sidebar="collapsed"] {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    grid-template-columns: none !important;
  }

  .main {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .content {
    overflow: visible !important;
    height: auto !important;
  }

  .view {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ---------- Hide interactive chrome ---------------------------------- */
  .sidebar,
  .header,
  .scrim,
  .toast-root,
  .modal-root,
  .palette-root,
  .side-panel,
  .storage-banner,
  .btn,
  .icon-btn,
  .btn-group,
  .dropdown,
  .pagination,
  .table-toolbar,
  .table-selection,
  .filter-bar,
  .page-header__actions,
  .card__actions,
  .form-actions,
  .tabs,
  .quick-actions,
  .settings-nav,
  .col-actions,
  .col-check,
  .cell-actions,
  [data-print="hide"] {
    display: none !important;
  }

  /* ---------- Reveal print-only content -------------------------------- */
  .print-only { display: block !important; }
  .screen-only { display: none !important; }

  /* ---------- Flatten decoration ---------------------------------------- */
  .card,
  .stat,
  .table-wrap,
  .modal {
    box-shadow: none !important;
    border-color: #ccc !important;
    background: #fff !important;
    break-inside: avoid;
  }

  .card { border-radius: 0 !important; }

  /* ---------- Typography ------------------------------------------------ */
  .page-header__title { font-size: 16pt; }
  .h1 { font-size: 15pt; }
  .h2 { font-size: 13pt; }
  .h3 { font-size: 11pt; }

  h1, h2, h3, .card__title, .section__title {
    break-after: avoid;
    color: #000 !important;
  }

  p, li { orphans: 3; widows: 3; }

  /* ---------- Tables ----------------------------------------------------- */
  .table-wrap { overflow: visible !important; }

  .table { width: 100% !important; font-size: 9pt; }

  .table thead { display: table-header-group; }
  .table tfoot { display: table-footer-group; }
  .table tr { break-inside: avoid; }

  .table thead th {
    position: static !important;
    background: #f2f2f2 !important;
    color: #000 !important;
    border-bottom: 1px solid #999 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .table tbody td {
    border-bottom: 1px solid #ddd !important;
    color: #000 !important;
  }

  .table tbody tr:hover { background: transparent !important; }

  /* Mobile card mode must never leak into print. */
  .table-cards { display: none !important; }

  /* ---------- Badges: never colour-only in print ------------------------- */
  .badge {
    border: 1px solid #666 !important;
    background: transparent !important;
    color: #000 !important;
    padding: 0 3px !important;
  }

  .badge__dot { display: none !important; }

  .flag-mark {
    border: 1px solid #000 !important;
    background: transparent !important;
    color: #000 !important;
  }

  .flag-mark--c {
    background: #000 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ---------- Charts ------------------------------------------------------ */
  .chart-wrap canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* ---------- Links: show the target where it is meaningful --------------- */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #555;
  }

  a[href^="#"]::after { content: ""; }

  /* ---------- Utility ------------------------------------------------------ */
  .avoid-break { break-inside: avoid; }
  .break-before { break-before: page; }
  .break-after { break-after: page; }
}

/* ==========================================================================
   Print document containers (screen-side scaffolding)

   These wrappers are populated by js/print/printer.js and are never visible
   on screen — they exist so a document can be composed, measured and, if
   needed, rasterised for PDF before being handed to the print window.
   ========================================================================== */

.print-doc {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 210mm;
  background: #fff;
  color: #000;
  font-family: var(--font-sans);
}

.print-doc--a5     { width: 148mm; }
.print-doc--thermal{ width: 80mm; }
.print-doc--label  { width: 50mm; }
.print-doc--a4-landscape { width: 297mm; }
