/**
 * Loading Spinner Components
 *
 * Replaces inline spinner styles throughout the application
 * Usage: Add .spinner class to elements instead of inline styles
 */

/* ========================================
   BASE SPINNER
   ======================================== */

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-300, #dee2e6);
    border-top-color: var(--color-primary, #3498db);
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

/* ========================================
   SPINNER SIZES
   ======================================== */

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-md {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* ========================================
   SPINNER COLORS
   ======================================== */

.spinner-primary {
    border-color: var(--color-gray-300, #dee2e6);
    border-top-color: var(--color-primary, #3498db);
}

.spinner-success {
    border-color: var(--color-gray-300, #dee2e6);
    border-top-color: var(--color-success, #27ae60);
}

.spinner-error {
    border-color: var(--color-gray-300, #dee2e6);
    border-top-color: var(--color-error, #e74c3c);
}

.spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

/* ========================================
   FULL-PAGE LOADING OVERLAY
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border-width: 6px;
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

/* ========================================
   LOADING MESSAGE
   ======================================== */

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.loading-message {
    color: var(--text-primary, #2c3e50);
    font-size: 14px;
    font-weight: 500;
}

.loading-overlay .loading-message {
    color: #ffffff;
}

/* ========================================
   INLINE LOADING STATE
   ======================================== */

.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading-inline .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ========================================
   BUTTON LOADING STATE
   ======================================== */

button.loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
}

/* ========================================
   PROGRESS BAR
   ======================================== */

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--color-gray-200, #dee2e6);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--color-primary, #3498db);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.progress-bar-success {
    background: var(--color-success, #27ae60);
}

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

/* ========================================
   DARK THEME SUPPORT
   ======================================== */

[data-theme="dark"] .spinner {
    border-color: var(--color-gray-700, #495057);
    border-top-color: var(--color-primary, #3498db);
}

[data-theme="dark"] .loading-message {
    color: var(--text-primary, #ecf0f1);
}

[data-theme="dark"] .progress-bar-container {
    background: var(--color-gray-700, #495057);
}

/* ========================================
   SKELETON LOADING (Bonus)
   ======================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200, #dee2e6) 25%,
        var(--color-gray-300, #ced4da) 50%,
        var(--color-gray-200, #dee2e6) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

.skeleton-text {
    height: 1em;
    border-radius: 4px;
    margin-bottom: 0.5em;
}

.skeleton-card {
    width: 100%;
    height: 200px;
    border-radius: 8px;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-700, #495057) 25%,
        var(--color-gray-600, #6c757d) 50%,
        var(--color-gray-700, #495057) 75%
    );
    background-size: 200% 100%;
}
