/* Print styles - loaded separately to avoid Tailwind CSS parsing issues */
@media print {
  /* Hide non-essential elements */
  aside,
  nav,
  header,
  button,
  [data-print-hide="true"] {
    display: none !important;
  }

  /* Reset body and html */
  html, body {
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Main content full width */
  main {
    margin: 0 !important;
    padding: 5mm !important;
    width: 100% !important;
    max-width: none !important;
  }

  /* Table print styles - fit to page width */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto !important;
    font-size: 8px !important;
    table-layout: auto !important;
  }

  /* Ensure thead is visible and repeats on each page */
  thead {
    display: table-header-group !important;
    visibility: visible !important;
  }

  /* Ensure thead rows are visible */
  thead tr {
    display: table-row !important;
    visibility: visible !important;
    background-color: #f9fafb !important;
  }

  /* Ensure thead cells are visible - CRITICAL: reset all positioning */
  thead th {
    display: table-cell !important;
    visibility: visible !important;
    background-color: #f3f4f6 !important;
    font-weight: 600 !important;
    color: #374151 !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
  }

  tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }

  th, td {
    padding: 2px 3px !important;
    border: 1px solid #ccc !important;
    word-wrap: break-word !important;
    overflow: hidden !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
  }

  /* Reset ALL sticky positioning for print */
  .sticky,
  [class*="sticky"] {
    position: static !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
  }

  /* Reset all left-[*] classes */
  [class*="left-["] {
    left: auto !important;
  }

  /* Reset all top-[*] classes */
  [class*="top-["] {
    top: auto !important;
  }

  /* Reset z-index classes for print */
  .z-10, .z-20, .z-30, .z-40, .z-50,
  [class*="z-"] {
    z-index: auto !important;
  }

  /* Preserve background colors */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Container overflow reset */
  .overflow-auto,
  .overflow-x-auto,
  .overflow-y-auto,
  .overflow-hidden {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  /* Default page settings - fit to page width */
  @page {
    margin: 8mm;
  }

  /* Shrink to fit page width - universal scaling */
  .space-y-4 {
    transform-origin: top left !important;
  }

  /* Card styles for print */
  .shadow, .shadow-sm, .shadow-md, .shadow-lg {
    box-shadow: none !important;
  }

  /* Ensure print headers are visible */
  [data-print-mode] {
    display: block !important;
    visibility: visible !important;
  }

  /* tbody and tfoot cells also need positioning reset */
  tbody td,
  tfoot td {
    position: static !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
  }
}
