/* Modern Interactions and Animations */

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Button Interactions */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

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

.btn:active::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);
}

/* Card Hover Effects */
.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Table Row Hover */
.data-table tbody tr {
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: var(--color-background);
    transform: scale(1.01);
}

/* Modal Animations */
.modal {
    animation: modalSlideIn 0.3s ease;
}

.modal.closing {
    animation: modalSlideOut 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
}

.modal-backdrop {
    animation: backdropFadeIn 0.3s ease;
}

.modal-backdrop.closing {
    animation: backdropFadeOut 0.3s ease;
}

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

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

/* Notification Animations */
.notification {
    animation: notificationSlideIn 0.3s ease;
}

.notification.hiding {
    animation: notificationSlideOut 0.3s ease;
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Page Transition Effects */
.content-container {
    animation: pageSlideIn 0.4s ease;
}

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

/* Sidebar Animation */
.sidebar {
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

/* Progress Bars */
.progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Chart Animations */
.chart-container {
    animation: chartFadeIn 0.8s ease;
}

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

/* Form Input Focus Effects */
.form-input,
.form-select {
    position: relative;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

/* Badge Pulse Animation */
.badge.pulse {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
}

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

/* Floating Elements */
.floating {
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Glow Effect */
.glow {
    box-shadow: 0 0 20px var(--color-primary);
    animation: glowPulse 2s infinite alternate;
}

@keyframes glowPulse {
    from { box-shadow: 0 0 20px var(--color-primary); }
    to { box-shadow: 0 0 30px var(--color-primary), 0 0 40px var(--color-primary); }
}

/* Stagger Animation for Lists */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: staggerIn 0.6s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes staggerIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Micro-interactions */
.micro-bounce {
    transition: transform 0.2s ease;
}

.micro-bounce:hover {
    transform: scale(1.05);
}

.micro-rotate {
    transition: transform 0.3s ease;
}

.micro-rotate:hover {
    transform: rotate(5deg);
}

/* Number Counter Animation */
.counter {
    animation: countUp 1s ease-out;
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

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

/* Focus Indicators */
*:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus,
.btn:focus {
    outline-offset: 4px;
}

/* Dark Theme Animations */
@media (prefers-color-scheme: dark) {
    .glow {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    }
    
    @keyframes glowPulse {
        from { box-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
        to { box-shadow: 0 0 30px rgba(59, 130, 246, 0.7), 0 0 40px rgba(59, 130, 246, 0.5); }
    }
}

/* 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;
    }
}

/* Performance Optimizations */
.content-container,
.card,
.btn,
.modal {
    will-change: transform;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .card:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 1px solid currentColor;
    }
}

/* Print Styles */
@media print {
    .btn,
    .sidebar,
    .notification,
    .modal {
        display: none !important;
    }
    
    .content-container {
        animation: none !important;
        transform: none !important;
    }
}