/* ===============================
   ANIMATIONS - CENTRALIZADAS
   Animaciones compartidas para todo el dashboard
================================ */

/* =========================
   KEYFRAMES
========================= */

@keyframes fadeIn {
    from { 
        opacity: 0; 
    }
    to { 
        opacity: 1; 
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(108,99,255,.4); }
    70% { box-shadow: 0 0 0 10px rgba(108,99,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(108,99,255,0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =========================
   CLASES DE UTILIDAD (Para animaciones automáticas del dashboard)
========================= */

.fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

/* NOTA: fade-in-up, fade-in-left, fade-in-right ahora son para SCROLL REVEAL
   y están definidas más abajo con transitions en vez de animations */

.fade-in-down {
    opacity: 0;
    animation: fadeInDown 0.5s ease forwards;
}

.slide-up {
    opacity: 0;
    animation: slideUp 0.5s ease forwards;
}

.slide-down {
    opacity: 0;
    animation: slideDown 0.5s ease forwards;
}

.shake {
    animation: shake 0.4s ease;
}

.float {
    animation: float 3s ease-in-out infinite;
}

.pulse {
    animation: pulse 1.5s infinite;
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

.scale-in {
    opacity: 0;
    animation: scaleIn 0.4s ease forwards;
}

.animate-in {
    opacity: 0;
    animation: cardFadeIn 0.5s ease forwards;
}

/* =========================
   ANIMACIONES SECUENCIALES (Para dashboard cards)
========================= */

/* Para cards en grids */
.cards-grid .dashboard-card:nth-child(1),
.stat-card-vertical:nth-child(1) { 
    animation-delay: 0s; 
}

.cards-grid .dashboard-card:nth-child(2),
.stat-card-vertical:nth-child(2) { 
    animation-delay: 0.05s; 
}

.cards-grid .dashboard-card:nth-child(3),
.stat-card-vertical:nth-child(3) { 
    animation-delay: 0.1s; 
}

.cards-grid .dashboard-card:nth-child(4),
.stat-card-vertical:nth-child(4) { 
    animation-delay: 0.15s; 
}

.cards-grid .dashboard-card:nth-child(5),
.stat-card-vertical:nth-child(5) { 
    animation-delay: 0.2s; 
}

.cards-grid .dashboard-card:nth-child(6),
.stat-card-vertical:nth-child(6) { 
    animation-delay: 0.25s; 
}

.cards-grid .dashboard-card:nth-child(7) { 
    animation-delay: 0.3s; 
}

.cards-grid .dashboard-card:nth-child(8) { 
    animation-delay: 0.35s; 
}

.cards-grid .dashboard-card:nth-child(9) { 
    animation-delay: 0.4s; 
}

/* Para stats cards */
.stat-card-vertical {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

/* Para elementos en lista */
.list-item-animated {
    opacity: 0;
    animation: fadeInLeft 0.4s ease forwards;
}

.list-item-animated:nth-child(1) { animation-delay: 0s; }
.list-item-animated:nth-child(2) { animation-delay: 0.1s; }
.list-item-animated:nth-child(3) { animation-delay: 0.15s; }
.list-item-animated:nth-child(4) { animation-delay: 0.2s; }
.list-item-animated:nth-child(5) { animation-delay: 0.25s; }

/* =========================
   SCROLL REVEAL ANIMATIONS
   Estas clases usan TRANSITIONS controladas por JavaScript
========================= */

/* Estados iniciales - ocultos hasta que entren al viewport */
.scroll-fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-fade-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-fade-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-fade-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Estados visibles - activados por JavaScript cuando entran al viewport */
.scroll-fade-up.visible,
.scroll-fade-left.visible,
.scroll-fade-right.visible,
.scroll-fade-scale.visible {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}

/* Delays para scroll reveal */
.scroll-fade-up.delay-1,
.scroll-fade-left.delay-1,
.scroll-fade-right.delay-1 { 
    transition-delay: 0.1s;
}

.scroll-fade-up.delay-2,
.scroll-fade-left.delay-2,
.scroll-fade-right.delay-2 { 
    transition-delay: 0.2s;
}

.scroll-fade-up.delay-3,
.scroll-fade-left.delay-3,
.scroll-fade-right.delay-3 { 
    transition-delay: 0.3s;
}

.scroll-fade-up.delay-4,
.scroll-fade-left.delay-4,
.scroll-fade-right.delay-4 { 
    transition-delay: 0.4s;
}

/* =========================
   ANIMACIÓN INMEDIATA PARA HERO
   El hero usa animación automática, no scroll reveal
========================= */
.hero-brand .fade-in-up {
    opacity: 0;
    animation: fadeInUp 1s ease-out forwards;
}

.hero-brand .fade-in-up.delay-1 {
    animation-delay: 0.2s;
}

.hero-brand .fade-in-up.delay-2 {
    animation-delay: 0.4s;
}

/* =========================
   ESTADOS DE HOVER
========================= */

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.3);
}

/* =========================
   LOADING STATES
========================= */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f4f6;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* =========================
   TRANSICIONES COMUNES
========================= */

.transition-all {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.5s ease;
}

/* =========================
   DELAYS PERSONALIZADOS
========================= */

.delay-50 { animation-delay: 0.05s; transition-delay: 0.05s; }
.delay-75 { animation-delay: 0.075s; transition-delay: 0.075s; }
.delay-100 { animation-delay: 0.1s; transition-delay: 0.1s; }
.delay-150 { animation-delay: 0.15s; transition-delay: 0.15s; }
.delay-200 { animation-delay: 0.2s; transition-delay: 0.2s; }
.delay-250 { animation-delay: 0.25s; transition-delay: 0.25s; }
.delay-300 { animation-delay: 0.3s; transition-delay: 0.3s; }
.delay-350 { animation-delay: 0.35s; transition-delay: 0.35s; }
.delay-400 { animation-delay: 0.4s; transition-delay: 0.4s; }
.delay-450 { animation-delay: 0.45s; transition-delay: 0.45s; }
.delay-500 { animation-delay: 0.5s; transition-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; transition-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; transition-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; transition-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; transition-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; transition-delay: 1s; }

/* =========================
   ANIMACIONES ADICIONALES
========================= */

/* Flip horizontal */
@keyframes flipInX {
    from {
        opacity: 0;
        transform: perspective(400px) rotateX(-90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateX(0);
    }
}

.flip-in-x {
    animation: flipInX 0.6s ease-out;
}

/* Zoom In */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.zoom-in {
    animation: zoomIn 0.5s ease-out;
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 5px rgba(108, 99, 255, 0.5),
                    0 0 10px rgba(108, 99, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(108, 99, 255, 0.8),
                    0 0 30px rgba(108, 99, 255, 0.5);
    }
}

.glow-pulse {
    animation: glowPulse 2s ease-in-out infinite;
}

/* Shake Error */
@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake-error {
    animation: shakeError 0.5s ease;
}

/* =========================
   UTILITIES
========================= */

.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Animation fill modes */
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

/* Pause animation */
.animation-paused { animation-play-state: paused; }
.animation-running { animation-play-state: running; }

/* =========================
   REDUCCIÓN DE MOVIMIENTO
========================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .float,
    .bounce,
    .pulse {
        animation: none;
    }
}