/* --- IMPORTAR FUENTE DE GOOGLE (Mulish - Alternativa a Museo Sans) --- */
@import url('https://fonts.googleapis.com/css2?family=Mulish:wght@300;400;600;700&display=swap');

/* --- VARIABLES & RESET --- */
:root {
    /* COLORES */
    --primary-red: #992d31;   /* Pantone 1805 C */
    --grey-medium: #6f7170;   /* Pantone 424 C */
    --grey-light: #c1c4c7;    /* Pantone 428 C */
    --grey-dark: #3a3c39;     /* Pantone 447 C */
    --white: #ffffff;
    --bg-app: #e0e0e0;
    
    /* TIPOGRAFÍA GLOBAL (Aquí aplicamos el cambio) */
    --font-family: 'Mulish', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--grey-dark);
    height: 100vh;
    overflow: hidden;
    /* Evita scroll en el body principal */
    display: flex;
}

/* --- UTILIDADES --- */
.hidden {
    display: none !important;
}

.text-red {
    color: var(--primary-red);
}

.text-right {
    text-align: right;
}

.w-100 {
    width: 100%;
}

/* --- LOGIN MODAL (Overlay) --- */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    /* Simula el fondo desenfocado */
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 10px;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.login-logo {
    max-width: 200px;
    margin-bottom: 30px;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    background-color: #e6e6e6;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    color: var(--grey-dark);
}

.input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-medium);
}

.btn-login {
    width: 100%;
    padding: 12px;
    background-color: var(--grey-medium);
    color: var(--white);
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-login:hover {
    background-color: var(--grey-dark);
}

/* --- LAYOUT PRINCIPAL (Sidebar + Content) --- */
.sidebar {
    width: 260px;
    background-color: var(--grey-medium);
    /* Usando el gris medio/oscuro del diseño */
    height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    color: var(--white);
}

.sidebar-logo {
    max-width: 180px;
    margin-bottom: 40px;
}

.menu-section {
    margin-bottom: 30px;
}

.menu-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: var(--white);
    font-weight: bold;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 8px;
    background-color: var(--grey-light);
    color: var(--grey-dark);
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    border: none;
    text-align: left;
    cursor: pointer;
}

.menu-btn.active {
    background-color: var(--primary-red);
    color: var(--white);
}

.menu-btn:hover:not(.active) {
    background-color: #dcdcdc;
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    flex: 1;
    padding: 20px 40px;
    overflow-y: auto;
    background-color: #d9d9d9;
    /* Gris de fondo app */
    position: relative;
}

/* --- HEADER & SEARCH --- */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.search-bar {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 15px 8px 35px;
    border-radius: 20px;
    /* Bordes redondeados como mockup */
    border: 1px solid #aaa;
    background: linear-gradient(to bottom, #f0f0f0, #ffffff);
    outline: none;
}

.btn-upload {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
}
.btn-upload:hover {
    background-color: var(--grey-medium);
}
.logout-btn {
    color: var(--primary-red);
    font-size: 1.2rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    margin-left: 10px;
    padding: 4px 8px;
    }
.logout-btn:hover { 
    color:var(--grey-dark); 
}

/* --- VIEW TITLES --- */
h1.page-title {
    font-size: 32px;
    color: var(--grey-dark);
    margin-bottom: 20px;
    font-weight: normal;
}

/* --- TABLES (LIST VIEWS) --- */
.data-table-container {
    background: transparent;
}

.table-header {
    display: grid;
    font-weight: bold;
    padding: 10px 0;
    border-bottom: 1px solid var(--grey-dark);
    /* Línea negra/gris oscura */
}

.table-row {
    display: grid;
    padding: 10px 0;
    border-bottom: 1px solid var(--primary-red);
    /* Línea roja separadora */
    align-items: center;
    background: transparent;
}

.table-row input {
    background: transparent;
    border: none;
    width: 100%;
}

/* Grillas específicas por vista */
.grid-clientes {
    grid-template-columns: 100px 1fr 150px 80px;
}

.grid-productos {
    grid-template-columns: 100px 1fr 80px 80px 120px 80px;
}

/* Para vistas split (Presupuesto/Certificado List) */
.grid-split-list {
    grid-template-columns: 120px 1fr 100px 100px;
}

.action-icons img,
.action-icons i {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-left: 5px;
    opacity: 0.6;
}

.action-icons img:hover,
.action-icons i:hover {
    opacity: 1;
}

/* --- FORMS (CARD STYLE) --- */
.form-container {
    background: transparent;
    padding-top: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--grey-dark);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background-color: var(--white);
    font-size: 14px;
}

/* --- SPLIT VIEWS (Presupuestos & Certificados) --- */
.split-view {
    display: flex;
    gap: 30px;
    height: calc(100vh - 150px);
}

.split-list {
    flex: 1;
    overflow-y: auto;
}

.split-preview {
    flex: 1.2;
    background: #f5f5f5;
    padding: 20px;
    display: flex;
    justify-content: center;
    overflow-y: auto;
    border: 1px solid #ccc;
}

/* --- PAPEL A4 (Preview) --- */
.a4-paper {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding:2px;
    position: relative;
    box-sizing: border-box;
}
    /* Look más formal */

/* Estilo específico Certificado (Borde decorativo) */


/* --- FOOTER ACTIONS --- */
.footer-actions {
    position: fixed;
    bottom: 20px;
    left: 300px;
    /* Sidebar width + padding */
    display: flex;
    gap: 10px;
}

.btn-action {
    padding: 8px 20px;
    border: 1px solid #999;
    background: #d0d0d0;
    /* Gris botón */
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: var(--grey-dark);
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-action:hover {
    background: #bbb;
}

.btn-print {
    padding: 8px;
}

/* --- ESTILOS ESPECÍFICOS DE PRESUPUESTO --- */

/* Contenedor del Grupo */
.budget-group {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
}

/* Input del Encabezado (Estilo distintivo) */
.group-header-container {
    margin-bottom: 10px;
    border-bottom: 2px solid var(--primary-red); /* Línea roja debajo del título */
    padding-bottom: 5px;
}

.header-input {
    font-weight: bold;
    font-size: 14px;
    color: var(--grey-dark);
    border: 1px solid #ddd !important; /* Borde suave */
    background: #fafafa;
}

/* Tabla interna */
.budget-table {
    width: 100%;
    border-collapse: collapse;
}

.budget-table th {
    text-align: left;
    font-size: 13px;
    color: #555;
    padding: 8px;
    border-bottom: 1px solid #ccc;
}

.budget-table td {
    padding: 5px;
    border-bottom: 1px solid #eee;
}

/* Inputs transparentes dentro de la tabla */
.form-control-transparent {
    width: 100%;
    border: none;
    background: transparent;
    padding: 5px;
    font-size: 13px;
    outline: none;
}

.form-control-transparent:focus {
    background: #f0f8ff; /* Azul muy pálido al escribir */
    border-radius: 3px;
}

/* Icono de Basura (Fila) */
.row-delete-icon {
    color: #ccc;
    cursor: pointer;
    transition: color 0.2s;
}

/* Efecto Hover en la fila para mostrar la basura */
.budget-table tr:hover .row-delete-icon {
    color: var(--primary-red); /* Se pone rojo solo al pasar el mouse */
}

.budget-table tr:hover {
    background-color: #f9f9f9;
}

/* Botón Rojo + (Agregar Fila) */
.row-action-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
}

.btn-add-row-red {
    background-color: var(--primary-red);
    color: white;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-add-row-red:hover {
    background-color: #7a2427; /* Rojo más oscuro */
}

/* Botones Globales (Control de Grupos) */
.global-group-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
    padding-right: 15px;
}

.btn-group-control {
    background-color: #888; /* Gris */
    color: white;
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-group-control:hover {
    background-color: #666;
}

/* Animación de entrada suave */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --- ESTILOS ESPECÍFICOS DEL PRESUPUESTO --- */

.presupuesto-print {
    font-family: 'Mulish', sans-serif;
    color: #333;
    width: 100%;
    height: 100%;
    position: relative;
    box-sizing: border-box;
    /* El padding lo maneja el a4-paper, aquí nos aseguramos de llenar el área */
}

/* --- HEADER --- */
.pp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px; /* Espacio antes de los datos del cliente */
    border-bottom: 1px solid transparent; /* Reserva de espacio visual */
}

.pp-logo-section {
    width: 50%;
}

.pp-logo-section img {
    max-width: 220px; /* Ajusta según tu imagen real */
    height: auto;
    display: block;
}

.pp-info-section {
    width: 45%;
    text-align: right;
}

.pp-box-number {
    background-color: #EAEAEA;
    border: 1px solid #D1D1D1;
    padding: 5px 10px;
    display: inline-block;
    font-weight: 800;
    font-size: 14px;
    color: #000;
    margin-bottom: 10px;
}

.pp-box-number span {
    color: #B72025; /* Rojo Plastperu */
}

.pp-slogan {
    font-size: 13px;
    color: #666;
    line-height: 1.3;
}

/* --- DATOS CLIENTE (Solo página 1) --- */
.pp-client-data {
    font-size: 12px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.pp-intro-text {
    margin-top: 15px;
    font-size: 12px;
}

/* --- TABLAS DE ITEMS --- */
.pp-group-title {
    font-size: 11px;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 5px;
    color: #444;
    padding-left: 2px;
}

.pp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin-bottom: 10px;
    table-layout: fixed; /* <--- IMPORTANTE: Obliga a respetar los anchos % exactos */
}

.pp-table th, .pp-table td {
    overflow: hidden; /* Evita que texto largo rompa la celda */
    white-space: nowrap; /* Opcional: si quieres que no baje de línea */
    text-overflow: ellipsis; /* Pone "..." si el texto es muy largo */
}

.pp-table th {
    background-color: #E0E0E0;
    color: #000;
    font-weight: 700;
    text-align: left;
    padding: 4px 6px;
    text-transform: uppercase;
    border-bottom: 1px solid #999; /* Mejora visual del header */
}

.pp-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
    color: #333;
}

/* Column widths simulados para parecerse al mockup */
.pp-col-cod { width: 12%; }
.pp-col-nom { width: 48%; } /* Reducimos un poco para dar espacio a otros */
.pp-col-cant { width: 12%; text-align: right; }
.pp-col-pu { width: 12%; text-align: right; }
.pp-col-total { width: 16%; text-align: right; background-color: #f9f9f9; }

.text-right { text-align: right !important; }

/* Filas alternadas (zebra) */
.pp-table tbody tr:nth-child(even) {
    background-color: #f4f4f4;
}

/* --- FOOTER (Pie de página absoluto al fondo del A4) --- */
.pp-footer-spacer {
    /* Un div invisible que empuja contenido si usáramos flujo normal, 
       pero aquí usaremos control JS de altura, esto es reserva visual */
    height: 120px; 
}

.pp-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 130px; /* Altura fija para cálculos */
}

.pp-legal-text {
    font-size: 9px;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
}

.pp-signature-area {
    text-align: right;
    margin-right: 20px;
    position: relative;
    top: -20px; /* Subir un poco la firma para que cuadre */
}

.pp-signature-img {
    height: 60px; /* Ajusta según tu imagen */
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.pp-signature-name {
    text-align: center;
    border-top: 1px solid #666;
    display: inline-block;
    padding-top: 5px;
    font-size: 11px;
    font-weight: 700;
    min-width: 150px;
    margin-top: 5px;
}

.pp-bottom-bar {
    position: absolute;
    bottom: -15mm; /* Ajuste para que pegue al borde real del papel fuera del padding */
    left: -15mm; /* Romper el padding del A4 */
    width: 210mm; /* Ancho total A4 */
    background-color: #f0f0f0;
    text-align: center;
    font-size: 9px;
    color: #666;
    padding: 8px 0;
    border-top: 2px solid #B72025; /* Línea roja decorativa */
}
 /* --- ESTILOS DE TABLA TÉCNICA (Igual que Productos) --- */
        .grid-clientes {
            display: grid;
            /* EL SECRETO: Definimos el ancho exacto de cada columna */
            /* Código | Razón Social (Ancha) | RUC | Acciones */
            grid-template-columns: 0.8fr 4fr 1.5fr 0.6fr;
            gap: 15px;
            align-items: center;
            padding: 12px 15px;
        }

        /* Encabezados en mayúsculas y estilo técnico */
        .table-header span {
            font-weight: 600;
            text-transform: uppercase;
            font-size: 0.85rem;
            letter-spacing: 0.5px;
            color: #444;
        }

        /* Texto de las filas */
        .table-row span {
            font-size: 0.9rem;
            color: #333;
        }

        /* Estilos de iconos */
        .action-icons a { text-decoration: none; color: #666; margin: 0 5px; transition: color 0.2s; }
        .action-icons a.edit-icon:hover { color: var(--grey-medium); }
        .action-icons a.delete-icon:hover { color: var(--primary-red); }

        /* Estilo especial para el RUC (tipo "código") */
        .ruc-text {
            font-family: monospace;
            font-size: 0.95em;
            color: #555;
            letter-spacing: 1px;
        }