/*
 * Print styling for the personal-ledger reports.
 *
 * Replaces /views/layout/print_normal.inc and /views/layout/page_print.inc,
 * the two ASP includes that wrapped a report table in a printable shell. Those
 * included a whole alternate page layout; here the application layout stays and
 * the print stylesheet hides everything outside .report-print-area.
 *
 * Screen rules are scoped to .report-table so they cannot affect the rest of
 * the app. The class names .sub-total and .grand-total are carried over from
 * the ASP, which used them on its subtotal and total rows.
 */

/* ── On screen ─────────────────────────────────────────────────────────── */

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

    .report-table th,
    .report-table td {
        padding: 4px 6px;
        border-bottom: 1px solid var(--mud-palette-lines-default, #e1e0d9);
        vertical-align: top;
    }

    .report-table thead th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--mud-palette-background-grey, #f5f5f5);
        border-bottom: 2px solid var(--mud-palette-lines-default, #cfcfcf);
        font-weight: 600;
        white-space: nowrap;
    }

    .report-table tbody tr:hover {
        background: var(--mud-palette-action-default-hover, rgba(0, 0, 0, .04));
    }

    /* Rows that drill down. The ASP put onclick="NewWindow(...)" on these and
       gave no affordance at all beyond a cursor change on some pages. */
    .report-table tr.is-drillable {
        cursor: pointer;
    }

        .report-table tr.is-drillable:focus-visible {
            outline: 2px solid var(--mud-palette-primary, #1e3a5f);
            outline-offset: -2px;
        }

    .report-table .group-head td {
        background: var(--mud-palette-background-grey, #f2f2ef);
        font-weight: 600;
        padding-top: 10px;
    }

    .report-table .sub-total td,
    .report-table .sub-total th {
        font-weight: 600;
        border-top: 1px solid #9a9a9a;
        border-bottom: 1px solid #9a9a9a;
    }

    .report-table .grand-total td,
    .report-table .grand-total th {
        font-weight: 700;
        border-top: 2px solid #6f6f6f;
        border-bottom: 3px double #6f6f6f;
    }

    .report-table .num {
        text-align: right;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    /* Negative balances. FormatNum in the ASP rendered these in parentheses and
       the same colour as everything else; the parentheses are kept (Num2Double
       still produces them) and colour is added. */
    .report-table .num.is-negative {
        color: var(--mud-palette-error, #b3261e);
    }

/* Wide reports scroll inside their own container rather than the page. */
.report-scroll {
    overflow-x: auto;
    max-width: 100%;
}

.report-criteria-summary {
    max-width: 640px;
    font-size: 0.82rem;
}

    .report-criteria-summary th {
        width: 160px;
        font-weight: 500;
        color: var(--mud-palette-text-secondary, #52514e);
    }

/* The criteria fields used to be native `<select multiple size="5">` listboxes
   and needed a floor on their height. They are MudSelect dropdowns with checkbox
   lists now — one line high closed — so the rule is gone. The row of them keeps
   its own spacing from Bootstrap's `row g-3` in CriteriaPanel.razor. */

/* ── On paper ──────────────────────────────────────────────────────────── */

@media print {
    /* Hide the shell: nav drawer, app bar, toolbars, criteria panel. */
    body * {
        visibility: hidden;
    }

    .report-print-area,
    .report-print-area * {
        visibility: visible;
    }

    .report-print-area {
        position: absolute;
        inset: 0;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .d-print-none,
    .mud-drawer,
    .mud-appbar,
    .report-criteria {
        display: none !important;
    }

    .report-scroll {
        overflow: visible !important;
    }

    .report-table {
        font-size: 9pt;
        border-collapse: collapse;
    }

        .report-table th,
        .report-table td {
            border: 1px solid #999;
            padding: 2px 4px;
            color: #000;
            background: transparent !important;
        }

        /* Repeat the header on every printed page. */
        .report-table thead {
            display: table-header-group;
            position: static;
        }

        .report-table tr {
            page-break-inside: avoid;
        }

        .report-table .num.is-negative {
            color: #000;
        }

    @page {
        size: landscape;
        margin: 10mm;
    }
}

/* ── Report hub rows ───────────────────────────────────────────────────── */
/* index.asp's `.largebold` anchor + description + <hr /> triples. Matches the
   .period-task rules in Thrift/Period/Index.razor so the two hubs read alike. */

.report-link {
    padding: 10px 0;
    border-bottom: 1px solid var(--mud-palette-lines-default, #e1e0d9);
}

    .report-link:last-child {
        border-bottom: 0;
    }

.report-link__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 1.02rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--mud-palette-primary, #1e3a5f);
}

    .report-link__head:hover {
        text-decoration: underline;
    }

    /* Unavailable rows keep their place but read as inert. */
    .report-link__head.is-disabled {
        color: var(--mud-palette-text-disabled, #a0a0a0);
        cursor: not-allowed;
    }

        .report-link__head.is-disabled:hover {
            text-decoration: none;
        }

.report-link__note {
    margin: 4px 0 0;
    font-size: .86rem;
    color: var(--mud-palette-text-secondary, #52514e);
}

/* Drill trail, replacing the ASP's popup windows. */
.report-trail {
    display: flex;
    align-items: center;
    font-size: .86rem;
}

    .report-trail .btn-link {
        vertical-align: baseline;
    }
