/* =====================================================
   FACTURA DE COMPRA – DISEÑO ERP ESTABLE DEFINITIVO
   ===================================================== */

/* -----------------------------------------------------
   CONTENEDOR GENERAL
   ----------------------------------------------------- */
.contenedor {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* -----------------------------------------------------
   BLOQUES SUPERIORES (DOCUMENTO / PROVEEDOR)
   ----------------------------------------------------- */
.doc-consecutivo,
.doc-consecutivo-proveedor,
.doc-fecha-registro,
.doc-fecha-factura,
.doc-fecha-vencimiento,
.doc-NIT,
.doc-Razon-social {

    position: absolute;
    z-index: 10;
    background: oklch(89.56% 0.01198 203.914);
    padding: 6px 8px;
    border-radius: 8px;
}

/* Posiciones */
.doc-consecutivo { top: 120px; left: 80px; width: 150px; }
.doc-consecutivo-proveedor {
    top: 120px;
    left: 600px;
    width: 220px;
}

.doc-NIT { top: 200px; left: 80px; width: 300px; }
.doc-Razon-social { top: 257px; left: 80px; width: 300px; }

.doc-fecha-registro { top: 120px; right: 80px; width: 150px; }
.doc-fecha-factura { top: 180px; right: 80px; width: 150px; }
.doc-fecha-vencimiento { top: 240px; right: 80px; width: 150px; }

/* Labels */
.doc-consecutivo label,
.doc-consecutivo-proveedor label,
.doc-fecha-registro label,
.doc-fecha-factura label,
.doc-fecha-vencimiento label,
.doc-NIT label,
.doc-Razon-social label {
    font-size: 11px;
    color: #374151;
    display: block;
    margin-bottom: 2px;
}

/* Inputs superiores */
.doc-consecutivo input,
.doc-consecutivo-proveedor input,
.doc-fecha-registro input,
.doc-fecha-factura input,
.doc-fecha-vencimiento input,
.doc-NIT input,
.doc-Razon-social input {
    width: 100%;
    height: 26px;
    padding: 4px 6px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid #9ca3af;
    background: #ffffff;
}

/* -----------------------------------------------------
   BLOQUE TABLA FACTURA
   ----------------------------------------------------- */
.doc-detalle-factura {
    margin: 220px auto 0 auto;
    width: calc(100% - 100px);
    background: #f3f4f6;
    padding: 14px 16px;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

/* -----------------------------------------------------
   TABLA FACTURA
   ----------------------------------------------------- */
#tablaDetalle {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

/* Encabezados */
#tablaDetalle thead th {
    background: #e5e7eb;
    color: #1f2937;
    font-weight: 600;
    font-size: 11.5px;
    padding: 6px 4px;
    text-align: center;
    border-bottom: 1px solid #cbd5e1;
    white-space: nowrap;
}

/* Celdas */
#tablaDetalle td {
    padding: 4px;
    background: #ffffff;
    vertical-align: middle;
}

/* Inputs y selects */
#tablaDetalle input,
#tablaDetalle select {
    width: 100%;
    height: 24px;
    padding: 2px 4px;
    font-size: 11.5px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
}

/* Focus */
#tablaDetalle input:focus,
#tablaDetalle select:focus {
    outline: none;
    border-color: #6366f1;
}

/* -----------------------------------------------------
   ANCHOS DE COLUMNAS
   ----------------------------------------------------- */
#tablaDetalle th:nth-child(1),
#tablaDetalle td:nth-child(1) { width: 70px; }

#tablaDetalle th:nth-child(2),
#tablaDetalle td:nth-child(2) { width: 60px; }

#tablaDetalle th:nth-child(3),
#tablaDetalle td:nth-child(3) { width: 90px; }

#tablaDetalle th:nth-child(4),
#tablaDetalle td:nth-child(4) { width: 140px; }

#tablaDetalle th:nth-child(5),
#tablaDetalle td:nth-child(5) { width: 90px; }

#tablaDetalle th:nth-child(6),
#tablaDetalle td:nth-child(6) { width: 160px; }

#tablaDetalle th:nth-child(7),
#tablaDetalle td:nth-child(7) { width: 90px; }

#tablaDetalle th:nth-child(8),
#tablaDetalle td:nth-child(8) { width: 80px; }

#tablaDetalle th:nth-child(9),
#tablaDetalle td:nth-child(9) { width: 80px; }

#tablaDetalle th:nth-child(10),
#tablaDetalle td:nth-child(10) { width: 80px; }

#tablaDetalle th:nth-child(11),
#tablaDetalle td:nth-child(11) { width: 90px; }

#tablaDetalle th:nth-child(12),
#tablaDetalle td:nth-child(12) { width: 60px; }

/* Alineación numérica */
#tablaDetalle td:nth-child(5),
#tablaDetalle td:nth-child(6),
#tablaDetalle td:nth-child(7),
#tablaDetalle td:nth-child(8),
#tablaDetalle td:nth-child(9),
#tablaDetalle td:nth-child(10),
#tablaDetalle td:nth-child(11) {
    text-align: right;
}

/* Total resaltado */
#tablaDetalle td:nth-child(11) input {
    font-weight: 600;
    background: #f8fafc;
}

/* Botones + / ✖ */
#tablaDetalle .acciones button {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #f9fafb;
    cursor: pointer;
}

#tablaDetalle .acciones button:hover {
    background: #e5e7eb;
}

/* -----------------------------------------------------
   TOTALES FACTURA
   ----------------------------------------------------- */
.totales-factura {
    margin-top: 12px;
    margin-left: auto;
    width: 280px;
    background: #ffffff;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.total-linea {
    display: none;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.total-linea.total-final {
    border-top: 1px solid #cbd5e1;
    margin-top: 8px;
    padding-top: 8px;
    font-weight: 600;
}

/* -----------------------------------------------------
   AUTOCOMPLETE NIT (FIX DEFINITIVO)
   ----------------------------------------------------- */
#listaNIT {
    position: fixed;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    z-index: 999999999;
    pointer-events: auto;
}

.autocomplete-item {
    padding: 6px 8px;
    cursor: pointer;
    font-size: 13px;
}

.autocomplete-item:hover {
    background: #e5e7eb;
}

/* -----------------------------------------------------
   AUTOCOMPLETE PUC
   ----------------------------------------------------- */
.puc-overlay {
    position: fixed;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    z-index: 9999999;
}

/* -----------------------------------------------------
   MODAL IVA (NO BLOQUEA NIT)
   ----------------------------------------------------- */
.modal-iva-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500000000;
}

.modal-iva-overlay.oculto {
    display: none;
    pointer-events: none;
}

.modal-iva {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    width: 420px;
    max-width: 90%;
    margin: 10vh auto;
    pointer-events: auto;
}

/* =============================
   PANEL IVA CONTABLE
   ============================= */
/* =============================
   PANEL IVA CONTABLE (CON SCROLL)
   ============================= */
.iva-panel {
    position: fixed;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 6px 0;
    width: 320px;

    /* 👇 LO IMPORTANTE */
    max-height: 220px;      /* altura visible */
    overflow-y: auto;       /* scroll vertical */
    
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    z-index: 9999999;
}


.iva-opcion {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.iva-opcion:hover {
    background: #e5e7eb;
}


/* =============================
   COMENTARIOS FACTURA
   ============================= */

.comentarios-factura {
    margin-top: 30px;              /* separación de la tabla */
    margin-bottom: 20px;
    padding: 18px 22px;

    background-color: oklch(89.56% 0.01198 203.914);
    border-radius: 14px;

    

    width: calc(100% - 360px);     /* deja espacio para totales */
}

/* Título */
.comentarios-factura label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #444;
    margin-bottom: 10px;
}

/* Área de texto */
.comentarios-factura textarea {
    width: 90%;
    min-height: 20px;

    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;

    border-radius: 10px;
    border: 1px solid #cfd6dd;

    resize: vertical;
    outline: none;

    background-color: #fafafa;
}

/* Enfoque */
.comentarios-factura textarea:focus {
    border-color: #6aa0d8;
    background-color: #ffffff;
}

/* =============================
   COMENTARIOS + TOTALES EN FILA
   ============================= */

#formFacturaCompra {
    display: flex;
    flex-wrap: wrap;
}

/* Comentarios a la izquierda */
.comentarios-factura {
    flex: 1;
    margin-right: 20px;
}

/* Totales a la derecha */
.totales-factura {
    width: 320px;
    margin-top: 30px;
}

/* =============================
   IVA INPUT CON INDICADOR
   ============================= */

.iva-input-box {
    display: flex;
    align-items: center;
    height: 28px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    overflow: hidden;
}

/* Input IVA */
.iva-input-box input.col-iva {
    border: none;
    height: 24px;
    padding: 2px 6px;
    font-size: 11.5px;
    text-align: right;
    flex: 1;
}

/* Indicador */
.iva-indicador {
    background: #f1f5f9;
    color: #6b7280;
    font-size: 10px;
    font-weight: 600;
    padding: 0 6px;
    height: 24px;
    display: flex;
    align-items: center;
    border-left: 1px solid #e5e7eb;
    white-space: nowrap;
}

/* Quitar focus doble */
.iva-input-box input:focus {
    outline: none;
}

/* =============================
   RETE FUENTE INPUT CON INDICADOR
   ============================= */

#tablaDetalle td .rte-input-box {
    width: 100%;
    height: 30px;
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    box-sizing: border-box;
    overflow: hidden;
}

#tablaDetalle td .rte-input-box input.col-rtefuente {
    height: 100%;
    border: none;
    padding: 2px 4px;
    font-size: 11.5px;
    text-align: right;
    flex: 1;
    min-width: 0;
    background: transparent;
}

#tablaDetalle td .rte-indicador {
    height: 100%;
    width: 42px;
    font-size: 10.5px;
    font-weight: 700;
    color: #6b7280;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid #e5e7eb;
}


/* =============================
   BOTONES ACCIONES FACTURA
   ============================= */

.acciones-factura {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 30px;
    padding-right: 6px;
}

/* Botón Cancelar */
.btn-cancelar {
    background: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancelar:hover {
    background: #d1d5db;
}

/* Botón Crear */
.btn-crear {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37,99,235,0.35);
}

.btn-crear:hover {
    background: #1d4ed8;
}


/* =============================
   FORZAR BOTONES DEBAJO DE TODO
   ============================= */

.acciones-factura {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 14px;

    margin-top: 40px;
    padding-right: 20px;

    /* 👇 CLAVE */
    clear: both;
}

