/*
* Archivo: micro-interactions.css
* Autor: Joel Chala
* Versión: 1.0
* Descripción: Micro-interacciones modernas y animaciones avanzadas
* Ruta: Directorio_Raiz/assets/css/micro-interactions.css
*/

/* ==========================================================================
   VARIABLES GLOBALES PARA ANIMACIONES
   ========================================================================== */

:root {
    /* Timing functions */
    --ease-out-cubic: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-in-cubic: cubic-bezier(0.32, 0, 0.67, 0);
    --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
    --spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);

    /* Duraciones */
    --animation-micro: 0.15s;
    --animation-fast: 0.25s;
    --animation-normal: 0.4s;
    --animation-slow: 0.6s;
    --animation-slower: 1s;

    /* Efectos */
    --blur-light: blur(4px);
    --blur-medium: blur(8px);
    --blur-heavy: blur(12px);

    /* Sombras animadas */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   ANIMACIONES KEYFRAMES
   ========================================================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes morphing {
    0%, 100% {
        border-radius: 20px;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 50px;
        transform: rotate(90deg);
    }
    50% {
        border-radius: 20px;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 50px;
        transform: rotate(270deg);
    }
}

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

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

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1);
    }
    75% {
        transform: scale(1.05);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes wiggle {
    0%, 7%, 14%, 21%, 28%, 35%, 42%, 49%, 56%, 63%, 70%, 77%, 84%, 91%, 98%, 100% {
        transform: translateX(0);
    }
    3.5%, 10.5%, 17.5%, 24.5%, 31.5%, 38.5%, 45.5%, 52.5%, 59.5%, 66.5%, 73.5%, 80.5%, 87.5%, 94.5% {
        transform: translateX(-3px);
    }
}

/* ==========================================================================
   CLASES UTILITARIAS DE ANIMACIÓN
   ========================================================================== */

.fade-in-up {
    animation: fadeInUp var(--animation-normal) var(--ease-out-cubic) both;
}

.fade-in-down {
    animation: fadeInDown var(--animation-normal) var(--ease-out-cubic) both;
}

.fade-in-left {
    animation: fadeInLeft var(--animation-normal) var(--ease-out-cubic) both;
}

.fade-in-right {
    animation: fadeInRight var(--animation-normal) var(--ease-out-cubic) both;
}

.scale-in {
    animation: scaleIn var(--animation-fast) var(--spring) both;
}

.bounce-in {
    animation: bounceIn var(--animation-slow) var(--bounce) both;
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

.pulse-animation {
    animation: pulse 2s ease-in-out infinite;
}

.heartbeat-animation {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.wiggle-animation {
    animation: wiggle 1s linear infinite;
}

/* Delays para animaciones escalonadas */
.animation-delay-100 { animation-delay: 0.1s; }
.animation-delay-200 { animation-delay: 0.2s; }
.animation-delay-300 { animation-delay: 0.3s; }
.animation-delay-400 { animation-delay: 0.4s; }
.animation-delay-500 { animation-delay: 0.5s; }

/* ==========================================================================
   MICRO-INTERACCIONES PARA ELEMENTOS ESPECÍFICOS
   ========================================================================== */

/* Botones mejorados */
.btn-enhanced {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    transition: all var(--animation-fast) var(--ease-out-cubic);
    will-change: transform;
}

.btn-enhanced::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 var(--animation-slow) var(--ease-out-cubic);
}

.btn-enhanced:hover::before {
    left: 100%;
}

.btn-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-enhanced:active {
    transform: translateY(0);
    transition-duration: var(--animation-micro);
}

/* Cards con efectos avanzados */
.card-interactive {
    position: relative;
    transition: all var(--animation-normal) var(--ease-out-cubic);
    transform-style: preserve-3d;
    will-change: transform;
}

.card-interactive::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity var(--animation-fast) ease;
    pointer-events: none;
    border-radius: inherit;
}

.card-interactive:hover {
    transform: translateY(-8px) rotateX(5deg);
    box-shadow: var(--shadow-xl);
}

.card-interactive:hover::before {
    opacity: 1;
}

/* Inputs con animaciones fluidas */
.input-enhanced {
    position: relative;
    transition: all var(--animation-fast) var(--ease-out-cubic);
}

.input-enhanced:focus-within {
    transform: scale(1.02);
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.1),
        var(--shadow-md);
}

.input-enhanced label {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    transition: all var(--animation-fast) var(--ease-out-cubic);
    pointer-events: none;
    color: #9ca3af;
    font-size: 0.875rem;
}

.input-enhanced input:focus + label,
.input-enhanced input:not(:placeholder-shown) + label {
    top: 0.25rem;
    left: 0.75rem;
    font-size: 0.75rem;
    color: #3b82f6;
    background: white;
    padding: 0 0.25rem;
}

/* Loading skeletons */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
}

/* Progress indicators */
.progress-bar {
    position: relative;
    background: #e5e7eb;
    border-radius: 50px;
    overflow: hidden;
    height: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: inherit;
    transition: width var(--animation-slow) var(--ease-out-cubic);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite linear;
}

/* Navigation enhancements */
.nav-item {
    position: relative;
    transition: all var(--animation-fast) var(--ease-out-cubic);
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: #3b82f6;
    transition: all var(--animation-fast) var(--ease-out-cubic);
    transform: translateX(-50%);
}

.nav-item:hover::after {
    width: 100%;
}

.nav-item:hover {
    transform: translateY(-2px);
}

/* Modal animations */
.modal-overlay {
    background: rgba(0, 0, 0, 0);
    transition: background-color var(--animation-normal) ease;
    backdrop-filter: blur(0px);
}

.modal-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: var(--blur-medium);
}

.modal-content {
    transform: scale(0.8) translateY(50px);
    opacity: 0;
    transition: all var(--animation-normal) var(--spring);
}

.modal-content.active {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Tooltip improvements */
.tooltip {
    position: relative;
    cursor: pointer;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all var(--animation-fast) var(--ease-out-cubic);
    z-index: 1000;
}

.tooltip::before {
    content: attr(data-tooltip);
    background: rgba(17, 24, 39, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    white-space: nowrap;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    backdrop-filter: var(--blur-light);
}

.tooltip::after {
    content: '';
    border: 5px solid transparent;
    border-top-color: rgba(17, 24, 39, 0.9);
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   EFECTOS ESPECIALES
   ========================================================================== */

/* Parallax scroll effect */
.parallax {
    transform: translateZ(0);
    will-change: transform;
}

/* Magnetic effect para elementos importantes */
.magnetic {
    position: relative;
    transition: transform var(--animation-fast) var(--ease-out-cubic);
    cursor: pointer;
}

.magnetic::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: inherit;
    background: radial-gradient(
        circle at center,
        rgba(59, 130, 246, 0.1) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity var(--animation-fast) ease;
    pointer-events: none;
}

.magnetic:hover::before {
    opacity: 1;
}

/* Glitch effect para elementos especiales */
.glitch {
    position: relative;
    color: white;
    background: #000;
    padding: 1rem;
    display: inline-block;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    padding: 1rem;
}

.glitch::before {
    animation: glitch-1 0.3s infinite linear alternate-reverse;
    color: #ff0040;
    z-index: -1;
}

.glitch::after {
    animation: glitch-2 0.3s infinite linear alternate-reverse;
    color: #00ffff;
    z-index: -2;
}

@keyframes glitch-1 {
    0% { clip-path: inset(20% 0 60% 0); }
    20% { clip-path: inset(80% 0 5% 0); }
    40% { clip-path: inset(50% 0 30% 0); }
    60% { clip-path: inset(10% 0 70% 0); }
    80% { clip-path: inset(90% 0 2% 0); }
    100% { clip-path: inset(30% 0 40% 0); }
}

@keyframes glitch-2 {
    0% { clip-path: inset(40% 0 30% 0); }
    20% { clip-path: inset(5% 0 80% 0); }
    40% { clip-path: inset(70% 0 10% 0); }
    60% { clip-path: inset(30% 0 50% 0); }
    80% { clip-path: inset(2% 0 90% 0); }
    100% { clip-path: inset(60% 0 20% 0); }
}

/* ==========================================================================
   RESPONSIVE ANIMATIONS
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .parallax {
        transform: none !important;
    }
}

@media (max-width: 768px) {
    .card-interactive:hover {
        transform: translateY(-4px);
    }

    .btn-enhanced:hover {
        transform: translateY(-1px);
    }
}

/* ==========================================================================
   DARK MODE ADAPTATIONS
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(
            90deg,
            #374151 25%,
            #4b5563 50%,
            #374151 75%
        );
    }

    .tooltip::before {
        background: rgba(255, 255, 255, 0.9);
        color: #1f2937;
    }

    .tooltip::after {
        border-top-color: rgba(255, 255, 255, 0.9);
    }
}