/* ==========================================================================
   INTERFAST WMS — Print
   Used when a user clicks "Štampaj". printElement() (utils.js) clones the
   target report into a fresh <div id="print-root"> appended directly to
   <body>, then calls window.print(). This file just hides every OTHER
   top-level child of body and shows #print-root — much more robust than
   trying to hide everything *except* a deeply-nested element, which was
   the earlier approach and had a real bug: hiding an element's ANCESTORS
   with display:none also hides the element itself (a hidden ancestor
   always wins over a child's own display value), so the "printable"
   report ended up hidden along with everything else — blank page.
   ========================================================================== */
@media print {
  @page{ size: A4 portrait; margin: 12mm; }

  body > *:not(#print-root){ display: none !important; }
  #print-root{ display: block !important; }
  .no-print{ display: none !important; }

  /* There's a lot of unused vertical room on the page (31 rows barely fills
     half an A4 sheet at the old sizes) — go bigger and more readable.
     table-layout:fixed + explicit column widths let us deliberately narrow
     Sati/Index/Bolovanje ukupno (short values: "8", "0,65", "5,2") so
     Datum/Dan/Status get breathing room instead. */
  #print-root{ font-size: 13px; }
  #print-root .card{ box-shadow: none; border: none; margin: 0; }
  #print-root .print-header{ padding: 0 0 8px; }
  #print-root .print-header h3{ font-size: 17px; margin: 4px 0; }
  #print-root .ph-company{ font-size: 12px; }
  #print-root .ph-meta{ font-size: 10px; }
  #print-root .card-body{ padding: 0; }
  #print-root .card-body.tight{ padding: 0; }

  #print-root table.data-table{ font-size: 12.5px; width: 100%; table-layout: fixed; }
  #print-root table.data-table th,
  #print-root table.data-table td{ padding: 4px 6px; line-height: 1.35; }
  #print-root table.data-table thead th{
    background: transparent !important; -webkit-print-color-adjust: exact;
    border-bottom: 1px solid #000; white-space: normal; vertical-align: bottom;
  }
  #print-root table.worker-report-table th:nth-child(1), #print-root table.worker-report-table td:nth-child(1){ width: 14%; }
  #print-root table.worker-report-table th:nth-child(2), #print-root table.worker-report-table td:nth-child(2){ width: 10%; }
  #print-root table.worker-report-table th:nth-child(3), #print-root table.worker-report-table td:nth-child(3){ width: 20%; }
  #print-root table.worker-report-table th:nth-child(4), #print-root table.worker-report-table td:nth-child(4){ width: 18%; }
  #print-root table.worker-report-table th:nth-child(5), #print-root table.worker-report-table td:nth-child(5){ width: 9%; }
  #print-root table.worker-report-table th:nth-child(6), #print-root table.worker-report-table td:nth-child(6){ width: 10%; }
  #print-root table.worker-report-table th:nth-child(7), #print-root table.worker-report-table td:nth-child(7){ width: 19%; }
  #print-root table.worker-report-table td.site-cell{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }

  #print-root table.data-table tbody tr.weekend-row{ background: #f2f2f2 !important; -webkit-print-color-adjust: exact; }
  #print-root table.data-table tfoot td{ background: transparent !important; border-top: 1px solid #000; }
  #print-root table.data-table tfoot tr.kumulativni-row td{ font-size: 11px; }
  #print-root table.data-table tfoot tr.grand-total-row td{ background: transparent !important; border-top: 2px solid #000; font-size: 15px; }
  #print-root p.muted{ font-size: 10px; margin-top: 6px !important; }

  /* Batch print: one worker report per page (used by "Štampaj sve radnike pojedinačno") */
  #print-root .print-page-break{ page-break-before: always; break-before: page; }
  #print-root .worker-report-table + p.muted{ margin-bottom: 4px; }

  /* Site summary report (used by "Štampaj izveštaj gradilišta") — the
     worker table is explicitly allowed to spill onto extra pages (not
     required to fit one A4 sheet like the individual timesheet is); the
     header row repeats on each new page, and rows never split mid-row. */
  #print-root h4{ font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
  #print-root table.site-report-table thead{ display: table-header-group; }
  #print-root table.site-report-table tbody tr{ page-break-inside: avoid; break-inside: avoid; }
  #print-root table.site-report-table th:nth-child(1), #print-root table.site-report-table td:nth-child(1){ width: 24%; }

  /* Zbirovi u dnu svakog lista: tfoot se ponavlja na svakoj odštampanoj
     strani tabele (kao i zaglavlje), redovi zbira se ne lome. */
  #print-root table.data-table tfoot{ display: table-footer-group; }
  #print-root table.data-table tfoot tr{ page-break-inside: avoid; break-inside: avoid; }
  #print-root table.data-table tfoot tr.page-summary-row td{ font-size: 11.5px; border-top: 1px solid #000; padding-top: 5px; }
  #print-root table.list-report-table thead{ display: table-header-group; }
  #print-root table.list-report-table tbody tr{ page-break-inside: avoid; break-inside: avoid; }

  /* Rešenje o korišćenju godišnjeg odmora */
  #print-root .resenje{ font-size: 13px; line-height: 1.55; }
  #print-root table.site-report-table th:nth-child(8), #print-root table.site-report-table td:nth-child(8){ width: 14%; }
}
