/*
 * Paperly global print stylesheet.
 *
 * Linked with media="print" from every shell layout, so nothing declared here
 * can reach the screen.
 *
 * Why it exists: browser print (right-click -> Print, Ctrl/Cmd-P) produced a
 * blank sheet on every screen in the app. The theme carries an unscoped
 *
 *     @media print {
 *       body * { visibility: hidden }
 *       #print-area, #print-area * { visibility: visible }
 *     }
 *
 * written for the three order-receipt views that wrap their invoice in
 * #print-area and print it out of an open modal. Every other view has no
 * #print-area, so the first half of that rule hid the page and nothing put it
 * back.
 *
 * This sheet gives those other views a printable page: the theme's blanket hide
 * is undone, the app chrome is dropped, the content column loses the header and
 * sidebar offsets, and the scroll containers are un-clipped so what sits below
 * the fold lands on the paper too.
 *
 * The receipt views keep their isolate-and-print behaviour: the restore below is
 * scoped away from them, so they still print the invoice and nothing else. What
 * does reach them is the paper size and the rule dropping .btn, which takes the
 * Edit, Save and Cancel buttons off a printed invoice.
 *
 * A page that needs an element we drop here can opt it back in with Bootstrap's
 * own .d-print-* utilities, which are re-declared at the foot of this file.
 */

/* Let the print dialog choose the paper. The theme pins @page to a3, so an a4
   printer scales the whole page down -- the opposite of what a timetable pinned
   to a wall wants. */
@page {
    size: auto;
    margin: 12mm;
}

/*
 * 1. Undo the theme's blanket hide -- but only on a view that does not claim
 *    the page for itself. :has() keeps the three #print-area receipts on the
 *    behaviour they already have.
 *
 *    Deliberately not !important: .invisible carries !important of its own, so
 *    an element a view hid on purpose stays hidden.
 */
body:not(:has(#print-area)) * {
    visibility: visible;
}

/*
 * 2. App chrome. The header and sidebars are position: fixed, so on paper they
 *    would otherwise stamp themselves over the first page and nowhere else.
 */
.main-header,
.side-content-wrap,
.sidebar-left,
.sidebar-left-secondary,
.sidebar-panel,
.inbox-main-sidebar,
.sidebar-overlay,
#preloader,
#custom-preloader,
.loadscreen,
.processing-screen,
.modal-backdrop,
#toast-container,
.hopscotch-bubble,
.tooltip,
.popover,
.select2-container--open,
.ui-datepicker,
#google_translate_element,
.skiptranslate {
    display: none !important;
}

/* Controls that do nothing once the page is on paper. .dataTables_info is
   deliberately not among them: a paginated table still prints only the page
   that is on screen, and "Showing 1 to 10 of 57 entries" is the only thing on
   the paper that says so. */
.btn,
.dt-buttons,
.dataTables_length,
.dataTables_filter,
.dataTables_paginate,
.pagination {
    display: none !important;
}

/*
 * 3. The content column is sized around the fixed header (margin-top) and the
 *    sidebar (float + width), neither of which is on the page any more.
 */
.app-admin-wrap,
.main-content-wrap,
.main-content-wrap.sidenav-open {
    float: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    background: #fff !important;
}

.main-content-wrap > .container,
.main-content-wrap .main-content {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/*
 * 4. Anything that scrolls on screen prints only the slice that happens to be
 *    in view, which is how a long list loses most of itself. fullCalendar's own
 *    print sheet does this for .fc-scroller; these are the rest.
 */
.table-responsive,
.dataTables_scrollBody,
.dataTables_scrollHead,
.ps {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

/*
 * 5. fullCalendar's list view (the music timetable's "List View") paints each
 *    lesson row with the lesson colour and a matching text colour, both as
 *    inline styles. Browsers drop background colours when printing but keep the
 *    text colour, which leaves white text on white paper. A list row is not an
 *    .fc-event, so fullCalendar's print sheet does not cover it.
 */
.fc-list-item,
.fc-list-item > td,
.fc-list-item a {
    background: transparent !important;
    color: #000 !important;
}

/*
 * 6. Bootstrap's print utilities stay the escape hatch for a view that needs an
 *    element we drop above. Re-declared because this sheet loads after the
 *    theme and would otherwise win on source order.
 */
.d-print-none {
    display: none !important;
}

.d-print-inline {
    display: inline !important;
}

.d-print-inline-block {
    display: inline-block !important;
}

.d-print-block {
    display: block !important;
}

.d-print-table {
    display: table !important;
}

.d-print-table-row {
    display: table-row !important;
}

.d-print-table-cell {
    display: table-cell !important;
}

.d-print-flex {
    display: flex !important;
}

.d-print-inline-flex {
    display: inline-flex !important;
}
