/* print.css — @media print helpers used by the DataTableToolbar's
 * "Exportar como PDF" flow (table-tools.js#exportPDF).
 *
 * The JS toggles `body.printing-table` + `.print-target` on the exact
 * <div x-data="tableFilter(...)"> the operator clicked from. This file
 * hides everything else so the print dialog shows just that block —
 * which the user then saves as PDF via the OS-native print target
 * dropdown ("Salvar como PDF" no Chrome / "Microsoft Print to PDF" no
 * Windows, etc.).
 *
 * Standalone file (not part of the Tailwind bundle) so future rebuilds
 * of admin.css don't clobber it. Loaded by base.templ with print-only
 * media, so it costs zero bytes on screen render. */

/* body.capturing-png — sibling of @media print. Applied by
 * table-tools.js#exportPNGCapture around the html2canvas rasterisation
 * call so the snapshot always renders black-on-white regardless of the
 * current dashboard theme. Removed the moment the capture Promise
 * settles. Mirrors the visual guarantees of the @media print block but
 * scoped to on-screen rendering (html2canvas ignores @media print). */
body.capturing-png {
  background: white !important;
  color: black !important;
}
body.capturing-png * {
  background-color: transparent !important;
  background-image: none !important;
  color: black !important;
  box-shadow: none !important;
  text-shadow: none !important;
  border-color: #d0d0d0 !important;
}
body.capturing-png th,
body.capturing-png td {
  border: 1px solid #ccc !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
}
body.capturing-png thead th {
  background: #f0f0f0 !important;
  font-weight: 600 !important;
}
body.capturing-png thead th button {
  pointer-events: none !important;
  background: transparent !important;
  padding: 0 !important;
  color: inherit !important;
  border: none !important;
}
/* Sort arrow indicators look wrong in a static image — hide the
 * trailing span (matches the print convention). */
body.capturing-png thead th button > span:last-child {
  display: none !important;
}
/* Convention-driven column hide, same rule as print. */
body.capturing-png [data-noprint] {
  display: none !important;
}
body.capturing-png .toolbar-noprint {
  display: none !important;
}

@media print {
  body.printing-table > *:not(.print-target-root) {
    display: none !important;
  }

  /* Isolate the target element chain: only ancestors carrying
   * .print-target-root remain visible. The JS adds the class to the
   * $el and walks up marking parents so the flex/grid chain up to
   * <body> stays visible. */
  body.printing-table .print-target-root {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    max-height: none !important;
  }

  /* Universal loosening of every descendant of the target: without this
   * the ToolbarTable's inner div (rounded-lg overflow-auto style="max-height: calc(100vh - 260px)")
   * clips content per page — QA 14/07 saw each PDF page half-empty
   * because ~540px of table showed and the rest was force-page-broken.
   * Applied INSIDE .print-target-root so we don't smash the outer app
   * shell's layout on other paths. */
  body.printing-table .print-target-root * {
    max-height: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    position: static !important;
  }
  /* Keep tables from breaking mid-row so a bet/saldo cell doesn't split
   * across two pages, while allowing the tbody itself to split at row
   * boundaries so long tables use every printable page in full. */
  body.printing-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  body.printing-table thead {
    display: table-header-group !important; /* repeat header on each page */
  }

  body.printing-table .print-target-root .toolbar-noprint,
  body.printing-table .toolbar-noprint {
    display: none !important;
  }

  /* Print black-on-white — dashboards may be in dark mode. */
  body.printing-table {
    background: white !important;
    color: black !important;
  }
  body.printing-table * {
    background-color: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  body.printing-table th,
  body.printing-table td {
    border: 1px solid #ccc !important;
    padding: 4px 8px !important;
    font-size: 10pt !important;
  }
  body.printing-table thead th {
    background: #f0f0f0 !important;
    font-weight: 600 !important;
  }
  body.printing-table thead th button {
    pointer-events: none !important;
    background: transparent !important;
    padding: 0 !important;
    color: inherit !important;
    border: none !important;
  }
  /* Hide the sort indicator arrows in print (they'd look weird). */
  body.printing-table thead th button > span:last-child {
    display: none !important;
  }
  /* Hide filter/action columns via convention (data-noprint on the <th>/<td>). */
  body.printing-table [data-noprint] {
    display: none !important;
  }

  /* Print landscape by default for wide tables. */
  @page {
    size: landscape;
    margin: 12mm;
  }
}
