/**
 * STANDARDIZED ANIMATIONS - Bimmer Modular
 * =========================================
 * Librería centralizada de micro-animaciones
 * Duración y easing consistentes usando design tokens
 * 
 * Convención de nombres:
 * - @keyframes [action]-[direction]: slideUp, fadeIn, scaleIn
 * - .animate-[name]: clase para aplicar animación
 */

/* ==================== FADE ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.animate-fade-in {
    animation: fadeIn var(--duration-normal) var(--easing-out) forwards;
}

.animate-fade-out {
    animation: fadeOut var(--duration-normal) var(--easing-out) forwards;
}

/* ==================== SLIDE ANIMATIONS ==================== */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Utility classes */
.animate-slide-in-up { animation: slideInUp var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-out-down { animation: slideOutDown var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-in-down { animation: slideInDown var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-out-up { animation: slideOutUp var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-in-left { animation: slideInLeft var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-out-left { animation: slideOutLeft var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-in-right { animation: slideInRight var(--duration-slow) var(--easing-out) forwards; }
.animate-slide-out-right { animation: slideOutRight var(--duration-slow) var(--easing-out) forwards; }

/* ==================== SCALE ANIMATIONS ==================== */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

@keyframes scalePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.animate-scale-in { animation: scaleIn var(--duration-slow) var(--easing-out) forwards; }
.animate-scale-out { animation: scaleOut var(--duration-slow) var(--easing-out) forwards; }
.animate-pulse { animation: scalePulse 2s var(--easing-in-out) infinite; }

/* ==================== ROTATION ANIMATIONS ==================== */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.95);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-rotate-in { animation: rotateIn var(--duration-slow) var(--easing-out) forwards; }
.animate-spin { animation: spin 1s linear infinite; }

/* ==================== HEIGHT/WIDTH ANIMATIONS ==================== */
@keyframes expandHeight {
    from {
        height: 0;
        opacity: 0;
    }
    to {
        height: auto;
        opacity: 1;
    }
}

@keyframes collapseHeight {
    from {
        height: auto;
        opacity: 1;
    }
    to {
        height: 0;
        opacity: 0;
    }
}

.animate-expand { animation: expandHeight var(--duration-normal) var(--easing-out) forwards; }
.animate-collapse { animation: collapseHeight var(--duration-normal) var(--easing-out) forwards; }

/* ==================== FLOAT ANIMATIONS ==================== */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

.animate-float { animation: float 3s var(--easing-in-out) infinite; }
.animate-float-slow { animation: floatSlow 4s var(--easing-in-out) infinite; }

/* ==================== BOUNCE ANIMATIONS ==================== */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(30px);
    }
    50% { opacity: 1; }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.animate-bounce { animation: bounce 1s var(--easing-bounce) infinite; }
.animate-bounce-in { animation: bounceIn var(--duration-slow) var(--easing-bounce) forwards; }

/* ==================== SHIMMER/SHINE ANIMATIONS ==================== */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }
    15% {
        left: 150%;
    }
    100% {
        left: 150%;
    }
}

.animate-shimmer {
    animation: shimmer 2s infinite;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
    background-size: 1000px 100%;
}

.animate-shine {
    position: relative;
    overflow: hidden;
}

.animate-shine::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -100%;
    width: 50%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.6), transparent);
    transform: rotate(30deg);
    animation: shine 4s infinite;
}

/* ==================== PULSE/GLOW ANIMATIONS ==================== */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
    }
}

@keyframes backgroundPulse {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(59, 130, 246, 0.1); }
}

.animate-glow-pulse { animation: glowPulse 2s var(--easing-in-out) infinite; }
.animate-bg-pulse { animation: backgroundPulse 2s var(--easing-in-out) infinite; }

/* ==================== COLOR ANIMATIONS ==================== */
@keyframes colorShift {
    0% { color: var(--color-primary); }
    50% { color: var(--color-secondary); }
    100% { color: var(--color-primary); }
}

.animate-color-shift { animation: colorShift 3s var(--easing-in-out) infinite; }

/* ==================== MODAL ANIMATIONS ==================== */
@keyframes modalBackdropIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalContentIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalCardIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-modal-backdrop { animation: modalBackdropIn var(--duration-normal) var(--easing-out) forwards; }
.animate-modal-content { animation: modalContentIn var(--duration-slow) var(--easing-out) forwards; }
.animate-modal-card { animation: modalCardIn var(--duration-slow) var(--easing-out) forwards; }

/* Stagger animation for modal cards */
.animate-modal-card:nth-of-type(1) { animation-delay: 0.06s; }
.animate-modal-card:nth-of-type(2) { animation-delay: 0.12s; }
.animate-modal-card:nth-of-type(3) { animation-delay: 0.18s; }

/* ==================== DROPDOWN/MENU ANIMATIONS ==================== */
@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-dropdown { animation: dropdownSlide var(--duration-normal) var(--easing-out) forwards; }

/* ==================== TOAST/NOTIFICATION ANIMATIONS ==================== */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.animate-toast-in { animation: toastSlideIn var(--duration-normal) var(--easing-out) forwards; }
.animate-toast-out { animation: toastSlideOut var(--duration-normal) var(--easing-out) forwards; }

/* ==================== SKELETON LOADING ANIMATION ==================== */
@keyframes skeleton-loading {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.animate-skeleton {
    animation: skeleton-loading 2s infinite;
    background: linear-gradient(
        to right,
        #f3f3f3 8%,
        #e8e8e8 18%,
        #f3f3f3 33%
    );
    background-size: 1000px 100%;
}

body.dark-mode .animate-skeleton {
    background: linear-gradient(
        to right,
        #2a2a2a 8%,
        #1e1e1e 18%,
        #2a2a2a 33%
    );
}

/* ==================== INTERACTION ANIMATIONS ==================== */
.btn-press {
    animation: buttonPress 0.1s var(--easing-in-out);
}

@keyframes buttonPress {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.98); }
}

/* ==================== DELAY UTILITIES ==================== */
.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }
.animate-delay-500 { animation-delay: 0.5s; }

/* ==================== ANIMATION SPEED MODIFIERS ==================== */
.animate-fast { animation-duration: var(--duration-fast); }
.animate-slow { animation-duration: var(--duration-slow); }
.animate-slower { animation-duration: var(--duration-slower); }

/* ==================== RESPONSIVE - Disable animations on reduced motion ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
