/*
    Almost everything is MudBlazor's. What is here covers the two moments MudBlazor cannot:
    the loading screen, which is painted before any .NET code has run, and the error strip,
    which has to be legible when the application has failed.
*/

html, body {
    margin: 0;
    padding: 0;
    font-family: Roboto, "Segoe UI", system-ui, sans-serif;
}

/* --- Before the runtime starts ------------------------------------------- */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1.25rem;
    color: #5a6472;
    background: #f7f8fa;
}

.loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid #d7dbe2;
    border-top-color: #1f3a5f;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-text {
    margin: 0;
    font-size: 0.95rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/*
    No animation for anyone who has asked not to see one. The spinner is decoration; the text
    beside it is what actually says the application is starting.
*/
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }
}

/* --- When the runtime has failed ----------------------------------------- */

/*
    Blazor shows this by setting display:block on it, so the hidden state has to be display:none
    and nothing else. Driving it from opacity or visibility leaves an invisible strip across the
    bottom of every page swallowing clicks.
*/
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 0.8rem 1.2rem;
    background: #ffe8a3;
    color: #46331a;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.6rem;
    right: 0.9rem;
    cursor: pointer;
}

#blazor-error-ui a {
    color: #46331a;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Printing
   ---------------------------------------------------------------------------
   The "Export PDF" button on the tickets grid opens the browser's print dialog,
   where every browser offers "Save as PDF". These rules are what make the sheet
   worth saving: the navigation, the app bar, the filter block and the buttons go
   away, and what is left is the heading and the table.

   Written as a print media query rather than a separate stylesheet so there is
   one place to look, and scoped by a class the page adds rather than by element
   so the rest of the console is unaffected if it ever grows a print view of its
   own. */
@media print {
    .mud-appbar,
    .mud-drawer,
    .mud-overlay,
    .no-print {
        display: none !important;
    }

    .mud-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* A table that scrolls on screen has to lay flat on paper, or the rows past
       the viewport are simply not printed. */
    .mud-table-container {
        overflow: visible !important;
        max-height: none !important;
    }

    /* Outlines read as grey boxes on paper and cost ink for nothing. */
    .mud-paper-outlined {
        border: none !important;
    }

    /* Keep a row off a page boundary. A ticket split across two sheets is the one
       thing that makes a printed table hard to read. */
    tr {
        page-break-inside: avoid;
    }

    /* -----------------------------------------------------------------------
       M4 Phase 6: the four reports.
       -----------------------------------------------------------------------
       A printed ticket grid is self-explanatory -- it has barcodes on it. A
       printed report is a table of numbers, and without a statement of what it
       covers it is a sheet nobody can check a month later. So the reports add
       three things the grid did not need: a title and a filter summary that
       exist only on paper, repeated table headers and totals, and variance
       colours that survive the printer. */

    /* Shown ONLY when printing. The mirror of .no-print, and the reason the
       filter summary can be written into the page without cluttering the
       screen -- on screen the filter controls say all of it already. */
    .print-only {
        display: block !important;
    }

    .report-print-header {
        margin: 0 0 12px;
        padding: 0 0 8px;
        border-bottom: 1px solid #000;
    }

    .report-print-title {
        font-size: 16pt;
        font-weight: 600;
    }

    .report-print-summary {
        font-size: 9pt;
        margin-top: 2px;
    }

    /* REPEAT THE HEADERS AND THE TOTALS ON EVERY SHEET. A location report over
       sixty shops runs to three pages, and pages two and three of unlabelled
       columns of money are unreadable. thead/tfoot repetition is what
       table-header-group and table-footer-group buy, and it is the one reason
       the totals row is a <tfoot> rather than the last <tr>. */
    .report-table thead {
        display: table-header-group;
    }

    .report-table tfoot {
        display: table-footer-group;
    }

    .report-table tfoot th {
        border-top: 1px solid #000;
        font-weight: 600;
    }

    /* Amounts on paper want to be read in a column, not scanned for. */
    .report-table {
        font-size: 9pt;
    }

    /* KEEP THE VARIANCE COLOURS. Browsers drop background colours when printing
       to save ink, which would turn a red 2,400-gourde shortfall into the same
       grey chip as a balanced drawer -- on the one report where the colour IS
       the finding. print-color-adjust: exact is what overrides that, and it is
       scoped to this class so nothing else in the console starts printing in
       colour. -webkit- first for Chrome and Edge, which still want the prefix. */
    .variance-chip {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* The printed-on footer. A fixed position so it lands at the foot of every
       sheet rather than after the last row, which on a one-page report is
       halfway up the paper. */
    .report-print-footer {
        display: block !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        font-size: 8pt;
        border-top: 1px solid #ccc;
        padding-top: 4px;
    }
}

/* The screen half of the two print-only rules above. Written outside the media
   query so the elements are hidden by default and revealed by it, rather than
   the other way round -- a browser that ignored the print query would then show
   the paper furniture on screen, which is the worse failure. */
.print-only,
.report-print-footer {
    display: none;
}
