/* Loading CSS - Combined loading and spinner styles */

/* Spinner Base */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* Spinner Sizes */
.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.spinner-xl {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: var(--z-modal);
}

.loading-screen .spinner {
    margin-bottom: var(--spacing-md);
}

.loading-text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-sm);
}

/* Loading Skeleton */
.skeleton {
    display: inline-block;
    position: relative;
    overflow: hidden;
    background: var(--bg-elevated);
    border-radius: var(--border-radius);
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite;
}

/* Skeleton Variants */
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-button {
    height: 36px;
    width: 120px;
}

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

.skeleton-image {
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

/* Progress Bar */
.progress {
    width: 100%;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

/* Progress Bar Variants */
.progress-sm {
    height: 2px;
}

.progress-lg {
    height: 8px;
}

.progress-success .progress-bar {
    background: var(--success-color);
}

.progress-error .progress-bar {
    background: var(--error-color);
}

.progress-warning .progress-bar {
    background: var(--warning-color);
}

/* Progress with Label */
.progress-labeled {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Indeterminate Progress */
.progress-indeterminate .progress-bar {
    width: 50%;
    animation: indeterminate 1.5s infinite linear;
}

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

/* Loading Dots */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading-dots::after {
    content: '.';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40%, 60% { content: '..'; }
    80%, 100% { content: '...'; }
}

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

.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .spinner {
        border-color: ButtonText;
        border-right-color: transparent;
    }

    .skeleton {
        background: Canvas;
        border: 1px solid ButtonText;
    }

    .skeleton::after {
        display: none;
    }

    .progress {
        border: 1px solid ButtonText;
    }

    .progress-bar {
        background: Highlight;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
        border-color: currentColor;
    }

    .skeleton::after {
        animation: none;
    }

    .progress-bar {
        transition: none;
    }

    .progress-indeterminate .progress-bar {
        animation: none;
        width: 100%;
    }

    .loading-dots::after {
        animation: none;
        content: '...';
    }
}

/* Print Styles */
@media print {
    .loading-overlay,
    .loading-screen,
    .skeleton::after {
        display: none;
    }

    .progress {
        border: 1px solid #000;
    }

    .progress-bar {
        background: #000;
    }
}
