/* ============================================================================
   PRINT STYLES FOR TASK LISTS
   Shared print styles for task list pages
   ============================================================================ */

@media print {
    /* CAL-PRINT-01: Hide everything on the page except #print-content, however deeply it's
       nested in the Blazor app tree. visibility (unlike display) computes independently per
       element, so a visibility:hidden ancestor (e.g. #app) doesn't block a nested element from
       being set back to visibility:visible — display:none on an ancestor would. This is what
       lets pages reveal #print-content with pure CSS instead of a JS DOM-swap hack. */
    body * {
        visibility: hidden !important;
    }

    #print-content,
    #print-content * {
        visibility: visible !important;
    }

    #print-content {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }

    /* Belt-and-suspenders for any page that opts into this stylesheet without its own
       #print-content block — redundant with the visibility reset above otherwise. */
    nav, header, footer, .btn, .alert, .filter-controls, .no-print {
        display: none !important;
    }

    /* CAL-PRINT-02: MainLayout's own chrome (sidebar, top bar, right rail, session banners) —
       none of these are ancestors of #print-content, only siblings of the branch that leads to
       it, so removing them from layout entirely is safe. visibility:hidden (above) hides an
       element's paint but, by design, still reserves its layout space — the sidebar's fixed
       100vh box is by far the largest single contributor to that reserved space, and was
       producing the trailing blank/colored pages seen after the real content (their own dark
       backgrounds — #0f172a sidebar, #121c2e top bar — matched what showed on those pages).
       display:none removes both the paint and the layout space outright. */
    .sidebar, .top-row, .rail-column, .session-expired-banner,
    .exec-session-strip, .recovery-banner {
        display: none !important;
    }

    /* Defensive: body's own print background (below) doesn't touch html/:root, so if anything
       upstream ever sets a background directly on the root element, it won't bleed through. */
    html {
        background: #fff !important;
    }

    body {
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    /* Print header */
    .print-header {
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
        border-bottom: 2px solid #000;
    }
    
    .print-header h1 {
        font-size: 18pt;
        font-weight: 700;
        margin: 0 0 0.5rem 0;
        color: #000;
    }
    
    .print-header p {
        font-size: 10pt;
        margin: 0.25rem 0;
        color: #333;
    }
    
    /* Print list */
    .print-list {
        list-style-position: outside;
        padding-left: 1.5rem;
        margin: 0;
    }
    
    .print-item {
        margin-bottom: 1rem;
        page-break-inside: avoid;
        padding: 0.5rem 0;
        border-bottom: 1px solid #ddd;
    }
    
    .print-item:last-child {
        border-bottom: none;
    }
    
    .print-item.completed {
        opacity: 0.7;
    }
    
    .print-item.overdue {
        padding: 0.5rem;
        border-left: 3px solid #dc3545;
    }
    
    /* Print task header */
    .print-task-header {
        margin-bottom: 0.25rem;
    }
    
    .print-task-header strong {
        font-size: 11pt;
        font-weight: 600;
        color: #000;
    }
    
    /* Print badges */
    .print-badge {
        display: inline-block;
        padding: 0.125rem 0.375rem;
        margin-left: 0.375rem;
        font-size: 8pt;
        font-weight: 500;
        border: 1px solid #666;
        border-radius: 0.25rem;
        white-space: nowrap;
    }

    .print-badge.priority {
        border-color: #ffc107;
        color: #856404;
    }

    .print-badge.status {
        border-color: #6c757d;
        color: #6c757d;
    }

    .print-badge.danger {
        border-color: #dc3545;
        color: #dc3545;
    }

    .print-badge.success {
        border-color: #28a745;
        color: #28a745;
    }
    
    /* Print task description */
    .print-task-description {
        font-size: 9pt;
        color: #555;
        margin: 0.25rem 0 0 0;
        padding-left: 0;
    }
    
    /* Force page breaks */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    /* Avoid breaking inside important elements */
    .print-item,
    .print-task-header,
    .print-task-description {
        page-break-inside: avoid;
    }
}

/* ============================================================================
   CAL-PRINT-01: CALENDAR PRINT STYLES (Daily Calendar, Weekly Calendar)
   Shared by DayView.razor and WeekView.razor's #print-content — one canonical
   pattern instead of each view inventing its own. Colors are hardcoded (not
   var(--sf-*)) deliberately: print output must stay light/readable regardless
   of the on-screen theme, dark included.
   ============================================================================ */
@media print {
    .print-header {
        border-bottom: 2px solid #111;
        padding-bottom: 5pt;
        margin-bottom: 8pt;
    }

    .print-header-top {
        display: flex;
        align-items: baseline;
        gap: 8pt;
    }

    .print-title {
        margin: 0;
        font-size: 16pt;
        font-weight: 700;
        color: #000;
        line-height: 1.2;
    }

    .print-today-badge {
        display: inline-block;
        padding: 1pt 5pt;
        border: 1px solid #4f46e5;
        color: #4f46e5;
        border-radius: 3pt;
        font-size: 7.5pt;
        font-weight: 700;
        vertical-align: middle;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .print-meta-row {
        display: flex;
        gap: 12pt;
        margin-top: 3pt;
        font-size: 8pt;
        color: #555;
    }

    .print-meta-overdue {
        color: #c0392b;
        font-weight: 700;
    }

    /* ── Sections ── */
    .print-section {
        margin-bottom: 10pt;
    }

    .print-section-header {
        font-size: 7.5pt;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #555;
        border-bottom: 1px solid #ccc;
        padding-bottom: 2pt;
        margin-bottom: 3pt;
    }

    /* ── Rows ── */
    .print-row {
        display: flex;
        align-items: baseline;
        gap: 6pt;
        padding: 3pt 0;
        border-bottom: 1px dotted #e5e5e5;
        page-break-inside: avoid;
    }

    .print-row:last-child {
        border-bottom: none;
    }

    .print-row-time {
        flex: 0 0 68pt;
        font-size: 7.5pt;
        font-weight: 600;
        color: #444;
        white-space: nowrap;
        padding-top: 1pt;
    }

    .print-row-time-end {
        font-weight: 400;
        color: #666;
    }

    .print-row-body {
        flex: 1;
        display: flex;
        align-items: baseline;
        gap: 5pt;
        flex-wrap: wrap;
    }

    .print-row-title {
        font-size: 9pt;
        font-weight: 600;
        color: #111;
        line-height: 1.3;
    }

    .print-row-complete {
        text-decoration: line-through;
        color: #888;
    }

    .print-row-meta {
        font-size: 7.5pt;
        color: #666;
    }

    /* ── Inline badges ── */
    .print-badge-overdue {
        display: inline-block;
        padding: 1pt 4pt;
        border: 1px solid #c0392b;
        color: #c0392b;
        border-radius: 2pt;
        font-size: 6.5pt;
        font-weight: 700;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .print-badge-priority {
        display: inline-block;
        padding: 1pt 4pt;
        border-radius: 2pt;
        font-size: 6.5pt;
        font-weight: 700;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .print-priority-high,
    .print-priority-urgent {
        color: #c0392b;
        border: 1px solid #c0392b;
    }

    .print-priority-medium {
        color: #856404;
        border: 1px solid #856404;
    }

    .print-priority-low {
        color: #155724;
        border: 1px solid #155724;
    }

    .print-badge-initiative {
        display: inline-block;
        padding: 1pt 4pt;
        color: #4f46e5;
        border: 1px solid #4f46e5;
        border-radius: 2pt;
        font-size: 7pt;
        font-weight: 600;
        white-space: nowrap;
    }

    /* ── Week grid (WeekView only — one .print-section per day) ── */
    .print-day-column {
        page-break-inside: avoid;
    }

    /* ── Empty state ── */
    .print-empty {
        text-align: center;
        padding: 16pt 0;
        color: #888;
        font-style: italic;
        font-size: 9pt;
    }

    /* ── Footer ── */
    .print-footer {
        margin-top: 10pt;
        padding-top: 4pt;
        border-top: 1px solid #ccc;
        font-size: 7pt;
        color: #aaa;
        text-align: center;
    }

    /* @page can't be scoped to a selector, so this is the one page-setup rule for every print
       job on the site, not just Day/Week — a second @page block used to live in the task-list
       section above (and, before that, in DayView.razor.css's global-scoped bundle) but was
       always silently overridden by this one; removed rather than left dead and misleading. */
    @page {
        size: A4 portrait;
        margin: 1.2cm 1.5cm;
    }
}

/* Screen-only styles for print content */
@media screen {
    #print-content {
        display: none;
    }
}
