/**
 * ═══════════════════════════════════════════════════════════════
 * MAJAARH - UNIFIED LOADING SYSTEM
 * نظام Loading موحد لكامل المنصة
 * ═══════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════
   1. PAGE PRELOADER - محمل الصفحة الرئيسي
   ═══════════════════════════════════════════════════════════════ */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #07090c 0%, #0f1217 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    animation: fadeInUp 0.6s ease;
}

.loader-logo {
    width: 120px;
    height: auto;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
}

.loader-bar::after {
    content: '';
    display: block;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, #C41E3A, #ff2e2e, #C41E3A);
    background-size: 200% 100%;
    border-radius: 10px;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(300%);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   2. INLINE LOADING SPINNER - سبينر التحميل الداخلي
   ═══════════════════════════════════════════════════════════════ */

.spinner-border {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

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

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

/* ═══════════════════════════════════════════════════════════════
   3. BUTTON LOADING STATE - حالة التحميل للأزرار
   ═══════════════════════════════════════════════════════════════ */

.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 #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner-border 0.75s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════
   4. CONTENT LOADING SKELETON - هيكل التحميل للمحتوى
   ═══════════════════════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.05) 25%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 10px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 15px;
}

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

.skeleton-card {
    height: 200px;
    border-radius: 16px;
}

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

/* ═══════════════════════════════════════════════════════════════
   5. OVERLAY LOADING - تحميل الطبقة العلوية
   ═══════════════════════════════════════════════════════════════ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 9, 12, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-overlay .spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #C41E3A;
    border-radius: 50%;
    animation: spinner-border 0.8s linear infinite;
}

.loading-overlay .loading-text {
    color: white;
    margin-top: 20px;
    font-size: 14px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   6. PROGRESS BAR - شريط التقدم
   ═══════════════════════════════════════════════════════════════ */

.progress-bar-loading {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, #C41E3A, #ff2e2e);
    border-radius: 10px;
    animation: progress-loading 1.5s ease-in-out infinite;
}

@keyframes progress-loading {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   7. DOTS LOADING - نقاط التحميل
   ═══════════════════════════════════════════════════════════════ */

.dots-loading {
    display: inline-flex;
    gap: 8px;
}

.dots-loading span {
    width: 8px;
    height: 8px;
    background: #C41E3A;
    border-radius: 50%;
    animation: dots-bounce 1.4s ease-in-out infinite;
}

.dots-loading span:nth-child(1) {
    animation-delay: 0s;
}

.dots-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dots-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════
   8. RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .loader-logo {
        width: 80px;
    }
    
    .loader-bar {
        width: 150px;
    }
    
    .loading-overlay .spinner {
        width: 40px;
        height: 40px;
    }
}
