/* Printable documents (delivery note, picklist, proformas) mark their document element with
   data-print-root. When printing, that element is the only thing on the paper: everything outside
   it is hidden and every wrapper around it is flattened, so site-wide chrome (menu, admin sidebar,
   AI chat, cookie banner, mobile.css/menu.css responsive rules, ...) cannot leak into the print.
   Pages without data-print-root are unaffected. Page stylesheets only style the document itself. */
@media print {
    /* Neither the print root, inside it, nor an ancestor of it */
    body:has([data-print-root]) *:not([data-print-root]):not([data-print-root] *):not(:has([data-print-root])) {
        display: none !important;
    }

    /* Ancestors of the print root: plain blocks without size, offset, scroll or decoration */
    html:has([data-print-root]),
    body:has([data-print-root]),
    body:has([data-print-root]) *:has([data-print-root]) {
        display: block !important;
        position: static !important;
        float: none !important;
        inset: auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: visible !important;
        transform: none !important;
        box-shadow: none !important;
        background: #fff !important;
        container-type: normal !important;
    }

    [data-print-root] {
        position: static !important;
        float: none !important;
        inset: auto !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        background: #fff !important;
    }

    /* Form controls print as text: never show scrollbars, spinners or resize handles */
    [data-print-root] textarea,
    [data-print-root] input,
    [data-print-root] select {
        overflow: hidden !important;
        resize: none !important;
        scrollbar-width: none !important;
    }

    [data-print-root] ::-webkit-scrollbar {
        display: none !important;
    }
}
