/* =========================
   VARIABLES
========================= */

:root {
    --azul: #1f4e86;
    --azul-oscuro: #163b66;
    --gris-borde: #ddd;
    --gris-fondo: #f9f9f9;
    --gris-texto: #888;
    --texto: #111;
    --font: Arial, sans-serif;
    --font-size-base: 13px;
}

/* =========================
   RESET Y BASE
========================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    padding: 25px;
    background: #f5f5f5;
    color: var(--texto);
}

h1 {
    margin-top: 0;
    color: var(--azul);
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input,
textarea {
    width: 100%;
    padding: 9px;
    margin-bottom: 15px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    font-family: var(--font);
    font-size: var(--font-size-base);
}

/* =========================
   CONTENEDOR
========================= */

.contenedor {
    max-width: 1100px;
    margin: auto;
    background: #fff;
    padding: 25px;
    border-radius: 8px;
}

/* =========================
   ENCABEZADO FORMULARIO
========================= */

/* =========================
   ENCABEZADO FORMULARIO
========================= */

.encabezado-formulario {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gris-borde);
}

.accion-regresar-formulario {
    display: flex;
    justify-content: flex-start;
}

.logo-formulario {
    width: 260px;
    justify-self: center;
}

.logo-formulario img {
    max-width: 100%;
    height: auto;
    display: block;
}

.espacio-formulario {
    min-height: 1px;
}

.btn-regresar-inicio {
    display: inline-block;
    background: #777;
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    font-weight: bold;
    font-family: var(--font);
    font-size: 13px;
}

.btn-regresar-inicio:hover {
    background: #555;
    color: #fff;
}

/* =========================
   BUSCADOR
========================= */

.buscador-wrap {
    position: relative;
}

.resultados {
    display: none;
    border: 1px solid #ccc;
    background: #fff;
    max-height: 260px;
    overflow-y: auto;
    margin-top: -12px;
    margin-bottom: 15px;
    position: relative;
    z-index: 10;
}

.resultado-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: var(--font-size-base);
}

.resultado-item:hover {
    background: #f0f0f0;
}

/* =========================
   BOTONES
========================= */

button {
    background: var(--azul);
    color: white;
    border: none;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: bold;
    font-family: var(--font);
}

button:hover {
    background: var(--azul-oscuro);
}

/* =========================
   CAMPO EDITABLE CON VISTA
========================= */

.campo-editable-wrap {
    margin-bottom: 15px;
}

.campo-editable-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.campo-editable-header label {
    margin-bottom: 0;
}

.campo-editable-header button {
    padding: 5px 14px;
    font-size: 12px;
    background: var(--gris-texto);
    font-weight: normal;
}

.campo-editable-header button:hover {
    background: #555;
}

.campo-vista-defecto {
    width: 100%;
    padding: 9px;
    background: var(--gris-fondo);
    border: 1px solid #ccc;
    color: var(--gris-texto);
    font-size: var(--font-size-base);
    line-height: 1.6;
    white-space: pre-line;
    min-height: 90px;
}

/* =========================
   TABLA PREVIA
========================= */

.tabla-previa {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: var(--font-size-base);
}

.tabla-previa th {
    background: var(--azul);
    color: #fff;
    padding: 8px;
    text-align: left;
}

.tabla-previa td {
    border-bottom: 1px solid var(--gris-borde);
    padding: 8px;
    vertical-align: top;
}

/* =========================
   PREVIEW COTIZACIÓN
========================= */

.producto-preview {
    display: none;
    border: 1px solid var(--gris-borde);
    padding: 20px;
    margin-top: 20px;
    background: #fff;
}

/* =========================
   ENCABEZADO COTIZACIÓN
========================= */

.encabezado-cotizacion {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 35px;
}

.logo-cotizacion {
    max-width: 270px;
    height: auto;
}

.datos-empresa {
    text-align: right;
    font-size: 14px;
    line-height: 1.5;
}

.fecha-cotizacion {
    text-align: right;
    font-size: 16px;
    margin-bottom: 30px;
}

/* =========================
   TABLA COTIZACIÓN
========================= */

.tabla-cotizacion {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 20px;
    font-size: var(--font-size-base);
}

.tabla-cotizacion th {
    background: var(--azul);
    color: #fff;
    padding: 8px;
    text-align: left;
}

.tabla-cotizacion td {
    padding: 7px 10px;
    vertical-align: top;
    border-bottom: 1px solid var(--gris-borde);
    line-height: 1.35;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tabla-cotizacion th:nth-child(1),
.tabla-cotizacion td:nth-child(1) {
    width: 45%;
}

.tabla-cotizacion th:nth-child(2),
.tabla-cotizacion td:nth-child(2) {
    width: 10%;
    text-align: center;
}

.tabla-cotizacion th:nth-child(3),
.tabla-cotizacion td:nth-child(3),
.tabla-cotizacion th:nth-child(4),
.tabla-cotizacion td:nth-child(4),
.tabla-cotizacion th:nth-child(5),
.tabla-cotizacion td:nth-child(5) {
    width: 15%;
    text-align: right;
}

/* =========================
   FILAS DE PRODUCTO
========================= */

.producto-fila-principal td {
    border-bottom: none !important;
    padding-top: 4px !important;
    padding-bottom: 0 !important;
}

.producto-nombre-tabla {
    font-weight: bold;
    vertical-align: top;
}

.producto-detalle-fila {
    border-bottom: 1px solid var(--gris-borde);
    padding-top: 0;
}

.producto-detalle-layout {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 25px;
    padding: 0 0 10px 0;
    margin-top: -8px;
}

.producto-detalle-layout.sin-imagen {
    display: block;
}

.producto-descripcion {
    width: 42%;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-line;
    color: var(--texto);
}

.producto-descripcion-full {
    width: 100%;
}

.producto-imagen {
    width: 55%;
    text-align: center;
    padding-top: 25px;
}

.img-producto-cotizacion {
    max-width: 360px;
    max-height: 230px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* =========================
   RÉGIMEN + TOTALES
========================= */

.resumen-cotizacion {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    margin-top: 25px;
    padding: 8px 0;
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
}

.regimen-final {
    width: 45%;
    font-size: var(--font-size-base);
    line-height: 1.4;
}

.regimen-final strong {
    display: block;
    margin-bottom: 4px;
}

#regimenFinal {
    white-space: pre-line;
}

.totales-cotizacion {
    width: 45%;
    margin-left: 0;
    margin-top: 0;
    font-size: var(--font-size-base);
}

.totales-cotizacion div {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.valor-letras {
    margin-top: 6px;
}

/* =========================
   BLOQUE FINAL: DATOS + CONTACTO
========================= */

.bloque-final-cotizacion {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 35px;
    gap: 30px;
}

.datos-cotizacion-final,
.contacto-vendedor-final {
    width: 48%;
    font-size: var(--font-size-base);
    line-height: 1.5;
    white-space: pre-line;
    text-align: center;
}

.datos-cotizacion-final h3,
.contacto-vendedor-final h3 {
    margin: 0 0 4px 0 !important;
    text-decoration: underline;
}

/* =========================
   IMPRESIÓN A4 VERTICAL
========================= */

@page {
    size: A4 portrait;
    margin: 7mm;
}

@media print {
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    html,
    body {
        margin: 0;
        padding: 0;
        background: white;
        font-size: 14px;
    }

    .no-print {
        display: none !important;
    }

    h1 {
        display: none !important;
    }

    h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .contenedor {
        width: auto;
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border-radius: 0;
        background: white;
    }

    .producto-preview {
        display: block !important;
        width: 100%;
        border: none;
        padding: 0;
        margin: 0;
    }

    .encabezado-cotizacion {
        margin-top: 0;
        margin-bottom: 24px;
    }

    .logo-cotizacion {
        max-width: 260px;
    }

    .datos-empresa {
        font-size: 13px;
        line-height: 1.35;
    }

    .fecha-cotizacion {
        font-size: 14px;
        margin-bottom: 22px;
    }

    .tabla-cotizacion {
        font-size: 13px;
        page-break-inside: auto;
    }

    .tabla-cotizacion th {
        background: var(--azul) !important;
        color: #ffffff !important;
        padding: 7px;
        font-size: 13px;
        border-top: 2px solid var(--azul);
        border-bottom: 2px solid var(--azul);
    }

    .tabla-cotizacion td {
        padding: 6px 7px;
    }

    .tabla-cotizacion tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .producto-fila-principal td {
        padding-bottom: 1px !important;
    }

    .producto-nombre-tabla {
        font-size: 13px;
    }

    .producto-detalle-fila {
        border-top: none !important;
        padding-top: 0 !important;
    }

    .producto-detalle-layout {
        gap: 18px;
        padding: 0 0 8px 0;
        margin-top: -10px;
    }

    .producto-descripcion {
        font-size: 12px;
        line-height: 1.4;
    }

    .img-producto-cotizacion {
        max-width: 360px;
        max-height: 220px;
    }

    .resumen-cotizacion {
        margin-top: 38mm;
        padding: 7px 0;
        border-top: 2px solid #111;
        border-bottom: 2px solid #111;
    }

    .producto-preview.cotizacion-larga .resumen-cotizacion {
        margin-top: 12mm;
    }

    .producto-preview.cotizacion-larga .bloque-final-cotizacion {
        margin-top: 18px;
    }

    .regimen-final,
    .totales-cotizacion {
        font-size: 13px;
    }

    .totales-cotizacion {
        margin-top: 0;
    }

    .bloque-final-cotizacion {
        margin-top: 30px;
        gap: 25px;
    }

    .datos-cotizacion-final,
    .contacto-vendedor-final {
        font-size: 12px;
        line-height: 1.45;
    }
}

.acciones-formulario {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 20px;
}



@media (max-width: 600px) {
    .acciones-formulario {
        flex-direction: column;
        align-items: stretch;
    }

    .acciones-formulario button {
        width: 100%;
    }
}


/* =========================
   LOGIN COTIZADOR
========================= */

.login-cotizador-page {
    min-height: 100vh;
    margin: 0;
    padding: 25px;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font);
}

.login-cotizador-box {
    width: 360px;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(0,0,0,0.15);
    text-align: center;
}

.login-cotizador-logo {
    max-width: 230px;
    height: auto;
    margin-bottom: 20px;
}

.login-cotizador-box h2 {
    margin: 0 0 20px 0;
    color: var(--azul);
    font-size: 20px;
}

.login-cotizador-box input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    font-family: var(--font);
    font-size: 14px;
}

.login-cotizador-box button {
    width: 100%;
    background: var(--azul);
    color: white;
    border: none;
    padding: 12px;
    cursor: pointer;
    font-weight: bold;
}

.login-cotizador-box button:hover {
    background: var(--azul-oscuro);
}

.login-cotizador-error {
    color: #b00020;
    background: #ffecec;
    border: 1px solid #ffb3b3;
    padding: 8px;
    margin-bottom: 15px;
    font-size: 13px;
}

.barra-superior-cotizador {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.btn-regresar-inicio {
    display: inline-block;
    background: #777;
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    font-weight: bold;
    font-family: var(--font);
    font-size: 13px;
}

.btn-regresar-inicio:hover {
    background: #555;
    color: #fff;
}

/* =========================
   CONTACTO / VENDEDOR
========================= */

.contacto-vendedor-wrap {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.contacto-vendedor-texto textarea {
    min-height: 135px;
    margin-bottom: 0;
}

.contacto-vendedor-lista {
    background: var(--gris-fondo);
    border: 1px solid #ccc;
    padding: 12px;
    font-size: var(--font-size-base);
}

.contacto-vendedor-lista strong {
    display: block;
    margin-bottom: 10px;
}

.contacto-vendedor-lista label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 8px;
    cursor: pointer;
}

.contacto-vendedor-lista input {
    width: auto;
    margin: 0;
}

@media (max-width: 700px) {
    .contacto-vendedor-wrap {
        grid-template-columns: 1fr;
    }
}