/* ============================================================================
   Print stylesheet — currently scoped at the schedule weekly view.
   Loaded globally via index.html, but rules only fire on @media print.
   ========================================================================= */

@media print {

    /* -------- Page setup -------- */
    @page {
        size: landscape;
        margin: 0.5in;
    }

    /* -------- Strip the entire app shell -------- */
    #app-header,
    #app-sidebar,
    #sidebar,
    #sidebar-overlay,
    #app-bottom-tabs,
    nav.bottom-tab-bar,
    [data-bottom-tab-bar],
    #app-toast-container,
    .toast,
    .modal-backdrop-st,
    .dropdown-nav-panel,
    .popover-sheet-backdrop {
        display: none !important;
    }

    /* -------- Reset main content layout (kill the tablet sidebar offset) -------- */
    html, body, #app, #content, #app-content {
        background: white !important;
        color: black !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }
    #content {
        padding-left: 0 !important;
        padding-top: 0 !important;
    }

    /* -------- Flatten viewport-height + flex stretching ----
       The app uses .h-full / .min-h-screen / .flex-1 everywhere to fill the
       browser viewport. In print, those reserve a full page of empty space
       before the actual content (e.g. schedule grid) gets to lay out — leaves
       page 1 mostly blank with the title floating up top. Force natural flow.
    */
    .min-h-screen,
    .h-full,
    .h-app-content {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
    }
    .flex-1 {
        flex: none !important;
    }
    .min-h-0 {
        min-height: 0 !important;
    }

    /* -------- Force colour fidelity (badges/shift blocks) -------- */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* -------- Hide every interactive control on the schedule page -------- */
    #cmdPrevWeek, #cmdNextWeek, #cmdToday, #cmdWeekPicker,
    #cmdFilterProject, #cmdApplyTemplate, #cmdSaveTemplate,
    #cmdRequestTimeOff, #cmdScheduleCrew, #cmdCompareActual,
    #cmdPrint,
    .add-shift-btn, .cmd-edit-shift, .cmd-delete-shift,
    .filter-btn, .three-dots-menu,
    [data-action="kebab"], [data-action="more"] {
        display: none !important;
    }

    /* Hide nearly all interactive buttons + inputs.
       Allow buttons inside .shift-block so the visual block still renders if it
       happens to be a <button> — just neutralise its action affordance. */
    button:not(.shift-block):not(.shift-block *),
    input[type="text"], input[type="search"], input[type="date"], input[type="time"],
    select,
    textarea {
        display: none !important;
    }

    /* -------- Card chrome — flatten -------- */
    .card-st {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* -------- Kill sticky/scrolling — blows up in print otherwise -------- */
    .sticky, [class*="sticky"],
    #schedule-grid-header,
    #schedule-grid-container {
        position: static !important;
        overflow: visible !important;
        max-height: none !important;
        height: auto !important;
    }

    /* -------- Show the print-only title -------- */
    .print-title {
        display: block !important;
        font-size: 16pt;
        font-weight: 700;
        margin: 0 0 12pt 0;
        text-align: center;
        color: black !important;
    }
    .print-subtitle {
        display: block !important;
        font-size: 10pt;
        font-weight: 400;
        text-align: center;
        margin: 0 0 12pt 0;
        color: #444 !important;
    }

    /* -------- Schedule grid: keep employee rows together, render greyscale-friendly -------- */
    .schedule-grid-employee,
    .schedule-grid-row,
    [data-schedule-row] {
        page-break-inside: avoid;
        break-inside: avoid;
        background: white !important;
        border-color: #ccc !important;
        color: black !important;
    }

    .shift-block {
        border: 1px solid #999 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Make header row repeat at the top of each printed page if the body
       overflows (Chrome respects this on table elements; harmless on divs). */
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }

    /* -------- Dark mode override — always print on white -------- */
    [data-theme="dark"], [data-theme="dark"] * {
        background: white !important;
        color: black !important;
        border-color: #ccc !important;
    }
}

/* Print-only title element is hidden on screen */
.print-title,
.print-subtitle {
    display: none;
}
