﻿@media print {
    /* ========================================================================= */
    /* === SECCIÓN 1: CONFIGURACIÓN GENERAL BÁSICA === */
    /* ========================================================================= */

    .noprint,
    .mud-button-close,
    .mud-appbar,
    .mud-drawer,
    .mud-dialog-actions {
        display: none !important;
    }

    body, .mud-main-content, .mud-container, .mud-paper {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background-color: white !important;
    }

    .mud-dialog-paper {
        box-shadow: none !important;
        background: white !important;
    }

    /* ========================================================================= */
    /* === SECCIÓN 2: ESTILOS PARA EL ENCABEZADO DEL REPORTE === */
    /* ========================================================================= */

    .encabezado-compacto {
        padding: 4px 8px !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        border-bottom: 2px solid black !important; /* Separador visual */
        margin-bottom: 10px !important;
    }

        .encabezado-compacto .mud-grid {
            display: flex !important;
            justify-content: space-between !important;
            align-items: flex-start !important;
        }

        .encabezado-compacto .mud-item,
        .mud-grid, .mud-item {
            margin: 0 !important;
            padding: 0 !important;
        }

        .encabezado-compacto .mud-text {
            font-size: 10px !important;
            line-height: 1.2 !important;
        }

    /* ========================================================================= */
    /* === SECCIÓN 3: ESTILOS Y ESTRUCTURA DE LA TABLA === */
    /* ========================================================================= */

    .mud-table, .mud-table-container table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    /* Regla general para todas las celdas (original) */
    th, td {
        display: table-cell !important;
        vertical-align: middle;
        font-size: 10px !important;
        border: none !important;
        white-space: nowrap !important;
        word-wrap: normal !important;
        padding: 1px 4px !important; /* Un poco más de padding horizontal */
    }

    thead, .mud-table-container thead {
        display: table-header-group !important;
    }

    /* --- AJUSTE DE LA PRIMERA COLUMNA --- */
    .mud-table th:first-child,
    .mud-table td:first-child {
        max-width: 130px !important; /* Límite de ancho */
        white-space: normal !important; /* Permitir salto de línea */
        overflow-wrap: break-word !important; /* Romper palabras largas */
    }
    /* --- AJUSTE DE LA SEGUNDA COLUMNA --- */
    .mud-table th:nth-child(2),
    .mud-table td:nth-child(2) {
        max-width: 130px !important; /* Ajusta el ancho como necesites */
        white-space: normal !important; /* Permitir salto de línea */
        overflow-wrap: break-word !important; /* Romper palabras largas */
    }

    /* --- AJUSTE DE ALINEACIÓN DE ENCABEZADOS Y DATOS --- */
    .mud-table thead th:not(:first-child),
    .mud-table tbody td:not(:first-child),
    .mud-table tfoot td:not(:first-child) {
        text-align: right !important; /* Alinear todo (menos la primera col) a la derecha */
    }

    .mud-table thead th {
        font-weight: bold !important; /* Negritas para el encabezado principal */
    }

    /* --- BORDES PARA GRUPOS (LA SOLUCIÓN ESTRUCTURAL) --- */

    /* Borde para encabezado de grupo (Vendedor/Comprador) */
    .mud-table tbody th[colspan] {
        border-top: 1px solid #aaaaaa !important;
        text-align: left !important; /* Los encabezados de grupo se ven mejor a la izquierda */
    }

    /* Borde y negritas para pie de grupo (Totales) */
    .mud-table tbody tr:last-child > th,
    .mud-table tbody tr:last-child > td {
        border-top: 1px solid #aaaaaa !important;
        font-weight: bold !important;
    }


    /* ========================================================================= */
    /* === SECCIÓN 4: CONTROL DE PÁGINA Y OTROS === */
    /* ========================================================================= */
    .no-break, tr, .mud-table-group-row {
        page-break-inside: avoid !important;
    }
}
