/*
 * App-level print stylesheet.
 *
 * Loaded ONLY for the OS print dialog (Ctrl+P / Cmd+P / Save-as-PDF) via
 * <link media="print"> in resources/views/layouts/layout.blade.php.
 *
 * Because the <link> already gates loading to media="print", the rules in
 * this file are written at the top level (no inner `@media print { … }`
 * wrapper). That way they can be enabled on-screen for preview testing by
 * temporarily flipping the link's media attribute to "all".
 *
 * Strategy: visibility-toggle anchored to the printable region. We use
 *   body * { visibility: hidden }
 *   [printable] { visibility: visible }
 * instead of trying to enumerate every chrome class in the AdminLTE-style
 * sidebar layout. This is bullet-proof against future markup changes.
 *
 * Printable region for this app: anything inside #content-of-sidebar with
 * a bill / paid-bill / a4-container id, plus the bill containers themselves.
 *
 * The popup-based Print buttons (printQuerySelectorsList-custom.js) open a
 * separate window with their own injected styles and do NOT load this
 * file — these rules will not interfere with the carbon-quadrant flow.
 */

@page {
    size: A4 portrait;
    margin: 12mm;
}

/* Lock body to A4 portrait paper width so Bootstrap .container picks the
   same breakpoint between print preview and printed output, and so the
   bill's logo / column rows render at predictable widths. */
html,
body {
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
}

/* Step 1 — hide everything in the body by default. */
body * {
    visibility: hidden;
}

/* Step 2 — re-show only the printable bill content and its descendants. */
[id^="bill_container_"],
[id^="bill_container_"] *,
[id^="claim_bill_output_"],
[id^="claim_bill_output_"] *,
[id^="print_bill_output_"],
[id^="print_bill_output_"] *,
.a4-container,
.a4-container *,
.printable,
.printable *,
/* Accountant fees-collection-report: only the result table prints. The
   filter form, action buttons, sidebar, and page header are chrome. The
   per-page CSS in css/accountant/fees-collection-report.css further
   overrides @page size to landscape for the 11-column table. */
#fcr-result,
#fcr-result * {
    visibility: visible;
}

/* Step 3 — even within the printable region, the on-screen Print button is
   chrome and must not survive into the printed output. */
.print-button,
.print-button *,
.no-print,
.no-print *,
[data-no-print],
[data-no-print] * {
    visibility: hidden !important;
    display: none !important;
}

/* Step 4 — collapse the layout chrome wrappers so the bill region anchors
   at the page origin instead of leaving a sidebar-width gap on the left. */
#app,
.scrollbar-thin,
.bg-image,
.wrapper-of-sidebar,
.content-of-sidebar,
#content-of-sidebar {
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
}

/* Bootstrap responsive `.container` caps at ~1320px on XL screens; let it
   expand to fill the printable A4 region. */
.container {
    max-width: none !important;
    width: 100% !important;
}

/* One bill per page on the monthly-view print. Avoid splitting an individual
   bill across pages where possible. */
[id^="bill_container_"],
[id^="claim_bill_output_"],
[id^="print_bill_output_"],
.a4-container {
    page-break-inside: avoid;
    break-inside: avoid;
}

[id^="bill_container_"]:not(:last-of-type) {
    page-break-after: always;
    break-after: page;
}

/* Re-enable backgrounds and exact colors so the bill's borders and
   underlines survive the browser default of "remove backgrounds in print". */
* {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}
