/* ========================================
   ANIMACIONES AVANZADAS - SEMANA 3
   Micro-interacciones y feedback visual
======================================== */

/* ========================================
   KEYFRAMES - ANIMACIONES BASE
======================================== */

/* Fade In desde abajo */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In desde arriba */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In desde la izquierda */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In desde la derecha */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Zoom In */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Bounce In */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* Shake (para errores) */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-10px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(10px);
    }
}

/* Pulse (para llamar atención) */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(79, 70, 229, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

/* Rotate (para spinners) */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Shimmer (para skeleton loading) */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

/* Float (para elementos flotantes) */
@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Glow */
@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(79, 70, 229, 0.5);
    }

    50% {
        box-shadow: 0 0 20px rgba(79, 70, 229, 0.8);
    }
}

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

/* Animaciones de entrada */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

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

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

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

.animate-zoom-in {
    animation: zoomIn 0.5s ease-out;
}

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

/* Animaciones de estado */
.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

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

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

/* Delays para animaciones escalonadas */
.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

.delay-300 {
    animation-delay: 0.3s;
}

.delay-400 {
    animation-delay: 0.4s;
}

.delay-500 {
    animation-delay: 0.5s;
}

.delay-600 {
    animation-delay: 0.6s;
}

.delay-700 {
    animation-delay: 0.7s;
}

.delay-800 {
    animation-delay: 0.8s;
}

/* ========================================
   LOADING STATES PERSONALIZADOS
======================================== */

/* Spinner con gradiente */
.spinner-gradient {
    width: 50px;
    height: 50px;
    border: 4px solid transparent;
    border-top: 4px solid var(--accent-blue);
    border-right: 4px solid var(--accent-purple);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* Spinner con puntos */
.spinner-dots {
    display: inline-flex;
    gap: 8px;
}

.spinner-dots span {
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.spinner-dots span:nth-child(1) {
    animation-delay: 0s;
}

.spinner-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.spinner-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Skeleton loading */
.skeleton-loader {
    background: linear-gradient(90deg,
            var(--secondary) 0%,
            var(--tertiary) 50%,
            var(--secondary) 100%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
}

/* Progress bar animado */
.progress-animated .progress-bar {
    position: relative;
    overflow: hidden;
}

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

/* ========================================
   MICRO-INTERACCIONES EN BOTONES
======================================== */

/* Ripple effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::before {
    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::before {
    width: 300px;
    height: 300px;
}

/* Bounce al hacer clic */
.btn-bounce:active {
    animation: bounceIn 0.3s ease-out;
}

/* Shake al error */
.btn-error {
    animation: shake 0.5s ease-in-out;
}

/* Glow al hover */
.btn-glow:hover {
    animation: glow 1s ease-in-out infinite;
}

/* ========================================
   FEEDBACK VISUAL EN FORMULARIOS
======================================== */

/* Input con éxito */
.form-control.is-valid {
    border-color: var(--accent-green);
    background-image: none;
    padding-right: calc(1.5em + 0.75rem);
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* Input con error */
.form-control.is-invalid {
    border-color: var(--accent-red);
    animation: shake 0.5s ease-in-out;
}

.form-control.is-invalid:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Label animado */
.form-floating label {
    transition: all var(--transition-smooth);
}

.form-floating .form-control:focus~label,
.form-floating .form-control:not(:placeholder-shown)~label {
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
    color: var(--accent-blue);
}

/* ========================================
   TRANSICIONES DE PÁGINA
======================================== */

/* Fade page */
.page-transition-fade {
    animation: fadeInUp 0.5s ease-out;
}

/* Slide page */
.page-transition-slide {
    animation: fadeInRight 0.5s ease-out;
}

/* ========================================
   HOVER EFFECTS AVANZADOS
======================================== */

/* Lift con sombra */
.hover-lift-shadow {
    transition: all var(--transition-smooth);
}

.hover-lift-shadow:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

/* Tilt 3D */
.hover-tilt {
    transition: transform var(--transition-smooth);
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
}

/* Glow border */
.hover-glow-border {
    position: relative;
    transition: all var(--transition-smooth);
}

.hover-glow-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity var(--transition-smooth);
}

.hover-glow-border:hover::before {
    opacity: 1;
}

/* Scale smooth */
.hover-scale {
    transition: transform var(--transition-smooth);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ========================================
   TOAST NOTIFICATIONS
======================================== */

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: fadeInRight 0.5s ease-out;
    z-index: 9999;
}

.toast-notification.toast-success {
    border-left: 4px solid var(--accent-green);
}

.toast-notification.toast-error {
    border-left: 4px solid var(--accent-red);
}

.toast-notification.toast-info {
    border-left: 4px solid var(--accent-blue);
}

.toast-notification.toast-warning {
    border-left: 4px solid var(--accent-orange);
}

.toast-notification.toast-hide {
    animation: fadeInRight 0.5s ease-out reverse;
}

/* ========================================
   MODAL TRANSITIONS
======================================== */

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: scale(0.8) translateY(-50px);
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ========================================
   ACCORDION ANIMATIONS
======================================== */

.accordion-button {
    transition: all var(--transition-smooth);
}

.accordion-button:not(.collapsed) {
    background: var(--gradient-primary);
    color: white;
}

.accordion-button::after {
    transition: transform var(--transition-smooth);
}

.accordion-button:not(.collapsed)::after {
    transform: rotate(180deg);
}

/* ========================================
   DROPDOWN ANIMATIONS
======================================== */

.dropdown-menu {
    animation: fadeInDown 0.3s ease-out;
}

.dropdown-item {
    transition: all var(--transition-base);
}

.dropdown-item:hover {
    background: var(--tertiary);
    transform: translateX(5px);
}

/* ========================================
   BADGE ANIMATIONS
======================================== */

.badge-pulse {
    animation: pulse 2s infinite;
}

.badge-bounce {
    animation: bounceIn 0.8s ease-out;
}

/* ========================================
   CARD FLIP EFFECT
======================================== */

.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* ========================================
   SCROLL ANIMATIONS
======================================== */

.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}

.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   UTILIDADES DE ANIMACIÓN
======================================== */

/* Pausar animaciones */
.animation-paused {
    animation-play-state: paused !important;
}

/* Velocidades de animación */
.animation-fast {
    animation-duration: 0.3s !important;
}

.animation-slow {
    animation-duration: 1s !important;
}

/* Repeticiones */
.animation-infinite {
    animation-iteration-count: infinite !important;
}

.animation-once {
    animation-iteration-count: 1 !important;
}

/* Fill modes */
.animation-forwards {
    animation-fill-mode: forwards !important;
}

.animation-backwards {
    animation-fill-mode: backwards !important;
}

.animation-both {
    animation-fill-mode: both !important;
}