/* Reglas de impresion comunes a todas las paginas. Las reglas especificas de cada informe viven en su propio <style>. */

/*
 * Lista o tabla larga con scroll vertical en pantalla (max 500px) que en papel se expande completa.
 * Uso: class="report-scroll" en el contenedor (en tablas, sobre el propio div.table-responsive).
 * El thead y el tfoot quedan fijos mientras se hace scroll. Fuera del @media print por ser regla de pantalla.
 */
.report-scroll {
    max-height: 500px;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 0;
}

.report-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f8f9fa;
}

.report-scroll tfoot th,
.report-scroll tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background-color: #f8f9fa;
}

@media print {
    .report-scroll {
        max-height: none !important;
        overflow: visible !important;
    }

    .report-scroll thead th,
    .report-scroll tfoot th,
    .report-scroll tfoot td {
        position: static !important;
    }

    /* dynamic-colors.css fuerza overflow-x/min-height/padding para menus en pantalla; en papel recortan la tabla */
    .table-responsive {
        overflow: visible !important;
        min-height: 0 !important;
        padding-bottom: 0 !important;
    }

    /*
     * Grid de cards imprimible. Chrome superpone las cards en cada salto de pagina cuando una
     * fila flex (.row con gutter negativo) contiene columnas con break-inside: avoid y cards h-100.
     * Uso: <div class="row g-4 print-card-grid" style="--print-cols: 3"> con las columnas col-* y la card h-100 de siempre.
     * El stretch del grid iguala el alto de las cards por fila. Sin --print-cols son 2 columnas.
     */
    .print-card-grid {
        display: grid !important;
        grid-template-columns: repeat(var(--print-cols, 2), minmax(0, 1fr));
        gap: 0.5cm;
        margin: 0 !important;
    }

    /* Clase duplicada a proposito: sube la especificidad sobre .row > * y las utilidades px-*, que usan !important */
    .print-card-grid.print-card-grid > * {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        margin: 0 !important;
        padding: 0 !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Gráfica ApexCharts que escala al ancho del papel; el viewBox lo agrega print-helper.js en beforeprint */
    .print-fit-chart .apexcharts-canvas {
        width: auto !important;
        max-width: 100% !important;
    }

    .print-fit-chart .apexcharts-svg {
        max-width: 100% !important;
        height: auto !important;
    }

    .print-card-grid .card {
        transform: none !important;
    }
}
