/**
 * Hoja de estilos para el Dashboard principal.
 *
 * Define una interfaz de usuario moderna y animada utilizando variables CSS,
 * gradientes, sombras y efectos de transición para una experiencia de usuario atractiva.
 */

/* --- Variables Globales y Tema --- */
:root {
    /* Paleta de gradientes para diferentes elementos de la UI */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --warning-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --info-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --secondary-gradient: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    
    /* Estilos para efectos de "glassmorphism" y sombras */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-modern: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.15);
    --border-radius-lg: 20px;
    --border-radius-xl: 25px;
}

/* Sobrescribe las variables para el tema oscuro */
[data-bs-theme="dark"] {
    --glass-bg: rgba(0, 0, 0, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* --- Estilos Base del Body --- */
body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

[data-bs-theme="dark"] body {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

/* --- Contenedor y Bienvenida --- */
.main-container {
    /* El padding se gestiona en themes.css, aquí se resetea para evitar duplicidad */
    padding: 0% 0;
}

.welcome-section {
    /* Sección del título principal de bienvenida */
    margin-bottom: 1.5rem;
    text-align: center;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    /* Efecto de texto con fondo de gradiente */
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    color: #6c757d;
    font-size: 1.2rem;
    opacity: 0.8;
}

/* --- Tarjetas de Estadísticas --- */
.stat-card {
    border: none;
    border-radius: var(--border-radius-xl);
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: var(--shadow-modern);
}

/* Crea una barra superior que se anima al pasar el cursor */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

/* Efecto de elevación y crecimiento al pasar el cursor */
.stat-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card-body {
    padding: 2rem;
    position: relative;
    z-index: 2;
}

/* Contenedor circular para el icono */
.stat-icon-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

/* Crea un borde giratorio animado alrededor del icono */
.stat-icon-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: rotate 3s linear infinite;
}

/* Animación para el borde giratorio */
@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stat-icon {
    font-size: 2.5rem;
    color: white;
    z-index: 1;
    position: relative;
}

.stat-number {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
    /* El número también usa el efecto de texto con gradiente */
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: #6c757d;
    font-size: 1.1rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Asigna un gradiente de fondo específico a cada tipo de tarjeta */
.stat-empresas { background: var(--primary-gradient); }
.stat-sucursales { background: var(--info-gradient); }
.stat-empleados { background: var(--success-gradient); }
.stat-areas { background: var(--warning-gradient); }
.stat-ausencias { background: var(--warning-gradient); }
.stat-funciones { background: var(--secondary-gradient); }

/* --- Sección de Gráficos y Actividad --- */
.charts-section {
    margin-top: 4rem;
}

.chart-card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-modern);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.chart-header {
    /* Encabezado con efecto de "glassmorphism" */
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.chart-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: white;
}

.chart-body {
    padding: 2rem;
    position: relative;
    min-height: 300px;
}

/* --- Animaciones de Entrada --- */
.fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
    transform: translateY(30px);
}

/* Aplica un retraso escalonado a la animación para cada tarjeta en la fila */
.row.g-4 > div:nth-child(1) .fade-in-up { animation-delay: 0.1s; }
.row.g-4 > div:nth-child(2) .fade-in-up { animation-delay: 0.2s; }
.row.g-4 > div:nth-child(3) .fade-in-up { animation-delay: 0.3s; }
.row.g-4 > div:nth-child(4) .fade-in-up { animation-delay: 0.4s; }
.row.g-4 > div:nth-child(5) .fade-in-up { animation-delay: 0.5s; }
.row.g-4 > div:nth-child(6) .fade-in-up { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Diseño Responsivo --- */
@media (max-width: 768px) {
    .welcome-title { font-size: 2rem; }
    .stat-number { font-size: 2.5rem; }
    .stat-icon-container { width: 60px; height: 60px; }
    .stat-icon { font-size: 2rem; }
}

/* --- Efecto de Partículas de Fondo --- */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Estilo de cada partícula individual */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    animation: float-particle 20s infinite linear;
}

[data-bs-theme="dark"] .particle {
    background: rgba(255, 255, 255, 0.3);
}

/* Animación que hace que las partículas floten hacia arriba */
@keyframes float-particle {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}