/**
 * Animations & Transitions
 */

/* Page Load Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Bounce Animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Shimmer Skeleton Loading */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.3) 25%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0.3) 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Spin Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Confetti Animation */
@keyframes confetti-fall {
    to {
        transform: translateY(600px) rotateZ(360deg);
        opacity: 0;
    }
}

.confetti {
    animation: confetti-fall 2s ease-in forwards;
}

/* Scale Up Animation */
@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Checkmark Animation */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 50;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Toast Notification Animation */
@keyframes slideInTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutTop {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.toast {
    animation: slideInTop 0.3s ease-out;
}

.toast.hide {
    animation: slideOutTop 0.3s ease-in forwards;
}

/* Button Ripple Effect */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple-button {
    position: relative;
    overflow: hidden;
}

.ripple {
    display: none;
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

/* Apply animations to page elements */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

.scale-up {
    animation: scaleUp 0.3s ease-out forwards;
}

.bounce {
    animation: bounce 2s ease-in-out infinite;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Stagger animation for list items */
.list-stagger > * {
    animation: fadeIn 0.5s ease-out forwards;
}

.list-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.list-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.list-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.list-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.list-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.list-stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* Form focus animation */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    animation: scaleUp 0.2s ease-out;
}

/* Hover animations */
.hover-scale:hover {
    transform: scale(1.05);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.4);
}

/* Modal animations */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

/* Transition for background fade */
.fade-bg {
    animation: fadeIn 0.3s ease-out;
}

/* Loading spinner animation */
.loading-spinner {
    display: inline-block;
    position: relative;
    width: 20px;
    height: 20px;
}

.loading-spinner::after {
    content: " ";
    display: block;
    width: 16px;
    height: 16px;
    margin: 2px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    border-color: var(--color-primary) transparent var(--color-primary) transparent;
    animation: spin 1.2s linear infinite;
}

/* Slide In Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fade Out Animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Smooth transitions for all interactive elements */
button,
a,
input,
select,
textarea {
    transition: all var(--transition-fast);
}
