/**
 * EasyFlow Animations
 * Smooth, modern animations and transitions
 */

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Slide In From Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In From Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Spin */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Apply Animations to Elements */

/* Page Load Animation */
.page-header {
    animation: fadeInUp 0.5s ease-out;
}

/* Card Animations */
.card {
    animation: fadeIn 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
}

/* Button Animations */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

/* Input Focus Animation */
.form-input,
.form-select {
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Modal Animations */
.modal {
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Alert Animations */
.alert {
    animation: slideInRight 0.3s ease-out;
}

/* Auto-fade animation for messages */
.fade-out {
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.fade-out.fading {
    opacity: 0;
}

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

/* Stagger Animation for Lists */
.partners-list > tr,
.invoice-card,
.transaction-card {
    animation: fadeIn 0.4s ease-out backwards;
}

.partners-list > tr:nth-child(1),
.invoice-card:nth-child(1),
.transaction-card:nth-child(1) { animation-delay: 0.05s; }

.partners-list > tr:nth-child(2),
.invoice-card:nth-child(2),
.transaction-card:nth-child(2) { animation-delay: 0.1s; }

.partners-list > tr:nth-child(3),
.invoice-card:nth-child(3),
.transaction-card:nth-child(3) { animation-delay: 0.15s; }

.partners-list > tr:nth-child(4),
.invoice-card:nth-child(4),
.transaction-card:nth-child(4) { animation-delay: 0.2s; }

.partners-list > tr:nth-child(5),
.invoice-card:nth-child(5),
.transaction-card:nth-child(5) { animation-delay: 0.25s; }

/* Number Counter Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.summary-card .stat-value {
    animation: countUp 0.6s ease-out;
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Badge Pulse */
.badge-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Progress Bar Animation */
@keyframes progress {
    from {
        width: 0;
    }
}

.progress-bar {
    animation: progress 1s ease-out;
}

/* Chart Animations */
@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#cash-flow-chart {
    animation: chartFadeIn 0.6s ease-out;
}

/* Success Checkmark */
@keyframes checkmark {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.checkmark {
    animation: checkmark 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

