/*
 * Print stylesheet (linked with media="print" from layouts/app.blade.php).
 *
 * The preview is already split into A4 pages by the same planner as the PDF
 * (App\Services\InvoicePagination), so printing from the browser just has to
 * put each .invoice-page-node on exactly one sheet: no app chrome, no screen
 * scaling, no card shadow/border, and backgrounds (top bar, boxes) kept.
 *
 * Plain CSS on purpose: public/assets/css/app.css is a compiled Tailwind
 * bundle and only contains classes that were used when it was built.
 */

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    .no-print {
        display: none !important;
    }

    .print-reset {
        display: block !important;
        position: static !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        background: none !important;
    }

    /* Undo the on-screen 0.85 scale box around the preview. */
    .invoice-preview-scale {
        width: auto !important;
        height: auto !important;
    }

    .invoice-preview-scale > div {
        transform: none !important;
        width: auto !important;
    }

    .invoice-preview-stack {
        display: block !important;
        gap: 0 !important;
    }

    /* One preview page == one A4 sheet. */
    .invoice-page-node {
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: hidden;
        break-after: page;
        page-break-after: always;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Shrink-to-fit factor set by assets/js/print.js (1 when it fits).
       The absolutely positioned top bar / status stamp keep their size. */
    .invoice-page-node > :not(.absolute) {
        zoom: var(--print-fit, 1);
    }

    .invoice-page-node:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .invoice-page-node,
    .invoice-page-node * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .invoice-page-node thead {
        display: table-header-group;
    }

    .invoice-page-node tr,
    .invoice-summary {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
