/**
 * PRINT STYLES — FRAMEWORK
 * Specialized print formatting for reports and documents
 *
 * Strategy: use :has(.forPrint) to keep the ancestor chain from body
 * down to .forPrint open, while hiding everything else at each level.
 * No absolute positioning — .forPrint stays in normal document flow.
 *
 * DOM example (nested forms drilled to a report):
 *   #mainContent
 *     └─ managementBlock_1          ← :has(.forPrint) → kept open
 *          ├─ <form> nav buttons    ← hidden (no .forPrint inside)
 *          └─ managementBlock_2     ← :has(.forPrint) → kept open
 *               ├─ <form> buttons   ← hidden
 *               └─ … → managementBlock_N
 *                    └─ .forPrint   ← VISIBLE (the only thing that prints)
 */

/* .no-print is a PRINT-VISIBILITY MARKER ONLY — it must not set `display`
   on screen. It previously forced `inline-block`, which shrink-wrapped every
   .no-print form (filter panels rendered half-width) and, worse, knocked
   `<th class="no-print">` / `<td class="no-print">` out of the table's column
   model so headers no longer lined up with their rows. Hiding for print is
   handled by the @media print block below. */

/* Show elements only when printing */
.print-only {
    display: none;
    font-weight: bold;
    color: #000;
}

@media print {
    /* ===== FORCE WHITE CANVAS (Safari fix) ===== */
    html, body {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Kill ALL decorative pseudo-elements (starfields, nebula, overlays) */
    body::before,
    body::after,
    header::before,
    header::after,
    nav::before,
    nav::after,
    footer::before,
    footer::after {
        display: none !important;
    }

    /* ===== HIDE PAGE CHROME ===== */
    /* Framework structural elements — present across all sites */
    header,
    nav,
    footer,
    #accountDetails,
    .site-notification,
    .site-notification--info,
    .site-notification--warning,
    .site-notification--error {
        display: none !important;
    }

    /* Site-specific decorative layers (harmless no-op if absent) */
    .starfield-mid {
        display: none !important;
    }

    /* ===== ANCESTOR CHAIN — keep the path to .forPrint open ===== */
    /* Strip containers to bare pass-throughs so they generate no
       visible output, spacing, or page breaks of their own. */
    #outerFrame,
    #mainContent,
    #mainContent :has(.forPrint) {
        display: block !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
    }

    /* ===== HIDE EVERYTHING THAT ISN'T .forPrint OR AN ANCESTOR OF IT ===== */
    /* Direct children of #mainContent that don't contain .forPrint */
    #mainContent > *:not(:has(.forPrint)):not(.forPrint) {
        display: none !important;
    }

    /* Inside any ancestor that contains .forPrint, hide siblings
       that aren't part of the chain down to .forPrint */
    #mainContent :has(.forPrint) > *:not(:has(.forPrint)):not(.forPrint) {
        display: none !important;
    }

    /* ===== VISIBILITY CONTROLS ===== */
    .no-print {
        display: none !important;
    }

    .print-only {
        display: inline !important;
        font-weight: bold !important;
        color: #000 !important;
    }

    /* ===== .forPrint: THE PRINTABLE CONTENT BLOCK ===== */
    .forPrint {
        display: block !important;
        width: 100% !important;
        padding: 0.25in !important;
        background: #fff !important;
    }

    /* Base text styling — dark and bold for readability */
    .forPrint,
    .forPrint * {
        color: #000 !important;
        font-weight: bold !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Backgrounds: white on .forPrint itself, transparent on children */
    .forPrint * {
        background: transparent !important;
    }

    /* Tighten fieldset spacing with light gray borders */
    .forPrint fieldset {
        margin: 0 0 4px 0 !important;
        padding: 4px !important;
        border: 1px solid #ccc !important;
    }

    /* Legend styling — extra bold */
    .forPrint legend {
        margin: 0 !important;
        padding: 0 2px !important;
        font-size: 11pt !important;
        font-weight: 900 !important;
    }

    /* Tighten all headings — extra bold */
    .forPrint h2,
    .forPrint h3,
    .forPrint h4 {
        margin: 2px 0 !important;
        padding: 0 !important;
        font-size: 10pt !important;
        line-height: 1.1 !important;
        font-weight: 900 !important;
    }

    .forPrint h3 {
        font-size: 11pt !important;
    }

    /* Tighten paragraphs and divs */
    .forPrint p,
    .forPrint div {
        margin: 2px 0 !important;
        padding: 0 !important;
        line-height: 1.2 !important;
    }

    /* Compact tables with light gray borders */
    .forPrint table {
        margin: 2px 0 !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
        border: 1px solid #ccc !important;
    }

    .forPrint td,
    .forPrint th {
        padding: 1px 2px !important;
        border: 1px solid #ccc !important;
        line-height: 1.1 !important;
    }

    /* Extra bold for important elements */
    .forPrint .net-pay-highlight,
    .forPrint .total-row,
    .forPrint .total-row *,
    .forPrint strong,
    .forPrint .numeric {
        font-weight: 900 !important;
    }

    /* Cards and containers — clean borders */
    .forPrint .card {
        border: 1px solid #ccc !important;
        border-radius: 0 !important;
    }

    /* Page breaks for sections */
    .employee-print-section {
        page-break-after: always;
    }

    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }

    .no-page-break {
        page-break-inside: avoid;
    }

    /* Hide inputs/buttons completely */
    input,
    button,
    select,
    textarea {
        display: none !important;
    }

    /* ===== GL WORKED-DOCUMENT HIERARCHY ===== */
    /* Three tiers must survive print (the blanket .forPrint * bold above
       would flatten them) - quiet detail, bold milestones, unmissable net. */
    .forPrint .calc-detail,
    .forPrint .calc-detail *,
    .forPrint .calc-path:not(.chosen),
    .forPrint .calc-path:not(.chosen) * {
        font-weight: normal !important;
        font-size: 8pt !important;
        color: #333 !important;
    }

    .forPrint .calc-path.chosen,
    .forPrint .calc-path.chosen * {
        font-weight: 900 !important;
    }

    .forPrint .calc-chosen-tag {
        border: 1pt solid #000 !important;
        padding: 0 2pt !important;
    }

    .forPrint .calc-flag {
        border-left: 2pt solid #000 !important;
        padding-left: 3pt !important;
        font-weight: 900 !important;
    }

    .forPrint .calc-milestone {
        border-left: 3pt solid #000 !important;
        padding: 4pt !important;
    }

    .forPrint .calc-milestone,
    .forPrint .calc-milestone * {
        font-size: 11pt !important;
        font-weight: 900 !important;
    }

    .forPrint .net-pay-card {
        border: 2pt solid #000 !important;
        padding: 6pt !important;
    }

    .forPrint .net-pay-card td {
        font-size: 16pt !important;
        font-weight: 900 !important;
    }

    .forPrint .calc-subordinate,
    .forPrint .calc-subordinate * {
        font-size: 7.5pt !important;
        font-weight: normal !important;
        color: #444 !important;
    }
}