/**
 * Loading Indicator Styles
 * Global loading overlay and element-specific loading states
 */

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
    background-color: var(--card-bg);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
}

.loading-text {
    margin-top: var(--spacing-md);
    margin-bottom: 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ==========================================================================
   Element Loading States
   ========================================================================== */

.loading-element {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

button.loading-element,
.btn.loading-element {
    cursor: not-allowed;
}

/* ==========================================================================
   Form Disabled States
   ========================================================================== */

form button[disabled],
form input[disabled],
form select[disabled],
form textarea[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================================================
   Inline Spinners
   ========================================================================== */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

.spinner-inline {
    display: inline-block;
    vertical-align: middle;
    margin-right: var(--spacing-sm);
}

/* ==========================================================================
   Card Loading State
   ========================================================================== */

.card.loading {
    position: relative;
    pointer-events: none;
}

.card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* ==========================================================================
   Table Loading State
   ========================================================================== */

.table-loading {
    position: relative;
    min-height: 200px;
}

.table-loading tbody {
    opacity: 0.5;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3rem;
    height: 3rem;
    border: 0.25rem solid var(--brand-primary);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

/* ==========================================================================
   Skeleton Loaders
   ========================================================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--spacing-sm);
}

.skeleton-title {
    height: 1.5rem;
    margin-bottom: var(--spacing-md);
    width: 60%;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
}

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

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.loading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: transparent;
    z-index: 10000;
    display: none;
}

.loading-progress.active {
    display: block;
}

.loading-progress-bar {
    height: 100%;
    background-color: var(--brand-primary);
    width: 0;
    transition: width var(--transition-base);
    animation: loading-progress 2s ease-in-out infinite;
}

@keyframes loading-progress {
    0% {
        width: 0;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background-color: rgba(0, 0, 0, 0.7);
    }

    .skeleton {
        background: linear-gradient(
            90deg,
            #2a2a2a 25%,
            #3a3a3a 50%,
            #2a2a2a 75%
        );
    }

    .card.loading::after {
        background-color: rgba(26, 32, 44, 0.8);
    }
}

[data-theme="dark"] .loading-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        #2a2a2a 25%,
        #3a3a3a 50%,
        #2a2a2a 75%
    );
}

[data-theme="dark"] .card.loading::after {
    background-color: rgba(26, 32, 44, 0.8);
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

.loading-overlay {
    animation: fadeIn var(--transition-fast);
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.no-pointer-events {
    pointer-events: none;
}

.cursor-wait {
    cursor: wait !important;
}

.cursor-not-allowed {
    cursor: not-allowed !important;
}
