/* WorkCampConnect — Print Stylesheet
 * Single source of truth for @media print rules across the platform.
 *
 * Loaded via <link media="print"> in includes/header-global.php so it has
 * zero impact on screen rendering — browsers only apply these rules when
 * the user actually invokes print (File → Print, ⌘P / Ctrl+P, Save as PDF).
 *
 * Cross-browser strategy:
 *  - Use BOTH page-break-* (legacy, Safari prioritizes) AND break-* (modern).
 *  - Use BOTH -webkit-print-color-adjust AND print-color-adjust where applicable.
 *  - Use chained single-arg :not() (universal) instead of Level 4 multi-arg.
 *  - All colors via --color-print-* tokens (defined in design-system.css :root).
 *
 * Browsers in scope: Chrome (desktop+Android), Safari (macOS+iOS), Firefox, Edge Chromium.
 */

@media print {

    /* ── Page setup ───────────────────────────────────────────────── */
    @page {
        margin: 0.5in;
    }

    html, body {
        background: var(--color-print-bg) !important;
        color: var(--color-print-text) !important;
        font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
        font-size: 11pt !important;
        line-height: 1.5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Hide all chrome and interactive elements ─────────────────── */
    /* Platform-wide utility class — add to any element you want stripped from print */
    .no-print { display: none !important; }

    /* Top nav + footer chrome (header-global.php / footer-global.php) */
    .wcc-nav,
    .wcc-mega-menu,
    .wcc-mobile-nav,
    .wcc-mobile-menu,
    .wcc-mobile-menu__backdrop,
    .wcc-profile-menu,
    .wcc-bell,
    .wcc-search-overlay,
    .wcc-footer,
    .footer-global,
    .footer-bar,
    .cookie-consent,
    .skip-link {
        display: none !important;
    }

    /* Member dashboard sidebar */
    .dash-sidebar,
    .dash-nav-drawer,
    .dash-mobile-header {
        display: none !important;
    }

    /* Employer portal sidebar + bottom nav */
    .emp-sidebar,
    .emp-bottom-nav,
    .emp-mobile-header {
        display: none !important;
    }

    /* Admin sidebar */
    .adm-sidebar,
    .adm-header {
        display: none !important;
    }

    /* Modals + overlays — they're hidden by default but ensure they stay
       hidden even if a user prints with one open */
    .fwd-modal,
    .mj-notes-modal,
    .cg-verify-modal,
    .notes-quickadd-modal,
    .adm-fab-modal,
    .fs-modal-overlay {
        display: none !important;
    }

    /* Buttons, action forms, AJAX controls — none of these are useful on paper */
    button:not(.print-allow),
    .btn:not(.print-allow),
    input[type="submit"]:not(.print-allow),
    input[type="button"]:not(.print-allow) {
        display: none !important;
    }

    /* Forms with method="POST" are all action-firing controls — hide them.
       (The submitted RESULT content is preserved in the page body separately.) */
    form[method="POST"]:not(.print-allow),
    form[method="post"]:not(.print-allow) {
        display: none !important;
    }

    /* Alerts / toasts / flash messages */
    .alert,
    .dash-alert,
    .emp-dash-flash {
        display: none !important;
    }

    /* ── Reflow layouts to full-width single column ──────────────── */
    .dash-layout,
    .emp-dash-layout,
    .adm-shell {
        display: block !important;
        grid-template-columns: unset !important;
    }

    .dash-main,
    .emp-dash-main,
    .adm-main {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* ── Card surfaces: white bg + grey border instead of dark navy ──── */
    .dash-section,
    .dash-v5-card,
    .emp-dash-card,
    .adm-card,
    [class*="-card"] {
        background: var(--color-print-bg) !important;
        background-color: var(--color-print-bg) !important;
        color: var(--color-print-text) !important;
        border: 1px solid var(--color-print-border) !important;
        border-radius: 4px !important;
        padding: 12pt !important;
        margin-bottom: 12pt !important;
        box-shadow: none !important;
        /* Cross-browser page-break behavior */
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── Typography ──────────────────────────────────────────────── */
    h1, h2, h3, h4, h5, h6 {
        color: var(--color-print-text) !important;
        page-break-after: avoid;
        break-after: avoid;
    }
    h1 { font-size: 18pt !important; }
    h2 { font-size: 14pt !important; }
    h3 { font-size: 12pt !important; }

    p, li, td, div {
        color: var(--color-print-text) !important;
    }

    /* Muted text retains some hierarchy in print */
    .text-muted,
    [class*="-muted"],
    [class*="__hint"],
    [class*="__sub"] {
        color: var(--color-print-muted) !important;
    }

    /* Links — black, underlined for visibility on paper */
    a {
        color: var(--color-print-text) !important;
        text-decoration: underline !important;
    }

    /* Append the actual URL after content links so paper readers can find them.
       Skip:
       - Fragment anchors (#section-id) — useless on paper
       - mailto: / tel: — the address IS the link text
       - Button-styled links (.btn) — they're hidden anyway, but defensive
       - Navigation links (.dash-nav__link, .wcc-nav__link) — chrome, hidden anyway
       Uses chained single-arg :not() (universal browser support, not Level 4 multi-arg). */
    a[href]:not(.btn):not(.dash-nav__link):not(.wcc-nav__link)::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: var(--color-print-muted) !important;
        word-break: break-all;
    }
    a[href^="#"]::after,
    a[href^="mailto:"]::after,
    a[href^="tel:"]::after,
    a[href^="javascript:"]::after {
        content: "" !important;
    }

    /* ── Images — preserve aspect ratio, prevent oversized prints ── */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── Tables — ensure they print readably ─────────────────────── */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    th, td {
        border: 1px solid var(--color-print-border) !important;
        padding: 6pt 8pt !important;
        color: var(--color-print-text) !important;
    }
    thead {
        display: table-header-group;
    }
    tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* ── Status badges / pills — keep semantic colors readable ──── */
    [class*="status"],
    [class*="badge"],
    [class*="pill"] {
        background: var(--color-print-bg) !important;
        color: var(--color-print-text) !important;
        border: 1px solid var(--color-print-border) !important;
    }
}
