@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&display=swap');

/* ================================================================== */
/* --- VARIABLES DEL SISTEMA (TEMA CLARO UNIFICADO) ---               */
/* ================================================================== */
:root { 
    --cucara-red: #8e0000; 
    
    /* Paleta Glassmorphism */
    --bg-main: #f5f5f7;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-input: rgba(255, 255, 255, 0.8);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: rgba(0,0,0,0.05);
    --glass-border: rgba(255,255,255,0.9);
    color-scheme: light;
}

/* ================================================================== */
/* --- MODO OSCURO AUTOMÁTICO ---                                     */
/* ================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #121212;
        --bg-card: rgba(30, 30, 30, 0.75);
        --bg-input: rgba(0, 0, 0, 0.5);
        --text-main: #f8f9fa;
        --text-muted: #a1a1aa;
        --border-color: rgba(255,255,255,0.1);
        --glass-border: rgba(255,255,255,0.05);
        color-scheme: dark;
    }
    
    .table-light, .table-dark, .bg-light, .bg-white, .bg-primary, .bg-dark, .bg-secondary { background-color: transparent !important; }
    h1, h2, h3, h4, h5, h6, p, label, .fw-bold { color: var(--text-main) !important; }
    .text-dark { color: var(--text-main) !important; }
    .text-muted { color: var(--text-muted) !important; }
    
    .card-header { background-color: transparent !important; }
    .id-readonly { background-color: var(--bg-input) !important; }
    
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="time"]::-webkit-calendar-picker-indicator {
        filter: invert(1);
        opacity: 0.8;
    }
}

/* ================================================================== */
/* --- FORZAR TEMA SOBRE BOOTSTRAP (GLOBAL) ---                       */
/* ================================================================== */
.card-header.bg-dark, .card-header.bg-secondary, .card-header.bg-primary, 
.card-header.bg-danger, .card-header.bg-success, .card-header.bg-warning, .card-header.bg-info {
    background-color: transparent !important;
}

.card-header.text-white *, .card-header.text-white i, .card-header .text-white {
    color: var(--text-main) !important;
}

.card-header h5 i[class*="text-"] { color: var(--cucara-red) !important; }

@media (prefers-color-scheme: dark) {
    .card-header h5 i[class*="text-"] { color: var(--text-main) !important; }
}

/* ================================================================== */
/* --- ELIMINAR BARRAS DE SCROLL NATIVAS ---                          */
/* ================================================================== */
::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }
* { scrollbar-width: none !important; -ms-overflow-style: none !important; }

/* ================================================================== */
/* --- RESET Y BASE ---                                               */
/* ================================================================== */
*, *::before, *::after { box-sizing: border-box; }

body { 
    font-family: 'Manrope', sans-serif !important; 
    background: var(--bg-main) !important; 
    color: var(--text-main) !important;
    overflow-x: hidden; 
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    
    /* ADN DE APP NATIVA */
    overscroll-behavior-y: contain; 
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Permitir selección de texto SOLO en los inputs y textareas */
input, textarea {
    -webkit-user-select: auto !important;
    user-select: auto !important;
}

/* Scroll suave horizontal para tablas en móviles (Inercia iOS) */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}
/* ================================================================== */
/* --- PANTALLA DE LOGIN ---                                          */
/* ================================================================== */
#login-container {
    height: 100vh;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.login-box {
    background: var(--bg-card) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px 30px !important;
    border-radius: 32px !important;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1) !important;
}

/* ================================================================== */
/* --- MACOS DOCK REFINADO (EFECTO ONDA / WAVE) ---                   */
/* ================================================================== */
.desktop-dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end; /* Para que los íconos crezcan desde abajo */
    background: var(--bg-card);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 45px;
    padding: 10px 15px 12px 15px; /* Más padding en la base */
    z-index: 10000;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    height: 75px;
    gap: 2px;
}

.desktop-dock.hide-dock {
    transform: translate(-50%, 150%) !important;
    opacity: 0;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: bottom center; /* Crecen desde el piso del dock */
    border-radius: 20px;
    min-width: 70px;
    height: 100%;
    position: relative;
}

.dock-item i { font-size: 1.5rem; margin-bottom: 2px; transition: inherit; }
.dock-item span { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; transition: inherit;}

/* Efecto Ola (Magnificación interactiva) */
.dock-item:hover {
    transform: scale(1.4) translateY(-8px);
    color: var(--cucara-red);
    z-index: 10;
    margin: 0 15px; /* Empuja vecinos */
}
.dock-item:has(+ .dock-item:hover) {
    transform: scale(1.15) translateY(-4px);
    margin: 0 5px;
}
.dock-item:hover + .dock-item {
    transform: scale(1.15) translateY(-4px);
    margin: 0 5px;
}

.dock-item.active { color: var(--cucara-red); }
.dock-item.active::after {
    content: ''; position: absolute; bottom: -2px; width: 5px; height: 5px;
    background: var(--cucara-red); border-radius: 50%;
}

.dock-separator { width: 1px; height: 35px; background: var(--border-color); margin: 0 15px 10px 15px; }

/* Info de Usuario integrada en el Dock */
.dock-user-info {
    display: flex; align-items: center; gap: 15px; padding-right: 10px; margin-bottom: 8px;
}
.dock-user-info small {
    font-weight: 800; font-size: 0.75rem; color: var(--text-main); max-width: 100px; line-height: 1;
}
.btn-logout-dock {
    background: var(--bg-input); border: 1px solid var(--border-color); color: var(--cucara-red);
    width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.3s;
}
.btn-logout-dock:hover {
    background: var(--cucara-red); color: white; transform: rotate(-15deg);
}

/* ================================================================== */
/* --- CONTENIDO PRINCIPAL (EXPANSIÓN TOTAL 100%) ---                 */
/* ================================================================== */
.main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important; /* Liberación absoluta del ancho de pantalla */
    margin: 0 auto !important;
    padding: 40px 3% 140px 3% !important; /* 3% de márgenes adaptables */
}

.section-module { display: none; animation: fadeIn 0.4s ease-out; }
.section-module.active { display: block; }

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* ================================================================== */
/* --- TARJETAS GLASSMORPHISM Y BORDES ESTILO APPLE ---               */
/* ================================================================== */
.card {
    background: var(--bg-card) !important;
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border-radius: 28px !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04) !important;
    overflow: visible !important;
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 20px !important;
    border-radius: 28px 28px 0 0 !important;
}

.card-header h5, .card-header h6 { font-weight: 800 !important; color: var(--text-main) !important; }

/* ================================================================== */
/* --- INPUTS MODERNOS Y FORMULARIOS ---                              */
/* ================================================================== */
.form-control, .form-select {
    background: var(--bg-input) !important;
    color: var(--text-main) !important;
    border-radius: 18px !important;
    border: 1px solid var(--border-color) !important;
    padding: 14px 18px !important;
    font-weight: 600;
}

.form-control:focus, .form-select:focus { 
    box-shadow: 0 0 0 4px rgba(142,0,0,0.1) !important; 
    border-color: var(--cucara-red) !important; 
}

.form-label { font-weight: 800 !important; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.id-readonly { background-color: var(--bg-input) !important; color: var(--cucara-red) !important; font-weight: bold !important; font-family: monospace !important; }

.form-floating > .form-control, .form-floating > .form-select { height: calc(3.5rem + 2px) !important; padding-top: 1.625rem !important; padding-bottom: 0.625rem !important; }
.form-floating > label { padding: 1rem 0.75rem !important; color: var(--text-muted) !important; font-weight: 800; font-size: 0.8rem; text-transform: uppercase; }

.form-control.is-invalid { border-color: #dc3545 !important; box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important; }
.form-control.is-valid { border-color: #198754 !important; box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25) !important; }

/* ================================================================== */
/* --- BOTONES ESTILO APP NATIVA ---                                  */
/* ================================================================== */
.btn { border-radius: 24px !important; font-weight: 800 !important; padding: 14px 20px !important; border: none !important; }

.btn-danger { background: var(--cucara-red) !important; box-shadow: 0 8px 20px rgba(142,0,0,0.2) !important; color: white !important; }
.btn-primary { background: #0d6efd !important; box-shadow: 0 8px 20px rgba(13,110,253,0.2) !important; color: white !important; }
.btn-success { background: #10b981 !important; box-shadow: 0 8px 20px rgba(16,185,129,0.2) !important; color: white !important; }
.btn-info { background: #0ea5e9 !important; box-shadow: 0 8px 20px rgba(14,165,233,0.2) !important; color: white !important; }
.btn-warning { background: #ffc107 !important; box-shadow: 0 8px 20px rgba(255,193,7,0.2) !important; color: #1e293b !important; }
.btn-excel { background-color: #107c41 !important; color: white !important; box-shadow: 0 8px 20px rgba(16,124,65,0.2) !important; }
.btn-excel:hover { background-color: #0c5e31 !important; }

button[type="submit"] { text-transform: uppercase; letter-spacing: 1px; transition: all 0.3s ease; }
button[type="submit"]:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-light[onclick*="cambiarMesAnalisis"], .btn-dark[onclick*="navegarFechaDetalle"], .btn-outline-danger[onclick*="cambiarMesCumple"], .btn-outline-light[onclick*="cambiarMesVistaCalendario"] {
    background: var(--bg-input) !important; color: var(--text-main) !important; border: 1px solid var(--border-color) !important; border-radius: 50% !important; padding: 8px 12px !important; box-shadow: 0 4px 10px rgba(0,0,0,0.05) !important;
}

/* ================================================================== */
/* --- EXTRAS, BADGES Y ESTILOS ESPECÍFICOS ---                       */
/* ================================================================== */
#fecha-detalle-display, #mes-actual-display, #mes-cumple-display, #vista-mes-calendario, #anio-cuotas-display {
    background-color: var(--bg-input) !important; color: var(--text-main) !important; border: 1px solid var(--border-color) !important; border-radius: 18px; font-weight: 800; padding: 8px 16px !important; box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.bg-ingreso-sutil { background-color: rgba(16, 185, 129, 0.08) !important; }
.bg-egreso-sutil { background-color: rgba(220, 53, 69, 0.08) !important; }
.fila-inactiva { opacity: 0.55; background-color: var(--bg-main) !important; transition: opacity 0.3s ease; }
.fila-inactiva:hover { opacity: 0.9; }

#cumpleanos-hoy-container, #cumpleanos-mes-container { padding-top: 20px; display: flex; flex-wrap: wrap; }
.card.h-100.shadow-sm { transition: transform 0.3s ease; }
.card.h-100.shadow-sm:hover { transform: translateY(-5px) !important; }
#cumpleanos-hoy-container .card, #cumpleanos-mes-container .card { overflow: visible !important; margin-top: 15px; }

/* ================================================================== */
/* --- FOOTER ---                                                     */
/* ================================================================== */
.footer-bottom { display: flex; justify-content: center; align-items: center; text-align: center; padding: 20px 0; margin-top: 40px; color: var(--text-muted); font-weight: 800; width: 100%; background: transparent; border: none; }
.footer-bottom p { margin: 0; }

/* ================================================================== */
/* --- CERO BORDES EN TABLAS ---                                      */
/* ================================================================== */
.table, 
.table > :not(caption) > * > *,
.table > tbody > tr > td, 
.table > thead > tr > th,
.table > tfoot > tr > td,
.table > tfoot > tr > th {
    background-color: transparent !important;
    background: transparent !important;
    color: var(--text-main) !important;
    box-shadow: none !important;
}

.table, .table-bordered, .table > tbody > tr, .table > tbody > tr > td, .table > tbody > tr > th,
.table > thead > tr, .table > thead > tr > th, .table > thead > tr > td,
.table > tfoot > tr, .table > tfoot > tr > td, .table > tfoot > tr > th {
    border: none !important;
    border-bottom: none !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    --bs-table-border-color: transparent !important;
}

.table th { font-weight: 800; color: var(--text-muted) !important; text-transform: uppercase; font-size: 0.85rem; }
.table-hover > tbody > tr:hover > * { background-color: rgba(142, 0, 0, 0.08) !important; color: var(--text-main) !important; }

/* ================================================================== */
/* --- EXCEPCIÓN A PRUEBA DE BALAS: COLORES DE ASISTENCIA ---         */
/* ================================================================== */
.table .text-success, .table .text-success i, .table td.text-success, .table td.text-success i { color: #10b981 !important; }
.table .text-danger, .table .text-danger i, .table td.text-danger, .table td.text-danger i { color: #ef4444 !important; }
.table .text-warning, .table .text-warning i, .table td.text-warning, .table td.text-warning i { color: #f59e0b !important; }
.table .text-info, .table .text-info i, .table td.text-info, .table td.text-info i { color: #0ea5e9 !important; }

/* ================================================================== */
/* --- RESPONSIVE / CELULARES (Convertir Dock a Bottom Bar y Tablas) -*/
/* ================================================================== */
@media (max-width: 768px) {
    .main-content { 
        padding: 15px 15px 90px 15px !important; /* Espacio para el menú inferior */
        margin-left: 0 !important; 
    }
    .login-box { padding: 25px !important; }
    .card-header h5, .card-header h6 { font-size: 1.05rem !important; text-align: center; }
    .form-control, .form-select { font-size: 16px !important; }
    .footer-bottom { padding: 15px 0 90px 0; width: 100%; } /* Extra padding para que el footer no quede tapado */
    .footer-bottom p { font-size: 0.85rem; text-align: center; }

    /* Transformar el Dock de PC en Barra Inferior Móvil */
    .desktop-dock { 
        display: flex !important; 
        position: fixed;
        bottom: 0;
        left: 0;
        transform: none !important; 
        width: 100vw; 
        border-radius: 20px 20px 0 0; 
        overflow-x: auto; 
        justify-content: flex-start; 
        padding: 10px 15px;
        height: 75px;
        scroll-snap-type: x mandatory; 
        z-index: 1050; /* Sobreponer a otros elementos */
    }

    /* Ocultar elementos innecesarios en móvil (Separador y Nombre) */
    .dock-separator, .dock-user-info small { display: none !important; }
    
    /* Ajustar los botones del menú para que se puedan deslizar horizontalmente */
    .dock-item {
        min-width: 70px; 
        scroll-snap-align: start;
        transform: none !important; 
        margin: 0 !important;
    }
    
    /* Quitar el efecto hover gigante (ola) en celulares, ya que interfiere con el touch */
    .dock-item:hover, .dock-item:has(+ .dock-item:hover), .dock-item:hover + .dock-item {
        transform: none !important;
        margin: 0 !important;
    }

    /* ========================================= */
    /* --- CORRECCIÓN DE TABLAS EN MÓVIL ---     */
    /* ========================================= */
    
    /* Obligar a las tablas a no aplastarse y permitir scroll horizontal limpio */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
        border: 0; 
        padding-bottom: 10px; /* Espacio extra visual al scrollear */
    }
    
    .table {
        min-width: 800px; /* Fuerza un ancho mínimo para que las columnas respiren */
    }

    /* La matriz de cuotas tiene 15 columnas, necesita aún más espacio libre */
    #tabla-matriz-cuotas {
        min-width: 1200px; 
    }

    /* Evitar que las palabras se partan hacia abajo en columnas estrechas */
    .table th, .table td {
        white-space: nowrap !important;
        vertical-align: middle;
    }

    /* Excepción: Las columnas de "Glosa", "Descripción" o "Acuerdos" sí deben 
       hacer salto de línea, pero con un ancho mínimo para que sean legibles */
    .table td.text-start {
        white-space: normal !important;
        min-width: 250px;
    }
}