/* Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #525659; /* Color de fondo típico de un visor de PDF */
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0;
}

/* Botón flotante */
.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #007bff;
    color: white;
    border: none;
    padding: 15px 25px;
    font-size: 16px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 1000;
}
.floating-btn:hover {
    background-color: #0056b3;
}

.btn-action {
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    padding: 5px 15px;
    cursor: pointer;
    border-radius: 4px;
}

/* Estilos de las páginas tipo A4 */
.page {
    width: 210mm;
    min-height: 297mm;
    background-color: white;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    color: #000;
}

/* Inputs interactivos pero invisibles al imprimir */
.inline-input {
    border: 1px dashed transparent;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    padding: 2px;
    width: 100%;
}

.inline-input:hover {
    background-color: rgba(0, 123, 255, 0.1);
    border: 1px dashed #007bff;
}

.inline-input:focus {
    outline: none;
    background-color: rgba(255, 255, 0, 0.1);
    border: 1px solid #007bff;
}

textarea.inline-input {
    resize: none;
    overflow: hidden;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

/* Imprimir / PDF */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    @page {
        margin: 0;
        size: letter portrait;
    }
    body {
        background-color: white;
        padding: 0;
        margin: 0;
        display: block !important;
    }
    .no-print,
    .only-print,
    #login-screen,
    #auth-banner-wrapper {
        display: none !important;
    }
    #main-app {
        display: block !important;
    }
    .page {
        margin: 0;
        box-shadow: none;
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
        width: 100%;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }
    .page:last-of-type {
        page-break-after: auto;
        break-after: auto;
    }
    #page1 {
        height: auto !important;
        min-height: auto !important;
    }
    #page2, #page3 {
        height: 279.4mm !important;
        width: 215.9mm !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    #page2 img, #page3 img {
        width: 100% !important;
        height: 100% !important;
        object-fit: fill !important;
    }
    .inline-input, textarea.inline-input {
        border: none !important;
        background: transparent !important;
        -webkit-appearance: none;
        appearance: none;
        resize: none;
    }
    .bottom-line {
        border-bottom: 1px solid black !important;
    }
    .box-input {
        border: 1px solid black !important;
    }
    select, select.print-select {
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        background-color: #dbe2ec !important;
    }
    select::-ms-expand {
        display: none !important;
    }
    #descuento-val, #total-impuestos {
        border: none !important;
        background: transparent !important;
        text-align: center;
    }
}

/* --- Modales y Base de Datos --- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    position: relative;
}
.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-modal:hover { color: black; }

.form-grid {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.form-grid input, .form-grid select {
    padding: 8px;
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.btn-primary {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 4px;
}
.btn-primary:hover { background-color: #0056b3; }

.table-container {
    max-height: 300px;
    overflow-y: auto;
}
.db-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.db-table th, .db-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.db-table th {
    background-color: #f2f2f2;
}
.btn-delete {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}
.btn-delete:hover { background-color: #c82333; }

body.role-vendedor .hide-for-seller {
    display: none !important;
}

/* --- NUEVO DISEÑO --- */
#page1 {
    background-color: #fcfbfa !important; /* Crema claro */
    padding: 0 !important;
}

/* Header Banner */
.new-header {
    background-image: url('../encabezado.png');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    width: 100%;
    color: white;
    position: relative;
    padding-bottom: 5px;
    border-bottom: 6px solid #bda883; /* Linea dorada */
    margin-bottom: 15px;
    min-height: 161px;
    display: flex;
    flex-direction: column;
}

.header-content {
    display: flex;
    justify-content: space-between;
    padding: 20px 30px 10px 30px;
    flex: 1;
}

.header-left {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.header-logo {
    display: block;
    max-width: 250px;
    margin-bottom: 10px;
}
.header-text-block {
    display: block; 
    font-size: 11px;
    line-height: 1.4;
    color: #e0e0e0;
    text-align: center;
}
.header-bold {
    font-weight: bold;
    font-size: 13px;
    color: #ffffff;
}

.header-right {
    width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center; 
    justify-content: flex-start;
    gap: 10px;
    margin-top: 48px; 
    margin-right: 38px; 
    margin-left: auto; 
    transform: translate(1.25cm, 0.25cm);
}

.cotizacion-box {
    background-color: white;
    border-radius: 20px;
    padding: 4px 12px;
    color: #333;
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transform: translateX(0.55cm);
}

.cotizacion-box input {
    width: 130px;
    font-size: 18px;
    font-weight: bold;
    margin-left: 5px;
    color: #900;
    border: none;
    text-align: center;
    background: transparent;
}

.date-table-new {
    border-collapse: collapse;
    color: white;
    margin-top: 5px;
}
.date-table-new th, .date-table-new td {
    border: 1px solid rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 4px;
    font-size: 12px;
}
.date-table-new th {
    border: none;
    padding-bottom: 2px;
}
.date-table-new .no-border {
    border: none;
    text-align: right;
    padding-right: 10px;
}
.date-table-new input {
    background: white !important;
    border: none !important;
    border-radius: 0 !important;
    width: 35px;
    color: #333 !important;
    font-weight: bold;
    text-align: center;
}
.date-table-new #anio {
    width: 50px;
}

/* Client Info */
.client-info-new {
    padding: 0 30px;
    margin-bottom: 20px;
}
.client-row-new {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
.client-label {
    font-size: 14px;
    margin-right: 10px;
    white-space: nowrap;
}
.client-row-new > .client-label,
.client-half:first-child > .client-label {
    width: 135px;
    flex-shrink: 0;
    display: inline-block;
}
.client-input {
    background-color: #dbe2ec;
    border: none;
    border-bottom: 1px solid #7c98b8;
    padding: 6px;
    font-size: 14px;
    font-weight: bold;
    color: #2b4566;
}
.client-full {
    flex-grow: 1;
}
.client-split {
    display: flex;
    justify-content: space-between;
}
.client-half {
    display: flex;
    align-items: center;
    flex: 1;
}
.client-short {
    width: 100px;
}
.client-med {
    flex-grow: 1;
    margin-left: 10px;
}
.client-status {
    color: #900;
    font-size: 12px;
    font-weight: normal;
    margin-left: 10px;
}

/* Main Table */
.table-wrapper-new {
    padding: 0 30px;
    position: relative;
}

.table-wrapper-new::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    background-image: url('../logo 01.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.15;
    z-index: 10;
    pointer-events: none;
}
.main-table-new {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #7a94ad;
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
}
.main-table-new thead {
    background-color: #254a7c;
    color: white;
}
.main-table-new th {
    padding: 8px;
    text-align: center;
    font-weight: bold;
    border-bottom: 2px solid #7a94ad;
}
.main-table-new th:not(:last-child) {
    border-right: 1px solid rgba(255,255,255,0.3);
}

.main-table-new tbody tr:nth-child(even) {
    background-color: #e5edf5;
}
.main-table-new td {
    padding: 8px;
    vertical-align: middle;
    border-right: 1px solid #7a94ad;
}
.main-table-new td:last-child {
    border-right: none;
}

.row-icon {
    font-size: 16px;
}
.val-input-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
}

/* Footer of table */
.main-table-new tfoot {
    border-top: 2px solid #7a94ad;
}
.main-table-new tfoot td {
    border: none;
    border-top: 1px solid #7a94ad;
}
.letras-cell-new {
    background-color: #fcfbfa;
    padding: 15px;
    vertical-align: middle !important;
    text-align: left !important;
    font-size: 12px;
}
.footer-label-new {
    background-color: #d6be92; /* Dorado/Bronce */
    text-align: center;
    font-weight: bold;
    border-right: 1px solid #7a94ad !important;
    border-left: 1px solid #7a94ad !important;
    vertical-align: middle !important;
    height: 26px;
    padding: 2px !important;
}
.footer-value-new {
    background-color: #e0e6ed; /* Gris/azul claro */
    font-weight: bold;
    text-align: center !important;
    vertical-align: middle !important;
    height: 26px;
    padding: 2px !important;
}
.highlight-total {
    background-color: #d1d8e1 !important;
    font-size: 14px;
}
.tiny-text {
    font-size: 9px;
    color: #333;
    text-align: center;
    font-weight: normal;
}

/* Reducir tamaño de fuente en las columnas de la tabla para que quepan mejor */
.main-table-new td input[type="number"],
.main-table-new td input[type="text"],
.main-table-new td .row-total {
    font-size: 12px !important;
}

/* Ocultar flechas de inputs numéricos */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
    -moz-appearance: textfield;
}

/* Ocultar la flecha negra de datalist */
input::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Banner de Autenticación de Cotización QR */
.auth-banner-container {
    width: 100%;
    max-width: 800px;
    margin: 20px auto 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.auth-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.15);
    font-family: Arial, Helvetica, sans-serif;
    animation: fadeInDown 0.5s ease;
}

.auth-banner svg {
    fill: #155724;
    width: 20px;
    height: 20px;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.only-print {
    display: none;
}

#page2, #page3 {
    height: 279.4mm;
}

/* Login Screen Styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f2f5;
    padding: 15px;
    box-sizing: border-box;
}

.login-card {
    background: white;
    padding: 40px 30px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-sizing: border-box;
}

.login-card img {
    width: 100%;
    max-width: 250px;
    height: auto;
    margin-bottom: 20px;
    display: inline-block;
}

.login-card p {
    color: #666;
    margin-bottom: 25px;
    font-size: 15px;
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
}

.login-card button {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.login-card button:hover {
    background-color: #0056b3;
}
