/**
 * UI Animations & Micro-interactions - 2026 Design Standards
 * Advanced animation utilities for X-Ray Bone Fracture Detection System
 */

/* ============================================================
   1. PAGE TRANSITIONS
   ============================================================ */

/* Page Enter Animation */
.page-transition-enter {
    animation: pageEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page Exit Animation */
.page-transition-exit {
    animation: pageExit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Fade In Up - Default for content */
.animate-fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   2. STAGGERED ANIMATIONS
   ============================================================ */

/* Stagger children animations */
.stagger-children>* {
    opacity: 0;
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-children>*:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-children>*:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-children>*:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-children>*:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-children>*:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger-children>*:nth-child(6) {
    animation-delay: 0.6s;
}

.stagger-children>*:nth-child(7) {
    animation-delay: 0.7s;
}

.stagger-children>*:nth-child(8) {
    animation-delay: 0.8s;
}

/* ============================================================
   3. BUTTON MICRO-INTERACTIONS
   ============================================================ */

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.btn-ripple:active::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0) translate(-50%, -50%);
        opacity: 1;
    }

    100% {
        transform: scale(40) translate(-50%, -50%);
        opacity: 0;
    }
}

/* Button Hover Glow */
.btn-glow {
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-glow:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.btn-glow:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Button Press Effect */
.btn-press {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-press:active {
    transform: scale(0.96);
}

/* ============================================================
   4. CARD ANIMATIONS
   ============================================================ */

/* Card Hover Lift */
.card-hover-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Card Reveal - For loading states */
.card-reveal {
    animation: cardReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Card Glow Border */
.card-glow {
    position: relative;
}

.card-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7, #6366f1);
    background-size: 300% 300%;
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: gradientRotate 4s linear infinite;
}

.card-glow:hover::before {
    opacity: 1;
}

@keyframes gradientRotate {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ============================================================
   5. SUCCESS / ERROR / INFO FEEDBACK ANIMATIONS
   ============================================================ */

/* Success Pulse */
.success-pulse {
    animation: successPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes successPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }
}

/* Error Shake */
.error-shake {
    animation: errorShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes errorShake {

    10%,
    90% {
        transform: translateX(-1px);
    }

    20%,
    80% {
        transform: translateX(2px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-4px);
    }

    40%,
    60% {
        transform: translateX(4px);
    }
}

/* Warning Bounce */
.warning-bounce {
    animation: warningBounce 0.8s ease-in-out;
}

@keyframes warningBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }

    50% {
        transform: translateY(0);
    }

    70% {
        transform: translateY(-5px);
    }
}

/* Success Check Animation */
.success-check {
    animation: successCheck 0.5s ease-in-out forwards;
}

@keyframes successCheck {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.3) rotate(0deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* ============================================================
   6. LOADING ANIMATIONS
   ============================================================ */

/* Modern Spinner */
.spinner-modern {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spinModern 0.8s linear infinite;
}

@keyframes spinModern {
    to {
        transform: rotate(360deg);
    }
}

/* Pulse Loader */
.loader-pulse {
    display: flex;
    gap: 8px;
}

.loader-pulse span {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    animation: loaderPulse 1.4s ease-in-out infinite both;
}

.loader-pulse span:nth-child(1) {
    animation-delay: -0.32s;
}

.loader-pulse span:nth-child(2) {
    animation-delay: -0.16s;
}

.loader-pulse span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes loaderPulse {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Skeleton Shimmer Enhanced */
.skeleton-shimmer {
    background: linear-gradient(90deg,
            rgba(229, 231, 235, 0) 0%,
            rgba(229, 231, 235, 0.8) 50%,
            rgba(229, 231, 235, 0) 100%);
    background-size: 200% 100%;
    animation: shimmerEnhanced 1.5s ease-in-out infinite;
}

@keyframes shimmerEnhanced {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============================================================
   7. ICON ANIMATIONS
   ============================================================ */

/* Icon Bounce */
.icon-bounce {
    animation: iconBounce 2s ease infinite;
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Icon Spin */
.icon-spin {
    animation: iconSpin 2s linear infinite;
}

@keyframes iconSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Icon Pulse */
.icon-pulse {
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ============================================================
   8. NUMBER COUNTER ANIMATION
   ============================================================ */

.counter-animate {
    display: inline-block;
    transition: all 0.3s ease;
}

.counter-animate.counting {
    animation: counterPop 0.3s ease;
}

@keyframes counterPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================================================
   9. TOOLTIP ANIMATIONS
   ============================================================ */

.tooltip-fade {
    animation: tooltipFade 0.2s ease-out forwards;
}

@keyframes tooltipFade {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   10. UPLOAD AREA ANIMATIONS
   ============================================================ */

/* Drag Active State */
.upload-drag-active {
    animation: uploadDragActive 0.5s ease-in-out infinite alternate;
}

@keyframes uploadDragActive {
    from {
        border-color: #6366f1;
        background-color: rgba(99, 102, 241, 0.05);
    }

    to {
        border-color: #8b5cf6;
        background-color: rgba(139, 92, 246, 0.1);
    }
}

/* Upload Success */
.upload-success {
    animation: uploadSuccess 0.5s ease-out forwards;
}

@keyframes uploadSuccess {
    0% {
        border-color: #22c55e;
        background-color: rgba(34, 197, 94, 0.05);
    }

    50% {
        border-color: #22c55e;
        background-color: rgba(34, 197, 94, 0.15);
    }

    100% {
        border-color: #22c55e;
        background-color: rgba(34, 197, 94, 0.08);
    }
}

/* ============================================================
   11. MODAL ANIMATIONS
   ============================================================ */

.modal-slide-up {
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-backdrop-fade {
    animation: backdropFade 0.3s ease forwards;
}

@keyframes backdropFade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================================
   12. NOTIFICATION ANIMATIONS
   ============================================================ */

.notification-slide-in {
    animation: notificationSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification-slide-out {
    animation: notificationSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ============================================================
   13. HEATMAP ANIMATIONS
   ============================================================ */

/* Scan Effect Container */
.scan-container {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
}

/* The vertical scanning line */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(99, 102, 241, 0.4), transparent);
    transform: translateY(-100%);
    animation: scanMove 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
    z-index: 10;
}

@keyframes scanMove {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(100%);
    }
}

/* Heatmap Pulse Overlay */
.heatmap-overlay {
    animation: heatmapPulse 4s ease-in-out infinite;
}

@keyframes heatmapPulse {

    0%,
    100% {
        opacity: 0.75;
    }

    50% {
        opacity: 1;
    }
}

/* Reveal Animation for Heatmap */
.heatmap-reveal {
    opacity: 1;
    animation: revealFadeIn 1s ease-out 0.3s both;
}

@keyframes revealFadeIn {
    from {
        opacity: 0.3;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   14. FLOATING PARTICLES BACKGROUND
   ============================================================ */

.particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    border-radius: 50%;
    animation: particleFloat 15s ease-in-out infinite;
}

.particle:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    left: 20%;
    animation-delay: 2s;
    width: 15px;
    height: 15px;
}

.particle:nth-child(3) {
    left: 30%;
    animation-delay: 4s;
}

.particle:nth-child(4) {
    left: 40%;
    animation-delay: 6s;
    width: 8px;
    height: 8px;
}

.particle:nth-child(5) {
    left: 50%;
    animation-delay: 8s;
}

.particle:nth-child(6) {
    left: 60%;
    animation-delay: 10s;
    width: 12px;
    height: 12px;
}

.particle:nth-child(7) {
    left: 70%;
    animation-delay: 12s;
}

.particle:nth-child(8) {
    left: 80%;
    animation-delay: 14s;
    width: 6px;
    height: 6px;
}

.particle:nth-child(9) {
    left: 90%;
    animation-delay: 1s;
}

@keyframes particleFloat {

    0%,
    100% {
        top: 100%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: -10%;
        opacity: 0;
    }
}

/* ============================================================
   14. REDUCED MOTION SUPPORT
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .particles-bg {
        display: none;
    }
}