/**
 * Nipun ERP — global print chrome
 * Hides sidebar / nav chrome and keeps main content full-width for Ctrl/Cmd+P.
 * Loaded from franchise-gov-theme-head.php and erp_print_responsive_assets().
 * Document-specific print CSS (receipts, ID cards, report cards) stays in page files.
 */

@media print {
    /* ---- Base page ---- */
    html,
    body {
        background: #fff !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ---- Hide navigation chrome ---- */
    #sidebar,
    #partner-sidebar,
    .fr-sidebar,
    .adm-sidebar,
    .fr-sidebar-logo-bar,
    #sidebar-backdrop,
    #fr-sidebar-mobile-fab,
    .fr-panel-global-bar,
    .fr-nav-jump,
    .fr-skip-link,
    .fr-embed-actions,
    .fr-hub-quick-nav,
    .fr-dash-command-bar,
    .sp-nav,
    .sp-inner-kids-header,
    .sp-inner-kids-toolbar,
    .sp-student-menu-fab,
    .pp-mobile-nav,
    .no-print,
    .noprint {
        display: none !important;
    }

    /* Ribbon stays as print header; hide action buttons only */
    .fr-premium-ribbon__actions-panel,
    .fr-premium-ribbon__actions,
    .fr-premium-ribbon__action-row {
        display: none !important;
    }

    /* ---- Franchise school portal shell ---- */
    body.fr-portal {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.fr-portal > .fr-sidebar-logo-bar,
    body.fr-portal > #sidebar.fr-sidebar,
    body.fr-portal > div.min-h-screen.flex > #sidebar.fr-sidebar {
        display: none !important;
    }

    body.fr-portal > .fr-portal-topbar,
    body.fr-portal > main,
    body.fr-portal > #page-main,
    body.fr-portal > div.min-h-screen.flex > #page-main,
    body.fr-portal > div.min-h-screen.flex > .flex-1.flex-col {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        position: static !important;
        transform: none !important;
        grid-area: auto !important;
    }

    body.fr-portal.fr-portal--dash-hero .fr-premium-ribbon--dashboard .fr-premium-ribbon__inner {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    body.fr-portal .fr-layout-section,
    body.fr-portal main .fr-dash-shell,
    body.fr-portal main > .p-6,
    body.fr-portal main > .p-4,
    body.fr-portal #page-main > .p-6,
    body.fr-portal #page-main > .p-4 {
        padding: 0.5rem 0 !important;
        max-width: none !important;
    }

    /* ---- Admin / partner / teacher shells ---- */
    body.pp-portal,
    body.tp-portal {
        display: block !important;
        width: 100% !important;
        overflow: visible !important;
    }

    body.pp-portal > aside,
    body.pp-portal > #sidebar,
    body.pp-portal > #partner-sidebar,
    body.tp-portal > aside,
    body.tp-portal > #sidebar {
        display: none !important;
    }

    body.pp-portal > main,
    body.pp-portal > .flex-1,
    body.tp-portal > main,
    body.tp-portal > .flex-1 {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ---- Student mobile shell ---- */
    body.sp-mobile-shell {
        padding-bottom: 0 !important;
    }

    body.sp-mobile-shell #sidebar,
    body.sp-mobile-shell #sidebar-backdrop {
        display: none !important;
    }

    body.sp-mobile-shell .sp-mobile-main,
    body.sp-mobile-shell main {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* ---- Main content areas ---- */
    main,
    #page-main,
    .min-h-screen,
    .sch-att-desk,
    .gov-form-shell,
    .fin-page-wrap {
        overflow: visible !important;
        width: 100% !important;
        max-width: none !important;
        min-height: 0 !important;
        height: auto !important;
        box-shadow: none !important;
    }

    /* ---- Restore responsive tables to real tables (not mobile card stack) ---- */
    .erp-table--cards,
    table[data-erp-table="responsive"] {
        display: table !important;
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .erp-table--cards thead,
    table[data-erp-table="responsive"] thead {
        display: table-header-group !important;
    }

    .erp-table--cards tbody,
    table[data-erp-table="responsive"] tbody {
        display: table-row-group !important;
    }

    .erp-table--cards tfoot,
    table[data-erp-table="responsive"] tfoot {
        display: table-footer-group !important;
    }

    .erp-table--cards tr,
    table[data-erp-table="responsive"] tr {
        display: table-row !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        page-break-inside: avoid;
    }

    .erp-table--cards th,
    .erp-table--cards td,
    table[data-erp-table="responsive"] th,
    table[data-erp-table="responsive"] td {
        display: table-cell !important;
        width: auto !important;
        padding: 0.35rem 0.5rem !important;
        border-bottom: 1px solid #e2e8f0 !important;
        font-size: inherit !important;
        line-height: 1.35 !important;
        vertical-align: top !important;
    }

    .erp-table--cards td::before,
    table[data-erp-table="responsive"] td::before {
        content: none !important;
        display: none !important;
    }

    .erp-table-wrap,
    .overflow-x-auto,
    .table-gov-wrap {
        overflow: visible !important;
        max-width: none !important;
        max-height: none !important;
        margin-inline: 0 !important;
        border-radius: 0 !important;
        border-left: 0 !important;
        border-right: 0 !important;
    }

    .erp-table-wrap thead th,
    table.erp-table thead th {
        position: static !important;
    }

    /* ---- Cards / panels ---- */
    .fr-dash-kpi-card,
    .fr-dash-mini-card,
    .fin-panel,
    .gov-card,
    .report-print-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* ---- Dark theme reset for print ---- */
    html[data-erp-theme="dark"] body.fr-portal {
        background: #fff !important;
        color: #000 !important;
    }
}
