/* Global Animations */

/* Panel Slide Animations */
.slide-in-right {
    animation: slideInRight var(--transition-panel) forwards;
}

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

.slide-in-left {
    animation: slideInLeft var(--transition-panel) forwards;
}

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

.slide-in-up {
    animation: slideInUp var(--transition-panel) forwards;
}

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

.slide-in-down {
    animation: slideInDown 0.3s ease-out forwards;
}

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

/* Fade Animations */
.fade-in {
    animation: fadeIn var(--transition-slow) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-out {
    animation: fadeOut var(--transition-slow) forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Scale Animations */
.scale-in {
    animation: scaleIn var(--transition-base) forwards;
}

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

.pop-in {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Attention Animations */
.attention-pulse {
    animation: attentionPulse 2s ease-in-out infinite;
}

@keyframes attentionPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--color-ai-glow);
    }
    50% {
        box-shadow: 0 0 20px 5px var(--color-ai-glow);
    }
}

.highlight-flash {
    animation: highlightFlash 0.5s ease-out;
}

@keyframes highlightFlash {
    0% {
        background-color: rgba(127, 63, 191, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* Bounce Animation */
.bounce {
    animation: bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Glow Animation */
.glow {
    animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 5px var(--color-ai-glow);
    }
    to {
        box-shadow: 0 0 20px var(--color-ai-glow);
    }
}

/* Typing Cursor */
.typing-cursor::after {
    content: '|';
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Stagger Children Animation */
.stagger-children > * {
    opacity: 0;
    animation: fadeIn var(--transition-slow) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

/* Progress Bar Loading */
.loading-bar {
    position: relative;
    overflow: hidden;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, var(--color-primary) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* Number Count Up */
@property --num {
    syntax: '<integer>';
    initial-value: 0;
    inherits: false;
}

.count-up {
    animation: count-up 1s ease-out forwards;
    counter-reset: num var(--num);
}

.count-up::after {
    content: counter(num);
}

@keyframes count-up {
    to {
        --num: 100;
    }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border) 25%,
        var(--color-surface-alt) 50%,
        var(--color-border) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Form Field Focus Glow */
.field-focus {
    animation: fieldFocus 0.3s ease-out forwards;
}

@keyframes fieldFocus {
    from {
        box-shadow: 0 0 0 0 var(--color-primary);
    }
    to {
        box-shadow: 0 0 0 3px rgba(1, 118, 211, 0.2);
    }
}

/* Success Checkmark Animation */
.success-check {
    animation: successCheck 0.5s ease-out forwards;
}

@keyframes successCheck {
    0% {
        stroke-dasharray: 0 100;
    }
    100% {
        stroke-dasharray: 100 100;
    }
}

/* Transition Classes for JS */
.transition-opacity {
    transition: opacity var(--transition-base);
}

.transition-transform {
    transition: transform var(--transition-base);
}

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

/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
