/* =========================================
   1. CONFIGURACIÓN GENERAL
   ========================================= */
* {
    box-sizing: border-box; /* Fundamental para que los tamaños no se rompan */
}

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Evita scroll horizontal indeseado */
}

/* Contenedor flexible */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    position: relative;
}

/* =========================================
   2. SIDEBAR (MENÚ LATERAL)
   ========================================= */
#sidebar {
    min-width: 250px;
    max-width: 250px;
    background: #212529; /* Negro elegante */
    color: #fff;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* Animación suave */
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000; /* Por encima de casi todo */
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2);
}

#sidebar .sidebar-header {
    padding: 20px;
    background: #1a1d20;
    text-align: center;
    border-bottom: 1px solid #343a40;
}

/* Lista Scrollable */
#sidebar ul.components {
    padding: 20px 0;
    flex-grow: 1;
    overflow-y: auto;
}

/* Scrollbar personalizada para el menú */
#sidebar ul.components::-webkit-scrollbar { width: 5px; }
#sidebar ul.components::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }

#sidebar ul p {
    color: #adb5bd;
    padding: 10px 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 0;
}

#sidebar ul li a {
    padding: 15px 20px;
    font-size: 0.95rem;
    display: block;
    color: #dee2e6;
    text-decoration: none;
    transition: 0.2s;
    border-left: 4px solid transparent;
}

#sidebar ul li a:hover {
    color: #fff;
    background: #343a40;
    border-left: 4px solid #adb5bd;
}

#sidebar ul li.active > a {
    color: #fff;
    background: #0d6efd; /* Azul Bootstrap */
    border-left: 4px solid #fff;
}

/* Botón Hamburguesa (Solo visible en móvil) */
#sidebarCollapse {
    display: none; /* Oculto en PC */
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 2001; /* Encima del sidebar */
    padding: 10px 15px;
    border-radius: 5px;
    background: #212529;
    color: white;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* =========================================
   3. ÁREA DE CONTENIDO
   ========================================= */
#content {
    width: calc(100% - 250px); /* Resto del ancho */
    padding: 30px;
    min-height: 100vh;
    transition: all 0.3s;
    margin-left: 250px; /* Espacio para el sidebar */
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

/* =========================================
   4. SISTEMA RESPONSIVO GLOBAL (MÓVIL)
   ========================================= */
@media (max-width: 992px) {
    /* 1. Sidebar se oculta a la izquierda */
    #sidebar {
        margin-left: -250px;
    }
    
    /* 2. Cuando tiene la clase .active, entra */
    #sidebar.active {
        margin-left: 0;
        box-shadow: 0 0 100px rgba(0,0,0,0.5); /* Sombra intensa para resaltar */
    }

    /* 3. Contenido ocupa todo el ancho */
    #content {
        width: 100%;
        margin-left: 0;
        padding: 15px; /* Menos padding en celular */
        padding-top: 60px; /* Espacio para el botón hamburguesa */
    }

    /* 4. Aparece el botón hamburguesa */
    #sidebarCollapse {
        display: inline-block;
    }

    /* 5. Ajustes de tipografía y botones */
    h2, .h2 { font-size: 1.5rem; }
    .btn-lg { width: 100%; margin-bottom: 5px; }
    
    /* Tabla con scroll horizontal en móvil */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* --- MEJORAS PARA EL LOGIN EN MÓVIL --- */
    body.login-page {
        padding: 15px; /* Margen para que no toque los bordes de la pantalla */
    }
    
    .login-card {
        max-width: 100%;
        margin: 0;
        border-radius: 16px; /* Curvas más suaves en celular */
        box-shadow: 0 8px 20px rgba(0,0,0,0.15); /* Sombra un poco más profunda */
    }
    
    .login-header {
        padding: 25px 15px; /* Ajuste de padding */
    }
    
    .login-body {
        padding: 30px 20px; /* Ajuste de padding */
    }
}

/* =========================================
   5. CALENDARIO AGENDA (RESPONSIVO PRO)
   ========================================= */

/* Contenedor Grid */
.calendar-wrapper {
    display: grid;
    /* ESCRITORIO: 3 columnas */
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
}

/* --- MAGIA: MÓVIL A 1 COLUMNA --- */
@media (max-width: 1000px) {
    .calendar-wrapper {
        /* CELULAR: 1 sola columna (1 mes por fila) */
        grid-template-columns: 1fr !important; 
        gap: 30px !important;
    }
    .day-cell {
        height: 60px !important; /* Celdas más altas para dedos táctiles */
    }
}

.month-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
    overflow: visible; /* Permite que el tooltip salga */
    position: relative;
}

.month-header {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 10px 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    border-radius: 7px 7px 0 0;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.day-name {
    background: #f8f9fa;
    padding: 8px 0;
    font-size: 0.7rem;
    font-weight: bold;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
}

.day-cell {
    height: 55px;
    border-right: 1px solid #f1f1f1;
    border-bottom: 1px solid #f1f1f1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 4px;
    transition: all 0.2s;
    cursor: default;
}

.day-number {
    font-size: 0.75rem;
    font-weight: bold;
    color: #868e96;
    margin-bottom: 2px;
    pointer-events: none;
}

/* Hover de la celda (Efecto Pop) */
.day-cell:hover {
    z-index: 1000;
    background-color: #fff;
    box-shadow: 0 0 15px rgba(0,0,0,0.15);
    transform: scale(1.05);
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Puntos de colores */
.event-dots {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    width: 100%;
    padding: 0 2px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    cursor: pointer;
    background-color: var(--dot-color);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

/* Día Full Color */
.day-full-color {
    color: white !important;
    cursor: pointer;
}
.day-full-color .day-number { color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }

/* --- TOOLTIPS (TARJETAS FLOTANTES) --- */
.tooltip-evento {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 110%; /* Arriba de la celda */
    left: 50%;
    transform: translateX(-50%);
    
    background-color: #212529;
    color: #fff;
    padding: 12px;
    border-radius: 6px;
    width: max-content;
    min-width: 200px;
    max-width: 280px;
    
    font-size: 0.8rem;
    text-align: left;
    z-index: 9999;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto; /* Permite clic en links dentro del tooltip */
}

/* Flechita */
.tooltip-evento::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #212529 transparent transparent transparent;
}

.dot:hover .tooltip-evento, 
.day-full-color:hover .tooltip-evento {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* =========================================
   6. IMPRESIÓN (PRINT) - SIEMPRE PERFECTA
   ========================================= */
@media print {
    @page { size: landscape; margin: 0.5cm; }
    
    /* Ocultar todo lo que no sirve en papel */
    .no-print, header, footer, .sidebar, #sidebar, #sidebarCollapse, .navbar, .btn {
        display: none !important;
    }

    /* Resetear layout */
    body, .wrapper, #content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
        display: block !important;
    }

    .print-area {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }

    /* FORZAR 4 COLUMNAS EN IMPRESIÓN AUNQUE SEAS CELULAR */
    .calendar-wrapper {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        padding: 0 !important;
        border: none !important;
        background: none !important;
    }

    .month-card {
        box-shadow: none !important;
        border: 1px solid #999 !important;
        break-inside: avoid;
    }

    .month-header {
        background: #ddd !important; /* Gris claro para ahorrar tinta */
        color: black !important;
        border-bottom: 1px solid #000;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .day-cell { height: 40px !important; }

    /* Forzar colores e ignorar todo lo que los sobreescribía */
    * { 
        -webkit-print-color-adjust: exact !important; 
        print-color-adjust: exact !important; 
        color-adjust: exact !important;
    }
    
    .dot {
        border: 1px solid rgba(0,0,0,0.5) !important;
    }
    
    .day-full-color {
        color: white !important;
    }

    .day-full-color .day-number {
        color: white !important;
        text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
    }

    .tooltip-evento { display: none !important; }
}

/* =========================================
   ESTILOS LOGIN (PROFESIONAL Y RESPONSIVO)
   ========================================= */
body.login-page {
    background: #e9ecef; /* Gris suave de fondo */
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', sans-serif;
    padding: 20px; /* Importante para que no se pegue a los bordes en celular */
}

.login-card {
    width: 100%;
    max-width: 400px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); /* Sombra elegante */
    overflow: hidden; /* Para que el header no se salga de las curvas */
    background: white;
    /* Evita que se encoja feo si la pantalla es muy pequeña */
    flex-shrink: 0; 
}

.login-header {
    background: #212529; /* Mismo negro del Sidebar */
    color: white;
    padding: 35px 25px; /* Un poco más de aire */
    text-align: center;
    border-bottom: 4px solid #0d6efd; /* Línea azul decorativa */
}

.login-header h4 {
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0; /* Limpia márgenes extra */
}

.login-body {
    padding: 40px 30px;
}

.input-group-text {
    background-color: #f8f9fa;
    border-right: none;
    color: #6c757d; /* Iconos un poco más sutiles */
}

.form-control {
    border-left: none; /* Para que se fusione con el icono */
    padding: 12px 10px; /* Más fáciles de tocar en móvil */
}

/* Foco en inputs: línea azul sutil */
.form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
    border-bottom: 2px solid #0d6efd;
    background-color: #fff;
}

/* Ajuste del Focus cuando envuelve todo el grupo (para el icono) */
.input-group:focus-within .input-group-text {
    border-bottom: 2px solid #0d6efd;
}

.btn-login {
    padding: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    border-radius: 6px;
    margin-top: 15px; /* Un poco más despegado de los inputs */
    transition: all 0.2s ease-in-out;
}

.btn-login:hover {
    transform: translateY(-2px); /* Efecto sutil al pasar el mouse/dedo */
    box-shadow: 0 5px 15px rgba(13, 110, 253, 0.3);
}

/* =========================================
   7. ESTILOS DEL DASHBOARD (PANEL EJECUTIVO)
   ========================================= */

/* --- Tarjetas de Indicadores (Métricas) --- */
.dashboard-metrics .card {
    transition: all 0.3s ease-in-out;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    border: none !important;
}

/* Efecto de elevación al pasar el mouse */
.dashboard-metrics .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15) !important;
}

/* Icono de fondo gigante y sutil */
.dashboard-metrics .card::after {
    content: "";
    position: absolute;
    top: -20px;
    right: -20px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

/* Asegurar que el texto quede por encima del círculo decorativo */
.dashboard-metrics .card .d-flex {
    position: relative;
    z-index: 1;
}

/* Degradados Elegantes (Reemplazando colores sólidos aburridos) */
.bg-gradient-info {
    background: linear-gradient(135deg, #0dcaf0 0%, #087990 100%) !important;
}
.bg-gradient-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a4ebd 100%) !important;
}
.bg-gradient-dark {
    background: linear-gradient(135deg, #2b3035 0%, #111315 100%) !important;
}
.bg-gradient-success {
    background: linear-gradient(135deg, #198754 0%, #105936 100%) !important;
}
.bg-gradient-danger {
    background: linear-gradient(135deg, #dc3545 0%, #9e1c27 100%) !important;
}

.dashboard-metrics h6 {
    letter-spacing: 1.5px;
    font-size: 0.75rem;
    opacity: 0.9;
}

.dashboard-metrics h2 {
    font-size: 2.2rem;
    line-height: 1;
}

/* --- Secciones de Tablas y Listas --- */
.dashboard-section .card {
    border-radius: 12px;
    border: 1px solid #edf2f9;
}

.dashboard-section .card-header {
    background-color: transparent;
    border-bottom: 1px solid #edf2f9 !important; /* Línea más suave */
    padding-top: 20px;
    padding-bottom: 20px;
}

.dashboard-section .card-header.border-danger {
    border-bottom: 3px solid #dc3545 !important;
}

/* Estilizando la tabla de Urgentes */
.table-urgentes th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #8392a5;
    border-top: none;
}

.table-urgentes td {
    vertical-align: middle;
    padding: 15px 10px;
    color: #495057;
}

/* Estilizando la lista de Próximos Eventos */
.lista-proximos .list-group-item {
    border-left: none;
    border-right: none;
    border-bottom: 1px solid #edf2f9;
    padding: 15px 20px;
    transition: background-color 0.2s;
}

.lista-proximos .list-group-item:first-child { border-top: none; }
.lista-proximos .list-group-item:last-child { border-bottom: none; }

.lista-proximos .list-group-item:hover {
    background-color: #f8f9fa;
}

/* Ajustes Responsive para el Dashboard */
@media (max-width: 768px) {
    .dashboard-metrics .col {
        /* En celular, que cada tarjetita ocupe el 50% del ancho (2 columnas) */
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 15px;
    }
    .dashboard-metrics h2 {
        font-size: 1.8rem;
    }
}
@media (max-width: 480px) {
    .dashboard-metrics .col {
        /* En pantallas muy chicas, 1 columna */
        flex: 0 0 100%;
        max-width: 100%;
    }
}