/* Micro-interacciones Avanzadas para MentalFam - COMPLETO */
/* Versión: 1.0.0 */

/* ===== ANIMACIONES DE ENTRADA ===== */
@keyframes slideInFromLeft {
    0% { opacity: 0; transform: translateX(-50px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromRight {
    0% { opacity: 0; transform: translateX(50px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromTop {
    0% { opacity: 0; transform: translateY(-30px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromBottom {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes rotateIn {
    0% { opacity: 0; transform: rotate(-10deg) scale(0.9); }
    100% { opacity: 1; transform: rotate(0deg) scale(1); }
}

/* ===== EFECTOS DE HOVER AVANZADOS ===== */
.hover-lift-advanced {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
    position: relative;
    overflow: hidden;
}

.hover-lift-advanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
}

.hover-lift-advanced:hover::before {
    left: 100%;
}

.hover-lift-advanced:hover {
    transform: translateY(-8px) scale(1.02) rotateX(5deg) rotateY(2deg);
    box-shadow: 0 20px 40px rgba(123, 67, 151, 0.3), 0 0 0 1px rgba(123, 67, 151, 0.1);
}

/* ===== EFECTOS DE BOTONES MEJORADOS ===== */
.btn-ripple {
    position: relative;
    overflow: hidden;
    transform: translate3d(0, 0, 0);
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ===== EFECTOS DE CARGA ELEGANTES ===== */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ===== EFECTOS DE ENTRADA PARA ELEMENTOS ===== */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-on-scroll.slide-left {
    transform: translateX(-50px);
}

.animate-on-scroll.slide-left.visible {
    transform: translateX(0);
}

.animate-on-scroll.slide-right {
    transform: translateX(50px);
}

.animate-on-scroll.slide-right.visible {
    transform: translateX(0);
}

.animate-on-scroll.scale {
    transform: scale(0.8);
}

.animate-on-scroll.scale.visible {
    transform: scale(1);
}

/* ===== EFECTOS DE FOCUS MEJORADOS ===== */
.focus-glow {
    transition: all 0.3s ease;
    position: relative;
}

.focus-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.focus-glow:focus::before {
    opacity: 0.3;
}

/* ===== EFECTOS DE PULSACIÓN ===== */
.pulse-on-update {
    animation: pulseUpdate 0.6s ease-out;
}

@keyframes pulseUpdate {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(30, 154, 138, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(30, 154, 138, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(30, 154, 138, 0);
    }
}

/* ===== EFECTOS DE ÉXITO Y ERROR ===== */
.success-flash {
    animation: successFlash 0.8s ease-out;
}

@keyframes successFlash {
    0% { background-color: transparent; }
    50% { background-color: rgba(40, 167, 69, 0.2); transform: scale(1.02); }
    100% { background-color: transparent; transform: scale(1); }
}

.error-shake {
    animation: errorShake 0.6s ease-out;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ===== EFECTOS DE NAVEGACIÓN ===== */
.nav-item-enhanced {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

.nav-item-enhanced::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
    transform: scaleY(0);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: bottom;
    box-shadow: 0 0 8px rgba(123, 67, 151, 0.4);
}

.nav-item-enhanced::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(123, 67, 151, 0.1) 0%, rgba(30, 154, 138, 0.15) 100%);
    transition: left 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: -1;
}

.nav-item-enhanced:hover::before {
    transform: scaleY(1);
    transform-origin: top;
}

.nav-item-enhanced:hover::after {
    left: 0;
}

.nav-item-enhanced:hover {
    transform: translateX(12px) scale(1.03) rotateY(2deg);
    color: var(--primary-purple);
    box-shadow: 0 6px 20px rgba(123, 67, 151, 0.25);
}

/* ===== EFECTOS DE TARJETAS AVANZADOS ===== */
.card-3d-effect {
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
    position: relative;
    overflow: hidden;
}

.card-3d-effect::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(123, 67, 151, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: -1;
    transform: scale(0) rotate(0deg);
}

.card-3d-effect:hover::before {
    opacity: 1;
    transform: scale(1.2) rotate(360deg);
}

.card-3d-effect:hover {
    transform: translateY(-15px) scale(1.05) rotateX(8deg) rotateY(2deg);
    box-shadow: 0 30px 60px rgba(123, 67, 151, 0.2), 0 0 0 1px rgba(123, 67, 151, 0.1);
}

/* ===== EFECTOS DE FORMULARIOS ===== */
.form-field-enhanced {
    position: relative;
    transition: all 0.3s ease;
}

.form-field-enhanced::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.form-field-enhanced:focus::after {
    width: 100%;
}

.form-field-enhanced:focus {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 25px rgba(30, 154, 138, 0.15);
}

/* ===== EFECTOS DE PROGRESO ===== */
.progress-bar-animated {
    position: relative;
    overflow: hidden;
}

.progress-bar-animated::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ===== EFECTOS DE NOTIFICACIONES ===== */
.notification-slide-in {
    animation: notificationSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes notificationSlideIn {
    0% { opacity: 0; transform: translateX(100%) scale(0.8); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

.notification-bounce {
    animation: notificationBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes notificationBounce {
    0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
    50% { opacity: 0.8; transform: scale(1.1) rotate(5deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ===== EFECTOS DE MODAL MEJORADOS ===== */
.modal-enhanced {
    animation: modalEnhancedIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalEnhancedIn {
    0% { opacity: 0; transform: scale(0.7) translateY(-50px) rotateX(10deg); }
    50% { opacity: 0.8; transform: scale(1.05) translateY(-10px) rotateX(5deg); }
    100% { opacity: 1; transform: scale(1) translateY(0) rotateX(0deg); }
}

/* ===== EFECTOS DE TABLA MEJORADOS ===== */
.table-row-enhanced {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.table-row-enhanced::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #7B4397 0%, #1E9A8A 100%);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    transform-origin: center;
}

.table-row-enhanced:hover::before {
    transform: scaleY(1);
}

.table-row-enhanced:hover {
    background: linear-gradient(135deg, rgba(123, 67, 151, 0.05) 0%, rgba(30, 154, 138, 0.05) 100%);
    transform: translateX(8px) scale(1.01);
    box-shadow: 0 4px 15px rgba(123, 67, 151, 0.1);
}

/* ===== EFECTOS DE ICONOS ANIMADOS ===== */
.icon-spin-on-hover {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.icon-spin-on-hover:hover {
    transform: rotate(360deg) scale(1.2);
    color: var(--primary-teal);
}

.icon-bounce-on-hover {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.icon-bounce-on-hover:hover {
    transform: translateY(-5px) scale(1.2);
    color: var(--primary-teal);
}

.icon-pulse-continuous {
    animation: iconPulseContinuous 2s infinite;
}

@keyframes iconPulseContinuous {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* ===== EFECTOS DE TEXTO MEJORADOS ===== */
.text-gradient-animated {
    background: linear-gradient(45deg, #7B4397, #1E9A8A, #7B4397, #1E9A8A);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ===== EFECTOS DE ESTADÍSTICAS ===== */
.stat-counter {
    transition: all 0.3s ease;
}

.stat-counter.counting {
    animation: statCounting 2s ease-out;
}

@keyframes statCounting {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== EFECTOS DE BÚSQUEDA ===== */
.search-highlight {
    position: relative;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: 600;
    animation: searchHighlight 0.5s ease-out;
}

@keyframes searchHighlight {
    0% { background: transparent; transform: scale(1); }
    50% { background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%); transform: scale(1.05); }
    100% { background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%); transform: scale(1); }
}

/* ===== EFECTOS DE CALENDARIO ===== */
.calendar-day-hover {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.calendar-day-hover::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(30, 154, 138, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: -1;
}

.calendar-day-hover:hover::before {
    width: 200px;
    height: 200px;
}

.calendar-day-hover:hover {
    transform: scale(1.05) rotateZ(2deg);
    color: var(--primary-teal);
    font-weight: 600;
}

/* ===== EFECTOS DE ELEMENTOS INTERACTIVOS ===== */
.interactive-element {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
}

.interactive-element::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(123, 67, 151, 0.1) 0%, rgba(30, 154, 138, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
    border-radius: inherit;
}

.interactive-element:hover::after {
    opacity: 1;
}

.interactive-element:hover {
    transform: translateY(-3px) scale(1.02) rotateX(2deg);
    box-shadow: 0 8px 25px rgba(123, 67, 151, 0.2);
}

.interactive-element:active {
    transform: translateY(-1px) scale(1.01);
    transition: all 0.1s ease;
}

/* ===== EFECTOS DE VALIDACIÓN ===== */
.validation-success {
    animation: validationSuccess 0.6s ease-out;
}

@keyframes validationSuccess {
    0% { border-color: #dee2e6; box-shadow: none; }
    50% { border-color: #28a745; box-shadow: 0 0 0 5px rgba(40, 167, 69, 0.3); transform: scale(1.02); }
    100% { border-color: #28a745; box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2); transform: scale(1); }
}

.validation-error {
    animation: validationError 0.6s ease-out;
}

@keyframes validationError {
    0% { border-color: #dee2e6; transform: translateX(0); }
    25% { border-color: #dc3545; transform: translateX(-5px); }
    75% { border-color: #dc3545; transform: translateX(5px); }
    100% { border-color: #dc3545; transform: translateX(0); box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2); }
}

/* ===== EFECTOS DE CONEXIÓN ===== */
.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 9999;
    transition: all 0.3s ease;
    animation: connectionSlideIn 0.5s ease-out;
}

@keyframes connectionSlideIn {
    0% { opacity: 0; transform: translateX(100px); }
    100% { opacity: 1; transform: translateX(0); }
}

.connection-status.online {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.connection-status.offline {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    animation: connectionPulse 1s infinite;
}

@keyframes connectionPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== EFECTOS DE ELEMENTOS FLOTANTES ===== */
.floating-element {
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.floating-element-slow {
    animation: floatingSlow 6s ease-in-out infinite;
}

@keyframes floatingSlow {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-5px) rotate(1deg); }
    66% { transform: translateY(-8px) rotate(-1deg); }
}

/* ===== EFECTOS DE PARTÍCULAS ===== */
.particle-effect {
    position: relative;
    overflow: hidden;
}

.particle-effect::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: particleFloat 20s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.particle-effect:hover::before {
    opacity: 1;
}

@keyframes particleFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-50px, -50px) rotate(360deg); }
}

/* ===== EFECTOS ESPECÍFICOS PARA MENTALFAM ===== */
.mentalfam-glow {
    position: relative;
    overflow: hidden;
}

.mentalfam-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #7B4397, #1E9A8A, #7B4397, #1E9A8A);
    background-size: 300% 300%;
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    animation: gradientShift 3s ease infinite;
    transition: opacity 0.3s ease;
}

.mentalfam-glow:hover::before {
    opacity: 0.7;
}

.mentalfam-brand-pulse {
    animation: brandPulse 4s ease-in-out infinite;
}

@keyframes brandPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(123, 67, 151, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(123, 67, 151, 0); }
}

/* ===== EFECTOS DE ÉXITO ESPECÍFICOS ===== */
.success-checkmark {
    animation: successCheckmark 0.8s ease-out;
}

@keyframes successCheckmark {
    0% { opacity: 0; transform: scale(0.3) rotate(-45deg); }
    50% { opacity: 1; transform: scale(1.2) rotate(-22.5deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.success-celebration {
    animation: successCelebration 1.2s ease-out;
}

@keyframes successCelebration {
    0% { transform: scale(1); }
    25% { transform: scale(1.1) rotate(5deg); }
    50% { transform: scale(1.05) rotate(-3deg); }
    75% { transform: scale(1.02) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* ===== EFECTOS RESPONSIVE ===== */
@media (max-width: 768px) {
    .hover-lift-advanced:hover { transform: translateY(-4px) scale(1.01); }
    .card-3d-effect:hover { transform: translateY(-8px) scale(1.02); }
    .nav-item-enhanced:hover { transform: translateX(8px) scale(1.01); }
    .interactive-element:hover { transform: translateY(-2px) scale(1.01); }
}

/* ===== EFECTOS PARA DISPOSITIVOS TÁCTILES ===== */
@media (hover: none) and (pointer: coarse) {
    .hover-lift-advanced,
    .card-3d-effect,
    .nav-item-enhanced,
    .interactive-element {
        transition: all 0.2s ease;
    }
    
    .hover-lift-advanced:active { transform: scale(0.98); }
    .card-3d-effect:active { transform: scale(0.98); }
    .nav-item-enhanced:active { transform: translateX(4px) scale(0.98); }
    .interactive-element:active { transform: scale(0.98); }
}

/* ===== EFECTOS DE ACCESIBILIDAD ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .floating-element,
    .floating-element-slow,
    .icon-pulse-continuous,
    .particle-effect::before {
        animation: none !important;
    }
}

/* ===== UTILIDADES DE ANIMACIÓN ===== */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

.animate-duration-fast { animation-duration: 0.3s; }
.animate-duration-normal { animation-duration: 0.6s; }
.animate-duration-slow { animation-duration: 1s; }

.transition-fast { transition-duration: 0.15s; }
.transition-normal { transition-duration: 0.3s; }
.transition-slow { transition-duration: 0.6s; }

/* ===== EFECTOS DE PERFORMANCE ===== */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform { will-change: transform; }
.will-change-opacity { will-change: opacity; }
.will-change-auto { will-change: auto; }
