/* Formatos de factura — Contado ticket 55mm (plantilla cliente) y Crédito 8x10 */
:root {
    --fac-tinta: #111827;
    --fac-suave: #6b7280;
    --fac-linea: #d1d5db;
    --fac-acento: #4293E1;
    --ancho-papel: 55mm;
    --fuente-ticket: 11px;
}

.fac-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fac-tab {
    padding: 8px 14px; border: 2px solid var(--border); background: #fff;
    border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; color: var(--text);
}
.fac-tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.fac-tab.credit.active { background: #ecfdf5; border-color: #0f766e; color: #0f766e; }

.fac-layout {
    display: grid; gap: 14px;
    grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
    .fac-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
}
.fac-ajustes {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow);
}
.fac-ajustes h3 {
    margin: 0 0 10px; font-size: 0.85rem; letter-spacing: .04em;
    text-transform: uppercase; color: var(--fac-acento);
}
.fac-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.fac-campo { display: flex; flex-direction: column; gap: 4px; }
.fac-campo label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; }
.fac-campo input, .fac-campo textarea {
    font: inherit; font-size: 0.88rem; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 8px; width: 100%;
}
.fac-campo textarea { resize: vertical; min-height: 70px; }
.fac-logo-prev {
    height: 48px; max-width: 160px; object-fit: contain;
    border: 1px dashed var(--border); border-radius: 6px; padding: 2px; background: #fff;
}
.fac-preview-wrap {
    overflow: auto; background: #e5e7eb; border-radius: var(--radius);
    padding: 12px; border: 1px solid var(--border); max-width: 100%;
}
.fac-preview-wrap:has(.fac-ticket-55) {
    display: flex;
    justify-content: center;
    background: #cbd5e1;
}

/* ====== Ticket contado 55 mm (HTML del cliente) ====== */
.fac-hoja-contado,
.fac-ticket-55 {
    width: var(--ancho-papel);
    max-width: var(--ancho-papel);
    min-height: 10mm;
    height: auto;
    margin: 0 auto;
    padding: 2mm;
    background: #fff;
    box-shadow: 0 0 6px rgba(0,0,0,.25);
    font-family: "Arial Narrow", Arial, Helvetica, sans-serif;
    font-size: var(--fuente-ticket);
    color: #000;
    box-sizing: border-box;
    -webkit-font-smoothing: none;
}
.fac-ticket-55 .center { text-align: center; }
.fac-ticket-55 .right { text-align: right; }
.fac-ticket-55 .bold { font-weight: bold; }
.fac-ticket-55 .upper { text-transform: uppercase; }
.fac-ticket-55 .logo {
    max-width: 30mm; max-height: 20mm;
    display: block; margin: 0 auto 1mm;
}
.fac-ticket-55 .negocio {
    font-size: 14px; font-weight: bold; line-height: 1.1; margin-bottom: 1mm;
}
.fac-ticket-55 .mini { font-size: 10px; line-height: 1.25; }
.fac-ticket-55 .titulo-doc {
    font-size: 12px; font-weight: bold; margin: 1.5mm 0;
    border: 1px solid #000; padding: 0.6mm 0;
}
.fac-ticket-55 .sep {
    border-top: 1px dashed #000; margin: 1.5mm 0;
}
.fac-ticket-55 .fila {
    display: flex; justify-content: space-between; gap: 2mm; line-height: 1.3;
}
.fac-ticket-55 .fila span:last-child { text-align: right; }
.fac-ticket-55 table {
    width: 100%; border-collapse: collapse; font-size: 10px;
}
.fac-ticket-55 th {
    border-bottom: 1px solid #000; text-align: left;
    padding: 0.5mm 0; font-size: 10px;
}
.fac-ticket-55 td { padding: 0.4mm 0; vertical-align: top; }
.fac-ticket-55 .desc { word-break: break-word; }
.fac-ticket-55 .num { text-align: right; white-space: nowrap; }
.fac-ticket-55 .totales .fila { font-size: 11px; }
.fac-ticket-55 .total-grande {
    font-size: 14px; font-weight: bold;
    border-top: 1px solid #000; border-bottom: 1px solid #000;
    padding: 1mm 0; margin: 1mm 0;
}
.fac-ticket-55 .firma {
    margin-top: 8mm; border-top: 1px solid #000;
    padding-top: 1mm; font-size: 10px; text-align: center;
}
.fac-ticket-55 .gracias { margin-top: 2mm; font-size: 10px; }

.modal.modal-ticket-55 {
    max-width: min(340px, 96vw) !important;
}
.modal.modal-ticket-55 .modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Crédito — 8in x 10in */
.fac-hoja-credito {
    width: 8in; height: 10in; margin: 0 auto; background: #fff;
    padding: 0.35in 0.38in; display: flex; flex-direction: column;
    box-shadow: 0 2px 14px rgba(0,0,0,.12); overflow: hidden;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 10pt; color: var(--fac-tinta); box-sizing: border-box;
}
.fac-hoja-credito .enc {
    display: flex; gap: 14px; align-items: flex-start;
    border-bottom: 2px solid var(--fac-tinta); padding-bottom: 8px;
}
.fac-hoja-credito .enc img { height: 0.85in; max-width: 1.7in; object-fit: contain; }
.fac-hoja-credito .neg { flex: 1; min-width: 0; }
.fac-hoja-credito .neg .nombre {
    font-size: 19pt; font-weight: 800; line-height: 1.05;
    letter-spacing: -.01em; text-transform: uppercase;
}
.fac-hoja-credito .neg .fiscal { font-size: 8.2pt; color: var(--fac-suave); line-height: 1.4; margin-top: 3px; }
.fac-hoja-credito .doc { text-align: right; font-size: 8.4pt; line-height: 1.45; white-space: nowrap; }
.fac-hoja-credito .doc .tit { font-size: 12pt; font-weight: 800; letter-spacing: .06em; color: #0f766e; }
.fac-hoja-credito .meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px;
    font-size: 8.6pt; padding: 7px 0; border-bottom: 1px solid var(--fac-linea);
}
.fac-hoja-credito .meta span {
    color: var(--fac-suave); font-weight: 600; text-transform: uppercase;
    font-size: 7.2pt; letter-spacing: .04em;
}
.fac-hoja-credito .tabla-wrap { flex: 1; overflow: hidden; margin-top: 7px; }
.fac-hoja-credito table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.fac-hoja-credito thead th {
    background: var(--fac-tinta); color: #fff; font-size: 7.6pt;
    letter-spacing: .05em; text-transform: uppercase; padding: 5px 6px; text-align: right;
}
.fac-hoja-credito thead th:nth-child(1) { text-align: center; width: 8%; }
.fac-hoja-credito thead th:nth-child(2) { text-align: left; }
.fac-hoja-credito tbody td { padding: 3.5px 6px; border-bottom: 1px solid #e5e7eb; text-align: right; }
.fac-hoja-credito tbody td:nth-child(1) { text-align: center; }
.fac-hoja-credito tbody td:nth-child(2) { text-align: left; }
.fac-hoja-credito .zona {
    display: flex; gap: 14px; align-items: stretch;
    border-top: 1px solid var(--fac-linea); padding-top: 8px; margin-top: 6px;
}
.fac-hoja-credito .pagare {
    flex: 1; border: 1px solid var(--fac-tinta); border-radius: 6px;
    padding: 8px 10px; font-size: 7.8pt; line-height: 1.38; text-align: justify;
}
.fac-hoja-credito .pagare h3 {
    margin: 0 0 4px; font-size: 8.6pt; letter-spacing: .08em;
    text-transform: uppercase; color: #0f766e; text-align: center;
}
.fac-hoja-credito .totales { width: 2.7in; font-size: 9.2pt; }
.fac-hoja-credito .totales > div { display: flex; justify-content: space-between; padding: 2.5px 0; }
.fac-hoja-credito .totales .gran {
    border-top: 2px solid var(--fac-tinta); margin-top: 4px; padding-top: 5px;
    font-size: 12.5pt; font-weight: 800; color: #0f766e;
}
.fac-hoja-credito .totales .credito {
    margin-top: 8px; border: 1px dashed var(--fac-linea); border-radius: 6px;
    padding: 6px 8px; font-size: 8pt; display: block;
}
.fac-hoja-credito .totales .credito p { margin: 0 0 2px; display: flex; justify-content: space-between; }
.fac-hoja-credito .totales .credito p span { color: var(--fac-suave); }
.fac-hoja-credito .mensaje {
    font-size: 8pt; line-height: 1.35; color: var(--fac-suave); white-space: pre-line;
    border-top: 1px solid var(--fac-linea); margin-top: 8px; padding-top: 6px; text-align: center;
}
.fac-hoja-credito .firmas { display: flex; gap: 0.7in; justify-content: space-between; margin-top: 0.35in; }
.fac-hoja-credito .firma {
    flex: 1; border-top: 1px solid var(--fac-tinta); text-align: center;
    font-size: 8pt; padding-top: 3px; color: var(--fac-suave);
}
.fac-hoja-credito .firma b { display: block; color: var(--fac-tinta); font-size: 8.4pt; }

@media print {
    @page fac-contado { size: 55mm auto; margin: 0; }
    @page fac-credito { size: 8in 10in; margin: 0; }
    #print-root.print-fac-contado .fac-hoja-contado,
    #print-root.print-fac-contado .fac-ticket-55 {
        page: fac-contado;
        width: 55mm !important;
        max-width: 55mm !important;
        margin: 0 !important;
        padding: 1.5mm !important;
        box-shadow: none !important;
        height: auto !important;
    }
    #print-root.print-fac-credito .fac-hoja-credito {
        page: fac-credito; margin: 0; box-shadow: none;
        width: 8in !important; height: 10in !important;
    }
}
