/* ========================================
   Modern Animations Library
   Smooth, Delightful Animations
   ======================================== */

/* ========== FADE ANIMATIONS ========== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== SLIDE ANIMATIONS ========== */

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========== SCALE ANIMATIONS ========== */

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scaleOut {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0.95);
        opacity: 0;
    }
}

/* ========== BOUNCE ANIMATIONS ========== */

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== ROTATE ANIMATIONS ========== */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spinSlow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ========== PULSE ANIMATIONS ========== */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulseScale {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* ========== SHIMMER (Loading Effect) ========== */

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(to right,
            var(--color-bg-tertiary) 0%,
            var(--color-border) 20%,
            var(--color-bg-tertiary) 40%,
            var(--color-bg-tertiary) 100%);
    background-size: 1000px 100%;
}

/* ========== SKELETON LOADER ========== */

.skeleton {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-base);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 12px;
    margin-bottom: var(--spacing-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--spacing-4);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

/* ========== RIPPLE EFFECT ========== */

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    pointer-events: none;
}

.ripple:active::before {
    animation: ripple 0.6s ease-out;
}

/* ========== SHAKE ANIMATION ========== */

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s;
}

/* ========== UTILITY CLASSES ========== */

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

.animate-fade-in-down {
    animation: fadeInDown 0.4s ease-out;
}

.animate-slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

.animate-bounce-in {
    animation: bounceIn 0.5s ease-out;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Staggered Animations */
.animate-stagger>* {
    animation: fadeInUp 0.5s ease-out backwards;
}

.animate-stagger>*:nth-child(1) {
    animation-delay: 0.05s;
}

.animate-stagger>*:nth-child(2) {
    animation-delay: 0.1s;
}

.animate-stagger>*:nth-child(3) {
    animation-delay: 0.15s;
}

.animate-stagger>*:nth-child(4) {
    animation-delay: 0.2s;
}

.animate-stagger>*:nth-child(5) {
    animation-delay: 0.25s;
}

.animate-stagger>*:nth-child(6) {
    animation-delay: 0.3s;
}

/* ========== HOVER EFFECTS ========== */

.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

/* ========== PAGE TRANSITIONS ========== */

.page-enter {
    animation: fadeInUp 0.4s ease-out;
}

.page-exit {
    animation: fadeOut 0.3s ease-out;
}

/* ========== LOADING SPINNER ========== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* Dot Spinner */
.dots-spinner {
    display: inline-flex;
    gap: var(--spacing-2);
}

.dots-spinner span {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.dots-spinner span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-spinner span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ========== GRADIENT ANIMATION ========== */

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.gradient-animated {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* ========== TYPING ANIMATION ========== */

@keyframes typing {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

.typing-effect {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40) 1s 1 normal both, blink 0.75s step-end infinite;
}

/* ========== FLOAT ANIMATION ========== */

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.float-animation {
    animation: float 3s ease-in-out infinite;
}

/* ========== PROGRESS BAR FILL ========== */

@keyframes progressFill {
    from {
        width: 0%;
    }
}

.progress-fill-animated {
    animation: progressFill 1s ease-out forwards;
}