/**
 * Animaciones personalizadas para CSVM
 * Optimizadas para UX móvil y desktop
 */

/* Animaciones de entrada */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Clases de animación */
.animate-fade-in {
    animation: fade-in 0.5s ease-out;
}

.animate-fade-in-up {
    animation: fade-in-up 0.6s ease-out;
}

.animate-slide-in-right {
    animation: slide-in-right 0.4s ease-out;
}

.animate-bounce-in {
    animation: bounce-in 0.6s ease-out;
}

/* Animaciones con delay para efectos escalonados */
.animate-delay-100 {
    animation-delay: 100ms;
}

.animate-delay-200 {
    animation-delay: 200ms;
}

.animate-delay-300 {
    animation-delay: 300ms;
}

/* Loading spinner mejorado */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Micro-interacciones para tarjetas */
.client-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.client-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Efectos de progreso */
.progress-bar {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animaciones de botones */
.btn-animate {
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}

.btn-animate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.btn-animate:active {
    transform: translateY(0);
}

/* Ripple effect para botones */
.btn-animate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn-animate:active::before {
    width: 300px;
    height: 300px;
}

/* Estados de filtros */
.filter-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Transiciones suaves para modo oscuro */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Optimizaciones para móvil */
@media (max-width: 768px) {
    .client-card:hover {
        transform: none; /* Desactivar hover en móvil */
    }
    
    .animate-fade-in-up {
        animation-duration: 0.4s; /* Animaciones más rápidas en móvil */
    }
}

/* Skeleton loading para mejor UX */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

/* Indicadores de estado mejorados */
.status-indicator {
    position: relative;
    overflow: hidden;
}

.status-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.status-indicator:hover::after {
    left: 100%;
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states mejorados */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
    border-color: #3b82f6;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}

/* Optimización de rendimiento */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Estilos para filtros chips */
.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #f3f4f6;
    color: #6b7280;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent;
    cursor: pointer;
}

.filter-chip:hover {
    background-color: #e5e7eb;
    color: #374151;
    transform: translateY(-1px);
}

.filter-chip.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.dark .filter-chip {
    background-color: #374151;
    color: #9ca3af;
}

.dark .filter-chip:hover {
    background-color: #4b5563;
    color: #d1d5db;
}

.dark .filter-chip.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

/* Animación para colapsar filtros */
.filters-collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
}

.filters-expanded {
    max-height: 500px;
    opacity: 1;
    transition: all 0.3s ease-in-out;
}

/* Mejoras para tarjetas de cliente */
.client-card {
    border: 1px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, transparent, rgba(59, 130, 246, 0.1)) border-box;
}

.dark .client-card {
    background: linear-gradient(#374151, #374151) padding-box,
                linear-gradient(135deg, transparent, rgba(59, 130, 246, 0.2)) border-box;
}

/* Estados de activación con colores */
.activation-0 { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.activation-25 { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }
.activation-50 { background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%); }
.activation-75 { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.activation-100 { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }

/* Responsive improvements */
@media (max-width: 640px) {
    .client-card {
        margin-bottom: 1rem;
    }
    
    .filter-chip {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}
