/**
 * Rainify Animations System
 * Sistema centralizado de animaciones y transiciones
 */

:root {
    /* Timing Functions */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Duraciones */
    --duration-fast: 200ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
}

/* ==================== TRANSICIONES DE VISTAS ==================== */

/* Contenedor de transiciones */
#main-content {
    position: relative;
}

/* Fade In/Out */
.view-fade-enter {
    opacity: 0;
}

.view-fade-enter-active {
    opacity: 1;
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.view-fade-exit {
    opacity: 1;
}

.view-fade-exit-active {
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-smooth);
}

/* Slide From Right */
.view-slide-right-enter {
    opacity: 0;
    transform: translateX(30px);
}

.view-slide-right-enter-active {
    opacity: 1;
    transform: translateX(0);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.view-slide-right-exit {
    opacity: 1;
    transform: translateX(0);
}

.view-slide-right-exit-active {
    opacity: 0;
    transform: translateX(-30px);
    transition: all var(--duration-fast) var(--ease-smooth);
}

/* Slide From Left */
.view-slide-left-enter {
    opacity: 0;
    transform: translateX(-30px);
}

.view-slide-left-enter-active {
    opacity: 1;
    transform: translateX(0);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.view-slide-left-exit {
    opacity: 1;
    transform: translateX(0);
}

.view-slide-left-exit-active {
    opacity: 0;
    transform: translateX(30px);
    transition: all var(--duration-fast) var(--ease-smooth);
}

/* Scale Fade */
.view-scale-enter {
    opacity: 0;
    transform: scale(0.95);
}

.view-scale-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.view-scale-exit {
    opacity: 1;
    transform: scale(1);
}

.view-scale-exit-active {
    opacity: 0;
    transform: scale(1.05);
    transition: all var(--duration-fast) var(--ease-smooth);
}

/* Slide Up */
.view-slide-up-enter {
    opacity: 0;
    transform: translateY(30px);
}

.view-slide-up-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.view-slide-up-exit {
    opacity: 1;
    transform: translateY(0);
}

.view-slide-up-exit-active {
    opacity: 0;
    transform: translateY(-10px);
    transition: all var(--duration-fast) var(--ease-smooth);
}

/* ==================== ANIMACIONES DE ENTRADA ==================== */

/* Fade In Slide Up (clásica de Rainify) */
@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-fade-in {
    animation: fadeInSlideUp 0.4s var(--ease-smooth);
}

/* Fade In Simple */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade {
    animation: fadeIn 0.3s var(--ease-smooth);
}

/* Slide In From Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-right {
    animation: slideInRight 0.4s var(--ease-smooth);
}

/* Slide In From Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-left {
    animation: slideInLeft 0.4s var(--ease-smooth);
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.3s var(--ease-bounce);
}

/* Bounce In */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.animate-bounce-in {
    animation: bounceIn 0.6s var(--ease-smooth);
}

/* Rotate In */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

.animate-rotate-in {
    animation: rotateIn 0.5s var(--ease-smooth);
}

/* ==================== ANIMACIONES DE LISTA ==================== */

/* Stagger Children - aplicar delays progresivos */
.stagger-children > * {
    opacity: 0;
    animation: fadeInSlideUp 0.4s var(--ease-smooth) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }

/* ==================== MICROINTERACCIONES ==================== */

/* Hover Lift */
.hover-lift {
    transition: transform var(--duration-fast) var(--ease-smooth);
}

.hover-lift:hover {
    transform: translateY(-4px);
}

/* Hover Scale */
.hover-scale {
    transition: transform var(--duration-fast) var(--ease-smooth);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Hover Glow */
.hover-glow {
    transition: box-shadow var(--duration-normal) var(--ease-smooth);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

/* Active Press */
.active-press:active {
    transform: scale(0.95);
    transition: transform 100ms var(--ease-smooth);
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.animate-pulse {
    animation: pulse 2s var(--ease-smooth) infinite;
}

/* Spin Animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Ping Animation (para notificaciones) */
@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.animate-shake {
    animation: shake 0.5s var(--ease-smooth);
}

/* ==================== EFECTOS DE GLASSMORPHISM ANIMADOS ==================== */

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.glass-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 3s infinite;
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
}

.glow-pulse {
    animation: glowPulse 2s var(--ease-smooth) infinite;
}

/* ==================== ANIMACIONES DE NAVEGACIÓN ==================== */

/* Nav Item Active Pulse */
@keyframes navPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.nav-item.active i {
    animation: navPulse 0.3s var(--ease-smooth);
}

/* ==================== LOADING ANIMATIONS ==================== */

/* Skeleton Loading */
@keyframes skeletonLoading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton-loading {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200px 100%;
    animation: skeletonLoading 1.5s ease-in-out infinite;
}

/* ==================== CLASES AUXILIARES ==================== */

/* Delay Classes */
.delay-100 { animation-delay: 100ms !important; }
.delay-200 { animation-delay: 200ms !important; }
.delay-300 { animation-delay: 300ms !important; }
.delay-400 { animation-delay: 400ms !important; }
.delay-500 { animation-delay: 500ms !important; }

/* Duration Classes */
.duration-fast { animation-duration: var(--duration-fast) !important; }
.duration-normal { animation-duration: var(--duration-normal) !important; }
.duration-slow { animation-duration: var(--duration-slow) !important; }

/* Ease Classes */
.ease-smooth { animation-timing-function: var(--ease-smooth) !important; }
.ease-bounce { animation-timing-function: var(--ease-bounce) !important; }
.ease-spring { animation-timing-function: var(--ease-spring) !important; }

/* Animation Fill Modes */
.fill-forwards { animation-fill-mode: forwards !important; }
.fill-backwards { animation-fill-mode: backwards !important; }
.fill-both { animation-fill-mode: both !important; }

/* ==================== TRANSITION UTILITIES ==================== */

/* Transition All */
.transition-all {
    transition: all var(--duration-normal) var(--ease-smooth);
}

.transition-fast {
    transition: all var(--duration-fast) var(--ease-smooth);
}

.transition-slow {
    transition: all var(--duration-slow) var(--ease-smooth);
}

/* Specific Transitions */
.transition-transform {
    transition: transform var(--duration-normal) var(--ease-smooth);
}

.transition-opacity {
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.transition-colors {
    transition: background-color var(--duration-normal) var(--ease-smooth),
                border-color var(--duration-normal) var(--ease-smooth),
                color var(--duration-normal) var(--ease-smooth);
}

/* ==================== SCROLL ANIMATIONS ==================== */

/* Fade In on Scroll (requires JS) */
.scroll-fade {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-smooth),
                transform 0.6s var(--ease-smooth);
}

.scroll-fade.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== REDUCED MOTION ==================== */

/* Respetar preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stagger-children > * {
        animation-delay: 0ms !important;
    }
}
