/* Minimal extras beyond Tailwind */
@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  #root { padding: 0 !important; }

  /*
    Print layout strategy:
    - Keep the invoice header fixed so it repeats on every page.
    - Set @page margin to 0 to avoid double-offset issues in mobile browsers.
    - Use padding on .qc-print-body to reserve space for fixed header/footer.
  */
  @page {
    margin: 0;
  }

  /* Full-width header/footer on every printed page */
  .qc-pdf-header {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10;
    padding: 8px 20px !important;
    border-bottom: 2px solid #1d4ed8 !important;
  }

  .qc-pdf-logo { height: 44px !important; width: 44px !important; }

  .qc-pdf-footer {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: #1d4ed8; /* blue-700 */
    color: #fff;
    z-index: 10;
    padding: 6px 20px !important;
  }

  /* Ensure invoice body starts AFTER the fixed header (prevents overlap)
     Reduced padding-top to remove gap. */
  .qc-print-body {
    padding-top: 90px !important;
    padding-bottom: 40px !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    font-size: 10px !important;
  }

  /* Mobile/tablet print engines: header is taller due to stacked layout */
  @media (max-width: 1024px) {
    .qc-print-body { padding-top: 110px !important; }
  }

  /* Print-only invoice heading should appear AFTER the header */
  .qc-invoice-heading {
    margin-top: 0 !important;
    margin-bottom: 6px !important;
  }

  /* Items table should fit page width in print */
  .qc-items-table-wrap { overflow: visible !important; }
  .qc-items-table { min-width: 0 !important; table-layout: auto !important; width: 100% !important; }
  .qc-items-table th,
  .qc-items-table td {
    word-break: break-word;
    padding: 3px 5px !important;
    font-size: 9px !important;
    border-bottom-width: 1px !important;
    border-color: #e2e8f0 !important;
  }

  /* Avoid breaking tables awkwardly */
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* Compact totals card in print */
  [aria-label="Totals"] {
    padding: 6px !important;
    margin-top: 6px !important;
    border-radius: 8px !important;
  }
  [aria-label="Totals"] h2 { display: none; }
  [aria-label="Totals"] .mt-3 { margin-top: 0 !important; }
  [aria-label="Totals"] .text-sm { font-size: 9px !important; }
  [aria-label="Totals"] .text-base { font-size: 10px !important; }
  [aria-label="Totals"] .mt-4 { display: none !important; } /* Hide the tip in print */
}

:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.9);
  outline-offset: 2px;
}

/* Mobile polish */
html, body { overflow-x: hidden; }

/* Ensure content isn't hidden behind the mobile footer nav */
@media (max-width: 767px) {
  body { padding-bottom: 80px; }
}
