/* Variables CSS para colores consistentes */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --gradient-primary: linear-gradient(135deg, #0d6efd 0%, #0056b3 100%);
    --gradient-secondary: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    --shadow-light: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-medium: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-large: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    
    /* Light mode variables */
    --bg-color: #ffffff;
    --text-color: #212529;
    --card-bg: #ffffff;
    --section-bg: #f8f9fa;
    --border-color: rgba(0, 0, 0, 0.125);
    --navbar-bg: rgba(13, 110, 253, 0.95);
    --footer-bg: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

/* Dark mode variables */
[data-theme="dark"] {
    --primary-color: #4dabf7;
    --secondary-color: #adb5bd;
    --success-color: #51cf66;
    --info-color: #22d3ee;
    --warning-color: #ffd43b;
    --danger-color: #ff6b6b;
    --dark-color: #f8f9fa;
    --light-color: #212529;
    --gradient-primary: linear-gradient(135deg, #4dabf7 0%, #339af0 100%);
    --gradient-secondary: linear-gradient(135deg, #495057 0%, #343a40 100%);
    --shadow-light: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
    --shadow-large: 0 1rem 3rem rgba(0, 0, 0, 0.5);
    
    /* Dark mode specific variables */
    --bg-color: #1a1a1a;
    --text-color: #f8f9fa;
    --card-bg: #2d3748;
    --section-bg: #252525;
    --border-color: rgba(255, 255, 255, 0.125);
    --navbar-bg: rgba(77, 171, 247, 0.95);
    --footer-bg: linear-gradient(135deg, #343a40 0%, #212529 100%);
}

/* Reset y configuración general */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    scroll-behavior: smooth;
    padding-top: 76px; /* Espacio para navbar fijo */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navbar personalizado */
.navbar {
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-medium);
    transition: all 0.3s ease;
    background-color: var(--navbar-bg) !important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: #fff !important;
}

.navbar-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: #fff;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
    width: 100%;
}

/* Hero Section */
.hero-section {
    background: var(--gradient-primary);
    color: white;
    padding: 100px 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" fill="white" opacity="0.1"><polygon points="0,0 1000,0 1000,60 0,100"/></svg>');
    background-size: cover;
    background-repeat: no-repeat;
}

.hero-section .container {
    position: relative;
    z-index: 2;
}

.hero-chart-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-large);
    position: relative;
    overflow: hidden;
    animation: chartGlow 3s ease-in-out infinite alternate;
}

.hero-chart-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255, 99, 132, 0.1) 50%, 
        rgba(54, 162, 235, 0.1) 70%, 
        transparent 90%);
    animation: shimmer 4s linear infinite;
    z-index: -1;
}

.hero-chart-container canvas {
    position: relative;
    z-index: 2;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

@keyframes chartGlow {
    0% {
        box-shadow: 
            var(--shadow-large),
            0 0 20px rgba(255, 99, 132, 0.3),
            0 0 40px rgba(54, 162, 235, 0.2);
    }
    100% {
        box-shadow: 
            var(--shadow-large),
            0 0 30px rgba(54, 162, 235, 0.4),
            0 0 60px rgba(255, 206, 86, 0.3);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.3;
    }
    25% {
        transform: translateY(-10px) rotate(90deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-20px) rotate(180deg);
        opacity: 1;
    }
    75% {
        transform: translateY(-10px) rotate(270deg);
        opacity: 0.7;
    }
}

.particle {
    pointer-events: none;
}

/* Mejora adicional para el hero */
.hero-section {
    position: relative;
    overflow: hidden;
}

/* Secciones principales */
.section-padding {
    padding: 80px 0;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

.section-subtitle {
    font-size: 1.2rem;
    color: var(--secondary-color);
    max-width: 600px;
    margin: 0 auto;
}

/* Cards de gráficos */
.chart-card {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-medium);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    height: 100%;
}

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

.chart-card .card-header {
    background: var(--gradient-primary);
    color: white;
    padding: 20px 25px;
    border: none;
    font-weight: 600;
}

.chart-card .card-body {
    padding: 30px 25px;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-card canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Aplicar animaciones */
.chart-card {
    animation: fadeInUp 0.6s ease forwards;
}

.chart-card:nth-child(odd) {
    animation: fadeInLeft 0.6s ease forwards;
}

.chart-card:nth-child(even) {
    animation: fadeInRight 0.6s ease forwards;
}

/* Botones personalizados */
.btn {
    border-radius: 50px;
    padding: 12px 30px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    box-shadow: var(--shadow-medium);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

/* Backgrounds alternos */
.bg-light {
    background: var(--section-bg) !important;
    transition: background 0.3s ease;
}

/* Footer */
footer {
    background: var(--footer-bg) !important;
    position: relative;
    transition: background 0.3s ease;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, white 50%, transparent 100%);
}

/* Efectos de hover para iconos */
.fas, .far, .fab {
    transition: all 0.3s ease;
}

.section-title .fas:hover,
.card-header .fas:hover {
    transform: scale(1.2) rotate(5deg);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding-top: 66px;
    }
    
    .hero-section {
        padding: 60px 0;
        text-align: center;
    }
    
    .section-padding {
        padding: 60px 0;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .chart-card .card-body {
        height: 300px;
        padding: 20px 15px;
    }
    
    .hero-chart-container {
        margin-top: 40px;
        padding: 20px;
    }
}

@media (max-width: 576px) {
    .section-title {
        font-size: 1.8rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    .chart-card .card-body {
        height: 250px;
    }
}

/* Efectos de carga */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--secondary-color);
}

.chart-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Tooltips personalizados para Chart.js */
.chartjs-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    border-radius: 8px !important;
    color: white !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 12px !important;
    padding: 10px !important;
    box-shadow: var(--shadow-medium) !important;
}

/* Mejoras de accesibilidad */
.chart-card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Estados de hover mejorados */
.navbar-nav .nav-link:focus,
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

/* Efectos de glassmorphism para algunos elementos */
.hero-chart-container {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .hero-chart-container {
    background: rgba(45, 55, 72, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-card {
    backdrop-filter: blur(10px);
}

/* Transiciones suaves para todos los elementos interactivos */
a, button, .chart-card, .btn, .nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme Toggle Button Styles */
.theme-toggle-container {
    display: flex;
    align-items: center;
    margin-left: 15px;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover::before {
    width: 100%;
    height: 100%;
}

.theme-toggle-btn i {
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
}

/* Dark mode scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #2d3748;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
}

/* Dark mode tooltip adjustments */
[data-theme="dark"] .chartjs-tooltip {
    background: rgba(45, 55, 72, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Dark mode section subtitle color */
[data-theme="dark"] .section-subtitle {
    color: var(--secondary-color);
}

/* Responsive adjustments for theme toggle */
@media (max-width: 768px) {
    .theme-toggle-container {
        margin-left: 10px;
    }
    
    .theme-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}