/* ========================================
   MODERN APPLICATION LOADER
   ======================================== */

/* Loader Wrapper - Full page overlay */
.loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: var(--bg-surface);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-wrapper.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Modern Spinner Container */
.modern-loader {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Outer rotating ring */
.modern-loader-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: var(--theme-accent);
    border-right-color: var(--theme-accent);
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* Middle rotating ring */
.modern-loader-ring-2 {
    position: absolute;
    width: 80%;
    height: 80%;
    border: 4px solid transparent;
    border-bottom-color: color-mix(in srgb, var(--theme-accent) 70%, transparent);
    border-left-color: color-mix(in srgb, var(--theme-accent) 70%, transparent);
    border-radius: 50%;
    animation: spin 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite reverse;
}

/* Inner rotating ring */
.modern-loader-ring-3 {
    position: absolute;
    width: 60%;
    height: 60%;
    border: 4px solid transparent;
    border-top-color: color-mix(in srgb, var(--theme-accent) 50%, transparent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Center dot */
.modern-loader-dot {
    width: 20px;
    height: 20px;
    background: var(--theme-accent);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading text */
.modern-loader-text {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--theme-accent);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.9;
    white-space: nowrap;
}

/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Dark mode support */
body.dark-only .loader-wrapper {
    background: linear-gradient(135deg, #2A3650 0%, #1a202e 100%);
}

/* Alternative: Dots Loader Style */
.dots-loader {
    display: none; /* Hidden by default, can be enabled via JS */
    position: relative;
    width: 80px;
    height: 80px;
}

.dots-loader span {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--bg-surface);
    border-radius: 50%;
    animation: bounce 1.5s infinite ease-in-out;
}

.dots-loader span:nth-child(1) {
    left: 0;
    animation-delay: -0.32s;
}

.dots-loader span:nth-child(2) {
    left: 32px;
    animation-delay: -0.16s;
}

.dots-loader span:nth-child(3) {
    left: 64px;
    animation-delay: 0s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Inline/Small Loaders for AJAX requests */
.inline-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    border-top-color: var(--theme-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

.inline-loader-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.inline-loader-lg {
    width: 32px;
    height: 32px;
    border-width: 4px;
}

/* Button loader */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Card/Section Loaders */
.section-loader {
    position: relative;
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.section-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    border-top-color: var(--theme-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Skeleton loader for content */
.skeleton-loader {
    background: linear-gradient(90deg, var(--border-light) 25%, #e0e0e0 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

body.dark-only .skeleton-loader {
    background: linear-gradient(90deg, #2A3650 25%, #374462 50%, #2A3650 75%);
    background-size: 200% 100%;
}

/* Utility classes */
.loader-hidden {
    display: none !important;
}

.loader-visible {
    display: flex !important;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .modern-loader {
        width: 80px;
        height: 80px;
    }

    .modern-loader-text {
        font-size: 14px;
        bottom: -40px;
    }
}
