/* Print Styles - SOLO mostrar contenido de factura */
/* Versión 3 - Más agresiva en ocultar elementos */

/* Oculto por defecto */
#pos-ticket-print {
    display: none;
    position: absolute;
    left: -9999px;
    top: 0;
}

@media print {

    /* PASO 1: Resetear ABSOLUTAMENTE TODO */
    *,
    *::before,
    *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    html {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        position: relative !important;
    }

    /* PASO 2: Ocultar AGRESIVAMENTE todos los elementos de UI */
    body>*:not(#pos-ticket-print),
    #app-container,
    #app-container *,
    #loading-screen,
    #loading-screen *,
    #toast-container,
    #toast-container *,
    #modal,
    #modal *,
    .modal-overlay,
    .modal-overlay *,
    .sidebar,
    .sidebar *,
    .top-bar,
    .top-bar *,
    .main-content,
    .content-area,
    nav,
    aside,
    header:not(.print-header),
    footer:not(.print-footer),
    script,
    link,
    style,
    [id="loading-screen"],
    [id="app-container"],
    [id="toast-container"],
    [id="modal"] {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        max-width: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -99999px !important;
        top: -99999px !important;
        opacity: 0 !important;
        pointer-events: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    /* PASO 3: Mostrar SOLO el contenedor de impresión */
    #pos-ticket-print {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 1 !important;
        background: white !important;
        color: black !important;
    }

    /* PASO 4: Mostrar todo el contenido dentro del contenedor */
    #pos-ticket-print {
        visibility: visible !important;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }

    /* Preserve specific display types */
    #pos-ticket-print div {
        display: block !important;
    }

    /* Restaurar display correcto para elementos de tabla */
    #pos-ticket-print table {
        display: table !important;
    }

    #pos-ticket-print thead {
        display: table-header-group !important;
    }

    #pos-ticket-print tbody {
        display: table-row-group !important;
    }

    #pos-ticket-print tr {
        display: table-row !important;
    }

    #pos-ticket-print th,
    #pos-ticket-print td {
        display: table-cell !important;
    }

    /* Restaurar display para elementos inline */
    #pos-ticket-print span,
    #pos-ticket-print b,
    #pos-ticket-print strong,
    #pos-ticket-print i,
    #pos-ticket-print em,
    #pos-ticket-print a {
        display: inline !important;
    }

    /* Permitir backgrounds solo en el contenedor de impresión */
    #pos-ticket-print,
    #pos-ticket-print * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Permitir backgrounds específicos para encabezados */
    #pos-ticket-print [style*="background"] {
        background: inherit !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Configuración de página A4 */
    @page {
        margin: 5mm;
        size: A4 portrait;
    }
}

/* ============================================ */
/* Estilos para contenido de impresión         */
/* ============================================ */

/* Print Page Layout */
.print-page {
    page-break-after: always;
    break-after: page;
    min-height: 0;
    padding: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    color: black;
}

.print-page:last-child {
    page-break-after: auto;
    break-after: auto;
}

/* Page break class */
.page-break {
    page-break-before: always;
    break-before: page;
    height: 0;
    display: block;
}

.document-type-label {
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 10px;
    padding: 5px;
    border: 1px solid #000;
    display: inline-block;
    align-self: center;
}

/* Ticket Format */
.ticket-format {
    max-width: 300px;
    margin: 0 auto;
    font-family: 'Courier New', Courier, monospace;
}

.ticket-format table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

.ticket-format th,
.ticket-format td {
    padding: 4px 2px;
    border-bottom: 1px dashed #000;
}

/* Invoice Format */
.invoice-format {
    max-width: 100%;
    font-family: Arial, sans-serif;
    padding: 20px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}

.invoice-details {
    text-align: right;
}

.document-type-box {
    display: inline-block;
    border: 2px solid #000;
    padding: 5px 15px;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.invoice-table th {
    background-color: #f0f0f0;
    border: 1px solid #000;
    padding: 8px;
    text-align: center;
}

.invoice-table td {
    border: 1px solid #000;
    padding: 8px;
}

.invoice-footer {
    margin-top: 20px;
    border-top: 1px solid #000;
    padding-top: 10px;
}

/* ARBA Invoice Format */
.invoice-arba {
    max-width: 100%;
    font-family: Arial, sans-serif;
    padding: 30px;
    border: 1px solid #000;
    margin: 10px;
}

.arba-header {
    display: flex;
    justify-content: space-between;
    border: 1px solid #000;
    position: relative;
    margin-bottom: 20px;
}

.arba-header-left,
.arba-header-right {
    width: 45%;
    padding: 10px;
}

.arba-header-center {
    width: 10%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    background: #fff;
}

.letter-box {
    width: 40px;
    height: 40px;
    border: 1px solid #000;
    background: #fff;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -1px;
    border-top: 0;
}

.letter-code {
    font-size: 10px;
    font-weight: bold;
    margin-top: 5px;
}

.arba-header-right {
    border-left: 0;
}

.document-type-label-small {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.arba-client-info {
    border: 1px solid #000;
    padding: 10px;
    margin-bottom: 20px;
    background: #f9f9f9;
}

.arba-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.arba-table th {
    border: 1px solid #000;
    padding: 5px;
    background: #ccc;
    font-size: 0.9rem;
}

.arba-table td {
    border: 1px solid #000;
    padding: 5px;
    font-size: 0.9rem;
}

.arba-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.arba-totals {
    width: 40%;
    margin-left: auto;
}

.total-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.total-final {
    font-weight: bold;
    font-size: 1.2rem;
    border-top: 2px solid #000;
    padding-top: 5px;
}

/* Modern Invoice Format */
.invoice-modern {
    max-width: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 40px;
    color: #333;
}

.modern-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
}

.modern-brand h1 {
    font-size: 2.5rem;
    margin: 0;
    color: #2c3e50;
}

.modern-meta {
    text-align: right;
}

.modern-tag {
    background: #2c3e50;
    color: white;
    padding: 5px 15px;
    display: inline-block;
    font-weight: bold;
    margin-bottom: 10px;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.modern-table th {
    text-align: left;
    padding: 10px;
    border-bottom: 2px solid #eee;
    color: #7f8c8d;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.modern-table td {
    padding: 15px 10px;
    border-bottom: 1px solid #eee;
}

.modern-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.modern-total {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    min-width: 250px;
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
}

.modern-bottom {
    margin-top: 50px;
    text-align: center;
    color: #95a5a6;
    font-size: 0.9rem;
}