/* ============================================================================
   Shared print styles — the single source of truth for the app's print behavior.
   Used by the PrintablePacket component and by any module that produces a
   printable client copy. Loaded globally in App.razor.

   Two idioms are supported:
   1. Utility classes on a single set of content (preferred, used by PrintablePacket):
        .no-print    — element is hidden when printing
        .print-only  — element is hidden on screen, shown only when printing
   2. Dual-view (for pages whose print layout differs entirely from the screen UI):
        .screen-view — shown on screen, hidden when printing
        .print-view  — hidden on screen, shown when printing
   ============================================================================ */

@media screen {
    .print-only  { display: none !important; }
    .print-view  { display: none !important; }
    .screen-view { display: block; }

    /* A report block that always prints but is shown on screen only when expanded. */
    .print-report-block.is-collapsed { display: none; }
}

/* Give every printed page a consistent, professional gutter. */
@page { margin: 0.5in; }

@media print {
    .no-print    { display: none !important; }
    .screen-view { display: none !important; }
    .print-view  { display: block !important; }

    /* Only the document should print — strip the app shell chrome. */
    .top-nav,
    .tool-subnav,
    .site-footer,
    #blazor-error-ui { display: none !important; }

    /* Honor brand/tier colors and share bars (browsers strip backgrounds by default). */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        margin: 0;
        padding: 0;
        background: #fff;
        color: #000;
    }

    /* The main content should use the full page width with no screen padding. */
    .page-wrapper, .main-content { margin: 0 !important; padding: 0 !important; max-width: none !important; }

    /* Don't clip wide tables/diagrams inside horizontal scroll boxes — let them use the page. */
    .card, .card > div, .schedule-wrapper, .schedule-wrapper > div { overflow: visible !important; }

    /* Flatten cards for a document feel. */
    .card {
        border: 1px solid #d1d5db !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0.6rem 0.75rem !important;
        margin-top: 0.6rem !important;
    }

    /* Shrink data tables so all columns fit portrait. */
    .data-table, .schedule-table { font-size: 8.5px !important; width: 100% !important; }
    .data-table th, .data-table td,
    .schedule-table th, .schedule-table td { padding: 3px 4px !important; }

    /* Keep groups together across page breaks. */
    .card,
    table, tr,
    .stat-row, .stat-box,
    .print-avoid-break { break-inside: avoid; }

    /* The two-column visualizer layout (inputs | results) is a "300px 1fr" grid. When the input
       panel is hidden for print, the results would otherwise auto-place into the leftover 300px
       track — printing narrow and left-shifted (looked like the mobile view). Collapse the grid to
       a single full-width column so the results use the whole page. Covers every visualizer tool. */
    .visualizer-layout { display: block !important; }
    .visualizer-layout > * { width: 100% !important; max-width: none !important; }
}

/* ── Branded print header / title / footer (shared scaffolding) ────────────── */
.print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-primary, #002F6C);
}

.print-logo { height: 48px; width: auto; }

.print-client-name {
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    line-height: 1.5;
}

.print-field-value {
    border-bottom: 1px solid #555;
    min-width: 160px;
    display: inline-block;
}

.print-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary, #002F6C);
    letter-spacing: 1px;
    margin: 10px 0 14px;
    text-transform: uppercase;
}

.print-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #ccc;
    font-size: 9px;
    color: #555;
    text-align: center;
}

.print-footer p { margin: 0; }

/* Registered firm mark line under the disclosure — carries the ® on every packet. */
.print-firm-mark { margin: 4px 0 0; font-weight: 600; }

/* Section divider heading within a multi-section print packet. */
.print-section-heading {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary, #002F6C);
    border-bottom: 2px solid var(--color-accent, #CAB64B);
    padding-bottom: 3px;
    margin: 6px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* On-screen placement of the packet's print button. */
.print-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

/* ── One Page Financial Snapshot ───────────────────────────────────────────────
   The sheet must land on exactly one portrait page under the PrintablePacket
   header and footer, so print drops the screen chrome (shadow/border/padding),
   tightens the grid, and keeps every section whole. */
@media print {
    .snapshot-sheet {
        max-width: none;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0;
        margin: 0;
        gap: 8px 14px;
        break-inside: avoid;
    }
    .snapshot-section { padding-top: 4px; break-inside: avoid; }
    .snapshot-section-title { font-size: 10px; margin-bottom: 3px; }
    .snapshot-section-figure { font-size: 9.5px; }
    .snapshot-hero-value { font-size: 26px; }
    .snapshot-hero-sub, .snapshot-cashflow-summary { font-size: 9.5px; }
    .snapshot-note { font-size: 8.5px; }
    .chart-legend { font-size: 9px; }
    .spectrum-bar-svg { height: 24px; }
    .spectrum-bar-amount { font-size: 11px; }
    .spectrum-bar-tier-name { font-size: 9.5px; }
    .spectrum-bar-caption { font-size: 8px; }
    .spectrum-bar-runway { font-size: 8.5px; }
    .sparkline { width: 10rem; }
    .sparkline-caption, .sparkline-labels { font-size: 7.5px; }
    .snapshot-focus-text { font-size: 9.5px; }
    .snapshot-extra-page {
        break-before: page;
        max-width: none;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0;
        margin: 0;
        gap: 10px;
    }
    .snapshot-invest-bar { height: 16px; }
    .coverage-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
    .coverage-tile { padding: 4px 6px; gap: 1px; }
    .coverage-tile-type { font-size: 8.5px; }
    .coverage-tile-status { font-size: 8px; }
    .coverage-tile-figure { font-size: 9px; }
    .coverage-tile-carrier, .coverage-tile-notes { font-size: 7.5px; }
    .snapshot-debt-list dt { font-size: 10px; }
    .snapshot-debt-list dd { font-size: 11px; }
    .delta-badge { font-size: 10px; padding: 0 5px; }
    .delta-badge-context { font-size: 8.5px; }
    .donut-chart { margin: 2px 0; gap: 10px; }
    .waterfall-chart { margin: 2px 0; }
    .spectrum-bar { margin: 4px 0; }
}
