/**
 * ═══════════════════════════════════════════════════════════
 * Inline Spinner Component
 * ═══════════════════════════════════════════════════════════
 * 
 * Purpose: spinner بسيط للتنقل بين الأقسام
 * Usage: يظهر أثناء تحميل البيانات عند التنقل في SPA
 * 
 * Architecture:
 * - يستخدم CSS Variables من tokens.css
 * - لا inline styles من JS
 * - التحكم بالحالات عبر classes
 * 
 * Classes:
 * - .hidden: إخفاء الـ spinner
 * - .visible: إظهار الـ spinner
 * 
 * Dependencies: tokens.css
 * ═══════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════
   (1) الحاوية - Overlay فوق المحتوى
   ═══════════════════════════════════════════════════════════ */

#content-loader {
    /* مخفي بشكل افتراضي */
    display: none;
    
    /* في مركز الشاشة كـ overlay */
    position: fixed;
    top: var(--magic-nav-height, 70px);
    left: 0;
    width: 100%;
    height: calc(100% - var(--magic-nav-height, 70px));
    
    /* z-index عالي ليظهر فوق المحتوى */
    z-index: 999;
    
    /* overlay شفاف */
    background: rgba(var(--white-rgb), 0.95);
    backdrop-filter: blur(5px);
    
    /* توسيط المحتوى */
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* إظهار الـ spinner */
#content-loader.visible {
    display: flex;
}

/* للثيم الليلي */
body.theme-night #content-loader {
    background: var(--surface-1);
    backdrop-filter: blur(5px);
}

/* ═══════════════════════════════════════════════════════════
   (2) الـ Spinner نفسه
   ═══════════════════════════════════════════════════════════ */

.inline-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--surface-2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spinRotate 1s linear infinite;
    margin: 0 auto;
}

/* نسخة أكبر للصفحات */
.inline-spinner.large {
    width: 60px;
    height: 60px;
    border-width: 5px;
}

/* نسخة صغيرة للأزرار */
.inline-spinner.small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ═══════════════════════════════════════════════════════════
   (3) Animation
   ═══════════════════════════════════════════════════════════ */

@keyframes spinRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ═══════════════════════════════════════════════════════════
   (4) نص اختياري مع الـ Spinner
   ═══════════════════════════════════════════════════════════ */

.spinner-with-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md, 15px);
}

.spinner-text {
    color: var(--text-light);
    font-size: var(--font-size-sm, 0.9rem);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   (5) دعم الثيمات
   ═══════════════════════════════════════════════════════════ */

/* في الثيم الليلي */
body.theme-night .inline-spinner {
    border-color: var(--border-color-light);
    border-top-color: var(--primary-color);
}

body.theme-night .spinner-text {
    color: var(--text-main);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   (6) Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .inline-spinner {
        width: 45px;
        height: 45px;
        border-width: 4px;
    }
    
    .spinner-text {
        font-size: var(--font-size-xs, 0.85rem);
    }
}
