/**
 * Animaciones UI - Biblioteca reutilizable
 * 
 * Animaciones sutiles y profesionales para mejorar la experiencia de usuario.
 * Todas las duraciones y easings están optimizados para ser fluidos sin ser invasivos.
 *
 */

/* ============================================
   Keyframes
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    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(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ============================================
   Clases de animación de entrada
   ============================================ */

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.3s ease-out forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.3s ease-out forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.3s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

.animate-slide-in {
    animation: slideInFromBottom 0.3s ease-out forwards;
}

/* ============================================
   Estado inicial: elementos ocultos antes de animar
   ============================================ */

.animation-ready {
    opacity: 0;
}

/* ============================================
   Animación de contenido principal (páginas)
   ============================================ */

.page-content-animate {
    animation: fadeInUp 0.35s ease-out forwards;
}

/* ============================================
   Cards con aparición escalonada
   ============================================ */

.card-stagger {
    opacity: 0;
    animation: fadeInUp 0.3s ease-out forwards;
}

.card-stagger:nth-child(1) { animation-delay: 0.05s; }
.card-stagger:nth-child(2) { animation-delay: 0.1s; }
.card-stagger:nth-child(3) { animation-delay: 0.15s; }
.card-stagger:nth-child(4) { animation-delay: 0.2s; }
.card-stagger:nth-child(5) { animation-delay: 0.25s; }
.card-stagger:nth-child(6) { animation-delay: 0.3s; }
.card-stagger:nth-child(7) { animation-delay: 0.35s; }
.card-stagger:nth-child(8) { animation-delay: 0.4s; }
.card-stagger:nth-child(9) { animation-delay: 0.45s; }
.card-stagger:nth-child(10) { animation-delay: 0.5s; }

/* Grid de cards escalonadas */
/* Nota: estas reglas aplican solo a grids con la clase .grid-animate para evitar conflictos */
.grid-animate .col-12 .card,
.grid-animate .col-md-6 .card,
.grid-animate .col-md-4 .card,
.grid-animate .col-md-3 .card {
    opacity: 0;
    animation: fadeInUp 0.3s ease-out forwards;
}

.grid-animate .col-12 .card:nth-child(1),
.grid-animate .col-md-6 .card:nth-child(1),
.grid-animate .col-md-4 .card:nth-child(1),
.grid-animate .col-md-3 .card:nth-child(1) { animation-delay: 0.05s; }

.grid-animate .col-12 .card:nth-child(2),
.grid-animate .col-md-6 .card:nth-child(2),
.grid-animate .col-md-4 .card:nth-child(2),
.grid-animate .col-md-3 .card:nth-child(2) { animation-delay: 0.1s; }

.grid-animate .col-12 .card:nth-child(3),
.grid-animate .col-md-6 .card:nth-child(3),
.grid-animate .col-md-4 .card:nth-child(3),
.grid-animate .col-md-3 .card:nth-child(3) { animation-delay: 0.15s; }

.grid-animate .col-12 .card:nth-child(4),
.grid-animate .col-md-6 .card:nth-child(4),
.grid-animate .col-md-4 .card:nth-child(4),
.grid-animate .col-md-3 .card:nth-child(4) { animation-delay: 0.2s; }

.grid-animate .col-12 .card:nth-child(5),
.grid-animate .col-md-6 .card:nth-child(5),
.grid-animate .col-md-4 .card:nth-child(5),
.grid-animate .col-md-3 .card:nth-child(5) { animation-delay: 0.25s; }

.grid-animate .col-12 .card:nth-child(6),
.grid-animate .col-md-6 .card:nth-child(6),
.grid-animate .col-md-4 .card:nth-child(6),
.grid-animate .col-md-3 .card:nth-child(6) { animation-delay: 0.3s; }

/* ============================================
   Micro-interacciones: Botones
   ============================================ */

.btn-animate {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-animate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-animate:active {
    transform: translateY(0);
}

/* ============================================
   Micro-interacciones: Tablas
   ============================================ */

.table-row-hover {
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.table-row-hover:hover {
    background-color: rgba(0, 0, 0, 0.03);
    transform: scale(1.002);
}

/* ============================================
   Micro-interacciones: Iconos en headers
   ============================================ */

.header-icon-animate i {
    transition: transform 0.2s ease;
}

.header-icon-animate:hover i {
    transform: scale(1.1);
}

/* ============================================
   Micro-interacciones: Cards hover
   ============================================ */

.card-hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ============================================
   Transiciones suaves para componentes
   ============================================ */

.smooth-transition {
    transition: all 0.2s ease;
}

/* ============================================
   Utilidades de duración
   ============================================ */

.anim-fast {
    animation-duration: 0.15s !important;
}

.anim-normal {
    animation-duration: 0.3s !important;
}

.anim-slow {
    animation-duration: 0.5s !important;
}

/* ============================================
   Animación de pulsación (para alertas/notificaciones)
   ============================================ */

.anim-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================
   Reduced motion: accesibilidad
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
