

/* --- 0. Video de Fondo --- */
#background-video-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -2;
    overflow: hidden;
}
#background-video {
    width: 100vw; height: 100vh;
    object-fit: cover;
}

/* Superposición oscura para legibilidad */
body::before {
    content: '';
    position: fixed; inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: -1;
}

/* --- 1. General Styles & Typography --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
    /* Paleta refinada (manteniendo nombres de variables) */
    --accent-color: #5AA7FF;       /* azul más profesional */
    --success-color: #22C55E;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;

    --background-primary: transparent;
    --background-secondary: #161B22;
    --container-bg: rgba(22, 27, 34, 0.70);
    --text-primary: #E7ECF3;
    --border-color: #2B3440;

    --bg: #0B1220; --surface: #121a2b; --text: #E7ECF3; --muted: #9BA6B2;
    --primary: #7DF9FF; --secondary: #B08CFF;

    --success:#34D399; --warning:#F59E0B; --error:#F87171;
    --radius: 16px; --shadow: 0 10px 30px rgba(0,0,0,.35);
    --space-1:8px; --space-2:12px; --space-3:16px; --space-4:24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 20px;
    line-height: 1.45; /* mejor legibilidad */
}

/* --- 2. Header & Navigation --- */
header {
    max-width: 1200px;
    margin: 0 auto 20px auto;
}

h1 {
    text-align: center;
    margin-bottom: 18px;
    font-size: 2.2em;        /* un poco más contenido */
    font-weight: 600;
    color: var(--accent-color);
    letter-spacing: .2px;
    animation: fadeIn 0.8s ease-in-out;
}

.main-nav {
    text-align: center;
    margin-bottom: 18px;
}

.main-nav a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 10px;
    transition: color 0.3s, background-color .25s ease;
}
.main-nav a:hover { color: #fff; background: rgba(90,167,255,.18); }

/* --- 3. Containers & Forms --- */
h2 {
    font-weight: 600;
    font-size: 1.35em;     /* ligeramente más compacto */
    border-left: 4px solid var(--accent-color);
    padding-left: 14px;
    margin-bottom: 16px;
    line-height: 1.2;
}

.form-container, .table-container, .cotizador-container {
    background-color: var(--container-bg);
    padding: 24px 26px;           /* consistente con tablas y modales */
    margin: 18px auto;
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-width: 1200px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: slideUp 0.6s ease-out;
}

.form-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}
.form-container h2 { grid-column: 1 / -1; }

/* ====== Controles uniformes ====== */
input, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.98rem;
    background-color: var(--background-secondary);
    color: var(--text-primary);
    transition: all 0.25s ease;
    height: 44px;
    min-height: 44px;
    line-height: 20px;
}
input[type="date"] { padding: 10px 12px; height: 44px; min-height: 44px; }
select { height: 44px; }

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 6px rgba(90,167,255, 0.15);
}

input::placeholder { color: #cfd8e3b3; }
label { font-weight: 500; margin-bottom: -8px; }

/* ====== Campos compactos para Monto y Periodo ====== */
#cantidad, #periodo { max-width: 340px; }
@media (min-width: 900px) {
    #cantidad, #periodo { justify-self: start; }
}

/* Botones genéricos */
button#saveButton, button, #addItemButton, #addCategoriaButton, #addConceptoButton, #generatePdfButton {
    background: linear-gradient(135deg, #0d4bb5, #0a2c6b);  /* azul profundo profesional */
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, filter .2s ease, box-shadow .2s ease;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
button#saveButton, #addCategoriaButton, #addConceptoButton { grid-column: 1 / -1; }
button:hover, #addItemButton:hover, #addCategoriaButton:hover, #addConceptoButton:hover, #generatePdfButton:hover { 
    transform: translateY(-1px); 
    filter: brightness(1.04);
}
button:disabled { background: #566; cursor: not-allowed; filter: grayscale(.2); }

/* --- 4. Tables --- */
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
thead th { font-weight: 600; color: var(--text-primary); background-color: rgba(90,167,255, 0.15); }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background-color: rgba(255, 255, 255, 0.05); }

/* Botones de acción */
.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.actions-cell.actions-wide button,
.actions-cell.actions-wide a { min-width: 140px; }

.actions-cell button, .actions-cell a {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.25s ease;
    color: white;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0,0,0,.30);
}
.actions-cell button:hover, .actions-cell a:hover { 
    transform: translateY(-1px); 
    filter: brightness(1.05);
}

/* Colores coherentes (manteniendo los roles) */
.actions-cell .edit { background-color: var(--accent-color); }
.actions-cell .edit:hover { background-color: #3f8cf0; }

.actions-cell .status-toggle { background-color: #c07a0a; }    /* warning más sobrio */
.actions-cell .status-toggle:hover { background-color: #a56809; }

.actions-cell .delete { background-color: #C63232; }          /* rojo menos saturado */
.actions-cell .delete:hover { background-color: #a32929; }

.actions-cell .whatsapp-btn { background-color: #25D366; }
.actions-cell .whatsapp-btn:hover { background-color: #1fb85a; }

/* NUEVOS tonos pedidos (sin afectar otras vistas) */
.actions-cell .register-payment { 
    background: linear-gradient(135deg, #D4AF37, #A67C00);  /* dorado elegante */
    color: #111;
}
.actions-cell .register-payment:hover { filter: brightness(1.06); }

.actions-cell .view-history { background: #3A4756; }         /* gris pizarra */
.actions-cell .view-history:hover { background: #2f3a46; }

.status-indicator { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.status-indicator.activo { background-color: var(--success-color); }
.status-indicator.inactivo { background-color: var(--danger-color); }

#totalPago { grid-column: 1 / -1; font-weight: 600; font-size: 1.1em; color: var(--success-color); }

/* --- 5. Cotizador / Pago --- */
.cotizador-form { 
    display: grid; 
    grid-template-columns: 2fr 2fr 3fr 1fr 1fr; 
    gap: 15px; 
    align-items: center; 
    margin-bottom: 20px; 
}
.radio-group { display: flex; gap: 14px; align-items: center; }

/* Layout del bloque Pago (id="pago-section") – SOLO ajustes de tamaño/centrado */
#pago-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    align-items: center;
    margin-top: 8px;
}
#pago-section h2 { grid-column: 1 / -1; margin-bottom: 6px; }

/* radios: proporción y legibilidad */
#pago-section .radio-group {
    grid-column: 1 / 2;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 12px;
    padding: 8px 10px;
}
#pago-section .radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px dashed transparent;
    transition: background-color .2s ease, border-color .2s ease;
    font-weight: 600;
    line-height: 1;
}
#pago-section .radio-group input[type="radio"] { accent-color: var(--accent-color); }
#pago-section .radio-group input[type="radio"]:checked + span,
#pago-section .radio-group label:has(input[type="radio"]:checked) {
    background: rgba(90,167,255,.18);
    border-color: rgba(90,167,255,.35);
}

/* Instalación centrada y campos con altura consistente */
#pago-section label[for="inst"] { grid-column: 2 / 3; align-self: center; }
#pago-section #inst { grid-column: 2 / 3; }
#pago-section #instP { grid-column: 3 / 4; }
#pago-section #inst, #pago-section #instP { height: 44px; min-height: 44px; }

#pago-section #anualHint {
    grid-column: 4 / 5;
    justify-self: start;
    max-width: 240px;
    font-size: 0.86rem;
    line-height: 1.25;
    opacity: .85;
}

@media (max-width: 1024px) {
    #pago-section { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    #pago-section #anualHint { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
    body { padding: 10px; }
    h1 { font-size: 1.9em; }
    h2 { font-size: 1.25em; }
    
    th, td {
        padding: 10px 6px;
        font-size: 0.92em;
    }

    .form-container { grid-template-columns: 1fr; }
    .cotizador-form { grid-template-columns: 1fr; gap: 10px; }

    #pago-section { grid-template-columns: 1fr; }
    #pago-section .radio-group,
    #pago-section #inst,
    #pago-section #instP,
    #pago-section #anualHint { grid-column: 1 / -1; }

    .actions-cell {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .actions-cell button, .actions-cell a {
        text-align: center;
        width: 100%;
    }
}

/* --- 8. Estilos del Modal (Genéricos) --- */
.modal-hidden { display: none; }
.modal {
    position: fixed; z-index: 100;
    left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}
.modal-content {
    background-color: var(--background-secondary);
    margin: 10% auto; padding: 26px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 80%; max-width: 700px;
    position: relative;
    animation: slideUp 0.5s;
}
.close-button {
    color: #aeb7c4;
    float: right;
    font-size: 26px;
    font-weight: bold;
    position: absolute; top: 14px; right: 22px;
}
.close-button:hover, .close-button:focus { color: white; cursor: pointer; }

#assignedMaterialsList ul { list-style: none; padding: 0; margin-top: 10px; }
#assignedMaterialsList li {
    background-color: #2a2f36;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center;
}

/* --- Estilos Adicionales para Modal de Historial --- */
.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}
.modal-header h2 { margin-bottom: 0; border-left: none; padding-left: 0; }
.print-button {
    background: #506079;
    color: white; border: none; border-radius: 10px;
    padding: 10px 15px; font-size: 0.92em; font-weight: 600;
    cursor: pointer; transition: filter 0.2s ease;
}
.print-button:hover { filter: brightness(1.06); }
#historyContent table { width: 100%; margin-top: 16px; border-collapse: collapse; }
#historyContent th, #historyContent td { border: 1px solid var(--border-color); padding: 8px; text-align: left; }
#historyContent th { background-color: rgba(90,167,255, 0.15); }

/* --- 9. Estilos de Login y Autenticación --- */
.login-container {
    text-align: center;
    max-width: 450px;
    margin: 10vh auto;
    padding: 38px;
    background-color: var(--container-bg);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.login-container h2 { border-left: none; padding-left: 0; text-align: center; }
.error-text { color: var(--danger-color); margin-top: 15px; min-height: 20px; }
.logout-button {
    background: var(--danger-color);
    padding: 8px 15px !important;
    font-size: 0.9em !important;
    border-radius: 8px !important;
    margin-left: 20px;
}
.logout-button:hover { background-color: #c0392b; }

/* --- 10. Estilos de Paginación y Búsqueda --- */
.table-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 18px; margin-bottom: 10px;
}
#searchInput { padding: 10px 15px; max-width: 300px; }
.pagination-controls {
    display: flex; justify-content: center; gap: 8px; margin-top: 18px;
}
.page-btn {
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.25s ease;
}
.page-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.page-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    font-weight: bold;
}

/* --- 11. Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
