/* ============================================================
   ROOMZY REPORT PRINT STYLES
   Shared, theme-neutral print rules for every admin report
   (Housekeeping Dashboard / Weekly / Tasks, Door Report, and any
   future report). Loaded globally from Components/App.razor.

   Goals:
   1. THEME NEUTRAL - the admin shell paints .admin-shell with
      var(--surface-base), which is dark in the dark theme. Force
      every surface back to white with dark text so reports never
      print the dark (or tinted light) theme background.
   2. PRINT EVERY PAGE - the shell clamps height to 100vh and clips
      overflow (.admin-shell{height:100vh;overflow:hidden},
      .app-content{overflow-y:auto}), which silently cuts the
      printout to a single visible screen. Release those clamps so
      the browser paginates the whole report.
   3. PRINTER SAFE BRANDING - brand the output with Roomzy blue
      using LIGHT tints with DARK text. This stays legible on a
      colour printer, on a black-and-white printer (tints become
      light grey, dark text stays readable), and even if a printer
      driver drops background graphics entirely. print-color-adjust:
      exact asks the browser to keep the tints whenever it can.

   Roomzy brand blue: #2563EB (500) / #1D4ED8 (600) / #1E40AF (700).
   Canonical hooks used by the report pages:
     .report-print-header / .report-print-title / .report-print-date
     .report-print-section   (branded section / group heading)
     .report-print-summary   (branded footer / totals strip)
   Legacy aliases kept for existing markup: .print-section-title,
   .date-group-header td.
   ============================================================ */

@media print {

    /* ---- 0. Force the LIGHT colour scheme for print -------------- */
    /* Bootstrap 5.3 sets `color-scheme: dark` on [data-bs-theme="dark"]
       (see bootstrap-reboot.css). With a dark colour-scheme the browser
       paints the PRINT PAGE CANVAS / backdrop dark, which shows through
       as a black band at the top and bottom of every printed page (and
       a white band in the light theme). Element backgrounds cannot
       override that canvas, so we must reset the colour-scheme itself.
       This stylesheet loads after Bootstrap, so an equal-specificity
       rule on :root wins by source order; !important makes it certain. */
    :root,
    html,
    body {
        color-scheme: light !important;
    }

    /* ---- 1. Theme-neutral surfaces ------------------------------- */
    html,
    body,
    .admin-shell,
    .admin-main,
    .app-content,
    .container,
    .container-fluid,
    .card,
    .card-body,
    .card-header,
    .card-footer,
    .table,
    .table th,
    .table td {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        color: #1a1a1a !important;
        box-shadow: none !important;
    }

    body {
        font-size: 11pt !important;
        line-height: 1.35 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ---- 2. Hide on-screen chrome -------------------------------- */
    .app-sidebar,
    .app-topbar,
    .app-header,
    .app-top-menu,
    .mobile-bottom-nav,
    .navbar,
    nav,
    header,
    footer,
    .btn,
    .input-group,
    .form-select,
    .form-control,
    .form-check,
    .modal,
    .modal-backdrop,
    .no-print,
    .d-print-none {
        display: none !important;
    }

    /* ---- 3. Release the viewport clamp so every page prints ------ */
    .admin-shell,
    .admin-main,
    .app-content,
    .table-responsive {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .app-content {
        padding: 0 !important;
    }

    .h-100,
    .card.h-100 {
        height: auto !important;
    }

    /* Full-width content when printing */
    .col-print-12 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* ---- 4. Page set-up (portrait default) ----------------------- */
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    /* ---- 5. Cards ------------------------------------------------- */
    /* In print the only visible cards are report-CONTENT cards (the
       weekly daily breakdowns, the task table, arrivals/departures).
       The small summary stat cards are .d-print-none. Report content is
       routinely taller than one page, so cards MUST be allowed to
       paginate. Forcing break-inside: avoid made a tall first card jump
       to page 2 and left page 1 empty except for the title. Let cards
       and their Bootstrap grid rows/columns flow across pages; the
       atomic units that must stay whole (table rows, list entries,
       section headers) are pinned separately below. */
    .card {
        border: 1px solid #c7d2e8 !important;
        border-radius: 4px !important;
        margin-bottom: 10px !important;
        page-break-inside: auto;
        break-inside: auto;
    }

    /* A flex .row keeps a tall column whole and overflows unless we let
       the grid fragment too. */
    .card .row,
    .card [class*="col-"] {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Keep an individual entry (a guest line, a room and its tasks)
       from being split across a page boundary. The column still breaks
       cleanly BETWEEN entries. */
    .card li {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .card-header {
        border-bottom: 1px solid #c7d2e8 !important;
        font-weight: 600 !important;
    }

    /* ---- 6. Branded report banner (print-only) ------------------- */
    .report-print-header {
        display: block !important;
        text-align: center;
        margin: 0 0 16px 0 !important;
        padding: 12px 16px !important;
        background-color: #eff4ff !important;
        border: 1px solid #1d4ed8 !important;
        border-bottom-width: 3px !important;
        border-radius: 4px;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .report-print-header .report-print-title,
    .report-print-header h2 {
        margin: 0 !important;
        font-size: 17pt !important;
        font-weight: 700 !important;
        color: #1e3a8a !important;
    }

    .report-print-header .report-print-date,
    .report-print-header .report-date,
    .report-print-header .date-range {
        margin: 3px 0 0 0 !important;
        font-size: 10.5pt !important;
        color: #334155 !important;
    }

    /* ---- 7. Section / group headings ----------------------------- */
    .report-print-section,
    .print-section-title,
    .date-group-header td {
        background-color: #dce7ff !important;
        color: #1e3a8a !important;
        font-weight: 700 !important;
        border-bottom: 2px solid #1d4ed8 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .report-print-section h5,
    .report-print-section h6,
    .report-print-section .h5,
    .report-print-section strong,
    .print-section-title h5,
    .print-section-title h6,
    .print-section-title .h5 {
        color: #1e3a8a !important;
    }

    .date-group-header .badge {
        background-color: #ffffff !important;
        color: #1e3a8a !important;
        border: 1px solid #1d4ed8 !important;
    }

    /* ---- 7b. Weekly report: stack the day columns when printing --- */
    /* On screen each day shows Check-outs / Check-ins / Tasks side by
       side (col-md-4). When one column is much taller than the others
       (e.g. 19 tasks vs 1 check-in) the short columns leave large blank
       gaps and the flex row paginates awkwardly. For print we stack the
       three sections full-width so they read top-to-bottom like a clean
       checklist with no wasted space. */
    .report-day-grid {
        display: block !important;
    }

    .report-day-grid > [class*="col-"] {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        margin-bottom: 8px !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Branded sub-heading for each section inside a day card. */
    .report-day-grid > [class*="col-"] > h6 {
        font-size: 10.5pt !important;
        font-weight: 700 !important;
        color: #1e3a8a !important;
        margin: 4px 0 4px 0 !important;
        padding: 2px 6px !important;
        background-color: #eef3ff !important;
        border-left: 3px solid #1d4ed8 !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ---- 8. Tables ----------------------------------------------- */
    .table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9.5pt !important;
    }

    .table th,
    .table td {
        border: 1px solid #c7d2e8 !important;
        padding: 4px 7px !important;
        vertical-align: top !important;
    }

    .table thead th {
        background-color: #eff4ff !important;
        color: #1e3a8a !important;
        font-weight: 700 !important;
        border-bottom: 2px solid #1d4ed8 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Repeat the column header row on every printed page */
    thead {
        display: table-header-group !important;
    }

    tfoot {
        display: table-footer-group !important;
    }

    /* Very light zebra so it survives black-and-white printing */
    .table tbody tr:not(.date-group-header):nth-child(even) td {
        background-color: #f5f8ff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Keep rows from splitting across a page boundary */
    tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* ---- 9. Readable text ---------------------------------------- */
    /* Darken theme/semantic text so nothing prints invisibly. The
       semantic hues are kept but pushed dark enough to read on white
       (and as grey on a B&W printer). */
    .text-muted {
        color: #444444 !important;
    }

    .text-white,
    .text-white-50,
    .text-dark-50,
    .text-light {
        color: #1a1a1a !important;
    }

    .text-success {
        color: #0f5132 !important;
    }

    .text-danger {
        color: #842029 !important;
    }

    .text-warning {
        color: #7a5b00 !important;
    }

    .text-info {
        color: #055160 !important;
    }

    .text-primary {
        color: #1e3a8a !important;
    }

    small,
    .small {
        font-size: 8.5pt !important;
    }

    /* ---- 10. Badges: outlined so they read on any printer -------- */
    .badge {
        background-color: #ffffff !important;
        color: #1a1a1a !important;
        border: 1px solid #6b7280 !important;
        font-weight: 600 !important;
        padding: 2px 6px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .badge.bg-danger,
    .badge.text-bg-danger {
        color: #842029 !important;
        border-color: #842029 !important;
    }

    .badge.bg-warning,
    .badge.text-bg-warning {
        color: #7a5b00 !important;
        border-color: #7a5b00 !important;
    }

    .badge.bg-success,
    .badge.text-bg-success {
        color: #0f5132 !important;
        border-color: #0f5132 !important;
    }

    .badge.bg-info,
    .badge.text-bg-info {
        color: #055160 !important;
        border-color: #055160 !important;
    }

    .badge.bg-primary,
    .badge.text-bg-primary {
        color: #1e3a8a !important;
        border-color: #1d4ed8 !important;
    }

    .badge.bg-secondary,
    .badge.text-bg-secondary {
        color: #343a40 !important;
        border-color: #6b7280 !important;
    }

    /* ---- 11. Branded footer / summary strip ---------------------- */
    .report-print-summary {
        display: block !important;
        margin-top: 16px !important;
        padding: 8px 14px !important;
        background-color: #eff4ff !important;
        border-top: 2px solid #1d4ed8 !important;
        color: #1e3a8a !important;
        border-radius: 0 0 4px 4px;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .report-print-summary strong {
        color: #1e3a8a !important;
    }

    /* ---- 12. Page-break helpers ---------------------------------- */
    .page-break-before {
        page-break-before: always !important;
    }

    .page-break-after {
        page-break-after: always !important;
    }
}

/* Print-only blocks must never show on screen. The report pages also
   add Bootstrap's .d-none .d-print-block; this is a defensive fallback
   so a forgotten utility class can never leak the banner onto screen. */
@media screen {
    .report-print-header,
    .report-print-summary {
        display: none;
    }
}
