/**
 * SIBERTEX - Loading & Skeleton CSS
 * CANONICAL_SYSTEM_RULES_AND_SOT.md §10.1.1
 * 
 * Centralized loading UX styles (spinner + skeletons).
 * Single source of truth for all loading states.
 */

/* ==========================================================================
   GLOBAL SPINNER OVERLAY
   ========================================================================== */

.sib-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
}

.sib-spinner-overlay.d-none {
    display: none !important;
}

.sib-spinner-content {
    text-align: center;
    padding: 2rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.sib-spinner-icon {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

.sib-spinner-text {
    font-size: 0.95rem;
    color: var(--sib-text-secondary, #6c757d);
    font-weight: 500;
}

/* Body class when loading is active - prevent interaction */
body.sib-loading-active {
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}

body.sib-loading-active .sib-spinner-overlay {
    pointer-events: auto;
}

/* ==========================================================================
   SKELETON LOADING PLACEHOLDERS
   ========================================================================== */

.sib-skeleton {
    padding: 1rem;
}

.sib-skeleton-row {
    margin-bottom: 1rem;
}

.sib-skeleton-row:last-child {
    margin-bottom: 0;
}

.sib-skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, 
        var(--sib-skeleton-base, #e9ecef) 0%, 
        var(--sib-skeleton-shine, #f8f9fa) 50%, 
        var(--sib-skeleton-base, #e9ecef) 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: sib-skeleton-shimmer 1.5s infinite ease-in-out;
    margin-bottom: 0.5rem;
}

.sib-skeleton-line:last-child {
    margin-bottom: 0;
}

.sib-skeleton-line-short {
    width: 30%;
}

.sib-skeleton-line-medium {
    width: 60%;
}

.sib-skeleton-line-long {
    width: 85%;
}

/* Table skeleton */
.sib-skeleton-table {
    width: 100%;
}

.sib-skeleton-table-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.sib-skeleton-table-cell {
    flex: 1;
    height: 2.5rem;
    background: linear-gradient(90deg, 
        var(--sib-skeleton-base, #e9ecef) 0%, 
        var(--sib-skeleton-shine, #f8f9fa) 50%, 
        var(--sib-skeleton-base, #e9ecef) 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: sib-skeleton-shimmer 1.5s infinite ease-in-out;
}

.sib-skeleton-table-row:first-child .sib-skeleton-table-cell {
    background: var(--sib-skeleton-header, #dee2e6);
}

/* Card skeleton */
.sib-skeleton-card {
    padding: 1.25rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--sib-border-color, #e9ecef);
}

.sib-skeleton-card-title {
    height: 1.5rem;
    width: 50%;
    margin-bottom: 1rem;
}

.sib-skeleton-card-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

/* Shimmer animation */
@keyframes sib-skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   BUTTON LOADING STATES
   ========================================================================== */

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

.btn.sib-btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sib-btn-spin 0.75s linear infinite;
    color: inherit;
}

.btn.sib-btn-loading::after {
    color: #fff;
}

.btn-outline-primary.sib-btn-loading::after,
.btn-outline-secondary.sib-btn-loading::after,
.btn-outline-success.sib-btn-loading::after,
.btn-outline-danger.sib-btn-loading::after,
.btn-outline-warning.sib-btn-loading::after,
.btn-outline-info.sib-btn-loading::after,
.btn-light.sib-btn-loading::after {
    color: var(--sib-primary, #4154f1);
}

@keyframes sib-btn-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   INLINE LOADING INDICATORS
   ========================================================================== */

.sib-inline-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sib-text-muted, #6c757d);
    font-size: 0.875rem;
}

.sib-inline-loading-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sib-btn-spin 0.75s linear infinite;
}

/* ==========================================================================
   PROGRESS BAR FOR LONG OPERATIONS
   ========================================================================== */

.sib-progress-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sib-bg-dark, #0f2744);
    color: #fff;
    padding: 0.75rem 1.5rem;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.sib-progress-overlay.active {
    transform: translateY(0);
}

.sib-progress-text {
    font-size: 0.875rem;
    white-space: nowrap;
}

.sib-progress-bar-container {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.sib-progress-bar {
    height: 100%;
    background: var(--sib-success, #28a745);
    border-radius: 3px;
    transition: width 0.3s ease;
}
