/* css/impresion.css */

/* Hidden globally from UI */
#print-modal-container {
    display: none;
}

#print-modal-container.active {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

/* Base Ticket Wrapper for Previewing on Screen */
.ticket-preview-wrapper {
    background: #e2e8f0;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 90vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.ticket-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
    justify-content: center;
}

.ticket-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-print {
    background: #10b981;
    color: white;
}

.btn-print:hover {
    background: #059669;
}

.btn-pdf {
    background: #3b82f6;
    color: white;
}

.btn-pdf:hover {
    background: #2563eb;
}

.btn-close-ticket {
    background: #ef4444;
    color: white;
}

.btn-close-ticket:hover {
    background: #dc2626;
}


/* --- TICKET CONTENT (The Actual Receipt) --- */
.ticket-content {
    background: white;
    padding: 5mm;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.2;
    color: #000;
    overflow-y: auto;
    /* Paper-like texture/shadow for screen */
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}

/* Dynamic width by format (toggled by JS class) */
.ticket-content.format-80mm {
    width: 80mm;
    max-width: 80mm;
}

.ticket-content.format-58mm {
    width: 58mm;
    max-width: 58mm;
    font-size: 11px;
    /* Slightly smaller for 58mm */
    padding: 3mm;
}

/* Printing Typography */
.ticket-content h1,
.ticket-content h2,
.ticket-content h3,
.ticket-content p {
    margin: 0;
    padding: 0;
}

.ticket-header {
    text-align: center;
    margin-bottom: 10px;
}

.ticket-header .seniat {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 3px;
}

.ticket-header .rif {
    font-size: 1em;
    margin-bottom: 3px;
}

.ticket-header .nombre-comercial {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.ticket-header .razon-social {
    font-size: 0.9em;
    margin-bottom: 2px;
}

.ticket-header .direccion,
.ticket-header .contacto {
    font-size: 0.8em;
    margin-bottom: 2px;
}

.ticket-divider {
    border-top: 1px dashed #000;
    margin: 8px 0;
}

.ticket-client-info {
    text-align: left;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.ticket-client-info p {
    margin: 1px 0;
}

.ticket-doc-info {
    text-align: center;
    margin-bottom: 8px;
    font-weight: bold;
}

.ticket-datetime {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    margin-bottom: 5px;
}

/* Items Table */
.ticket-items table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.ticket-items th {
    text-align: left;
    border-bottom: 1px dashed #000;
    padding-bottom: 3px;
    font-weight: normal;
}

.ticket-items td {
    padding: 3px 0;
    vertical-align: top;
}

.ticket-items .col-prod {
    width: 100%;
}

.ticket-items .col-cant {
    text-align: center;
    white-space: nowrap;
    padding-left: 5px;
}

.ticket-items .col-precio {
    text-align: right;
    white-space: nowrap;
    padding-left: 5px;
}

.prod-qty-row {
    display: flex;
    justify-content: space-between;
    padding-left: 10px;
    color: #333;
}

/* Footer Totals */
.ticket-totals {
    margin-top: 10px;
    font-size: 0.9em;
}

.ticket-totals .row {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

.ticket-totals .row.big {
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 5px;
}

.ticket-footer {
    text-align: center;
    margin-top: 15px;
    font-size: 0.8em;
}

/* -------------------------------------
 *  PRINTING STYLES (OS Window.print)
 * ------------------------------------- */
@media print {

    /* Hide everything in the document */
    body * {
        visibility: hidden;
    }

    /* Except the ticket content */
    #print-ticket-area,
    #print-ticket-area * {
        visibility: visible;
    }

    /* Remove screen wrappers and shadows */
    #print-modal-container {
        position: absolute;
        left: 0;
        top: 0;
        background: transparent;
        display: block !important;
        width: auto;
        height: auto;
    }

    .ticket-preview-wrapper {
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    .ticket-content {
        box-shadow: none;
        margin: 0;
        padding: 0;
        /* Let printer margins do the work */
    }

    /* Hide the operation buttons */
    .ticket-actions {
        display: none !important;
    }

    /* Force Thermal Widths via Page Size */
    @page {
        margin: 0;
    }
}