/* =========================================
   1. المتغيرات ونظام الألوان (Light & Dark)
   ========================================= */
:root {
    /* --- الوضع النهاري (الافتراضي) --- */
    --primary-color: #0052cc;       /* أزرق مدخل الرسمي */
    --bg-color: #f8f9fa;            /* خلفية الصفحة */
    --surface-color: #ffffff;       /* لون الكروت والقوائم */
    --text-dark: #1f2937;           /* النصوص الرئيسية */
    --text-light: #6b7280;          /* النصوص الفرعية */
    --border-color: #e5e7eb;        /* لون الحدود والفواصل */
    --header-bg: rgba(255, 255, 255, 0.85); /* خلفية الهيدر الشفافة */
    --shadow-color: rgba(0, 0, 0, 0.05);    /* لون الظل */
    
    /* --- أبعاد ثابتة --- */
    --nav-height: 70px;
    --header-height: 60px;
}

/* --- الوضع الليلي (Dark Mode) --- */
[data-theme="dark"] {
    --primary-color: #60a5fa;       /* أزرق سماوي فاتح (عشان يوضح في الظلام) */
    --bg-color: #121212;            /* لون فحمي غامق (أفخم من الأسود الكامل) */
    --surface-color: #1e1e1e;       /* رمادي غامق للكروت */
    --text-dark: #e4e6eb;           /* أبيض مريح للعين (أوف وايت) */
    --text-light: #9ca3af;          /* رمادي فاتح */
    --border-color: #2d2d2d;        /* حدود غامقة */
    --header-bg: rgba(30, 30, 30, 0.85); /* هيدر غامق شفاف */
    --shadow-color: rgba(0, 0, 0, 0.3);  /* ظل أثقل للوضع الليلي */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    padding-bottom: calc(var(--nav-height) + 20px);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease; /* تنعيم التحويل بين الوضعين */
}

/* =========================================
   2. خلفية الإيموجي العائمة
   ========================================= */
#emoji-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.emoji-bg-item {
    position: absolute;
    opacity: 0.08;
    font-size: 24px;
    filter: grayscale(0.6);
}

/* في الدارك مود نخفف الإيموجي زيادة عشان ما تشوش */
[data-theme="dark"] .emoji-bg-item {
    opacity: 0.05;
}

/* =========================================
   3. الهيدر العلوي (Header)
   ========================================= */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    height: var(--header-height);
    background: var(--header-bg); /* استخدام المتغير */
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 10px var(--shadow-color);
    transition: background 0.3s ease;
}

.logo-container img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}

.menu-btn {
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    border-radius: 50%;
    transition: background 0.2s;
}

.menu-btn:active {
    background: var(--border-color);
}

/* =========================================
   4. تنسيق القائمة الجانبية (Sidebar)
   ========================================= */

#sidebarOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* تعتيم أغمق شوي */
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

#sidebarOverlay.active {
    opacity: 1;
    visibility: visible;
}

#sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background-color: var(--surface-color) !important; /* صار ياخذ لون الثيم */
    z-index: 9999;
    transition: left 0.3s ease-in-out, background-color 0.3s ease;
    box-shadow: 5px 0 15px var(--shadow-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.close-btn {
    background: var(--bg-color); /* زر الإغلاق ياخذ لون الخلفية */
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-btn:hover {
    background: #ffebeb;
    color: #d93025;
}

/* في الدارك مود، الهوفر حق زر الإغلاق يكون أغمق */
[data-theme="dark"] .close-btn:hover {
    background: #4a1b1b;
}

.sidebar-menu { list-style: none; padding: 0; margin: 0; }
.sidebar-menu li { margin-bottom: 8px; }

.sidebar-menu a {
    text-decoration: none;
    color: var(--text-dark); /* النص يتغير تلقائي */
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: 12px;
    transition: 0.2s;
    font-weight: 500;
}

.sidebar-menu a:hover, 
.sidebar-menu a.active {
    background-color: var(--bg-color); /* بدال الأزرق الفاتح، نستخدم لون الخلفية */
    color: var(--primary-color);
    font-weight: 700;
}

/* هذا عشان نضبط لون الهوفر في الدارك مود */
[data-theme="dark"] .sidebar-menu a:hover,
[data-theme="dark"] .sidebar-menu a.active {
    background-color: rgba(96, 165, 250, 0.15); /* أزرق شفاف خفيف */
}

.sidebar-menu i { font-size: 18px; }

/* =========================================
   5. قسم الترحيب (Welcome Section)
   ========================================= */
.welcome-section {
    text-align: center;
    padding: 25px 20px;
    margin-top: 10px;
}

.glow-text {
    font-size: 22px;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 800;
    text-shadow: 0 0 15px rgba(0, 82, 204, 0.2); /* خففنا الظل شوي */
    animation: glowPulse 3s infinite alternate;
}

@keyframes glowPulse {
    0% { text-shadow: 0 0 10px rgba(0, 82, 204, 0.1); }
    100% { text-shadow: 0 0 20px rgba(0, 82, 204, 0.4); }
}

.sub-text {
    color: var(--text-light);
    font-size: 14px;
}

/* =========================================
   6. قسم الاختصارات (Shortcuts)
   ========================================= */
.shortcuts-section {
    padding: 10px 20px;
}

.section-title {
    text-align: right;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-light); /* تغيير للون المتغير */
    padding-right: 5px;
}

.shortcuts-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 5px 5px 20px 5px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.shortcuts-grid::-webkit-scrollbar {
    display: none; 
}

.shortcut-card {
    position: relative;
    min-width: 110px;
    height: 110px;
    border-radius: 20px;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: transform 0.2s;
    overflow: hidden;
    scroll-snap-align: start;
}

.shortcut-card:active {
    transform: scale(0.96);
}

.shortcut-icon {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 22px;
    opacity: 0.9;
}

.shortcut-text {
    position: absolute;
    bottom: 15px;
    right: 15px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

/* التدرجات تبقى كما هي لأنها جميلة في الوضعين */
.blue-gradient {
    background: linear-gradient(135deg, #4facfe 0%, #007c83 100%);
    box-shadow: 0 8px 15px rgba(0, 198, 251, 0.25);
}

.purple-gradient {
    background: linear-gradient(135deg, #7a64ac 0%, #97a2ff 100%);
    box-shadow: 0 8px 15px rgba(161, 140, 209, 0.25);
}

.orange-gradient {
    background: linear-gradient(135deg, #f6d365 0%, #ec937a 100%);
    box-shadow: 0 8px 15px rgba(253, 160, 133, 0.25);
}

.green-gradient {
    background: linear-gradient(135deg, #63e2b1 0%, #41a1d1 100%);
    box-shadow: 0 8px 15px rgba(132, 250, 176, 0.25);
}

/* =========================================
   7. البار السفلي (Bottom Navigation)
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--surface-color); /* صار ياخذ لون الثيم */
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    box-shadow: 0 -5px 25px var(--shadow-color);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    transition: background 0.3s ease;
}

.nav-item {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light); /* بدال الرمادي الثابت */
    font-size: 11px;
    font-weight: 500;
    transition: 0.3s;
    width: 25%;
    height: 100%;
}

.nav-item i {
    font-size: 22px;
    margin-bottom: 5px;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active i {
    transform: translateY(-5px);
    color: var(--primary-color);
}

/* =========================================
   8. المودال (Pop-up Styling)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface-color); /* المودال صار يدعم الدارك مود */
    width: 100%;
    max-width: 500px;
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    padding: 25px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--primary-color);
}

.modal-close-btn {
    background: var(--bg-color); /* زر الإغلاق */
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 16px;
    color: var(--text-light);
    cursor: pointer;
    transition: 0.2s;
}

[data-theme="dark"] .modal-close-btn:hover {
    background: #333;
    color: #fff;
}

/* =========================================
   8. تكملة المودال والأزرار
   ========================================= */

/* أقسام التخصصات */
.major-title {
    font-size: 14px;
    color: var(--text-light); /* تم التعديل */
    margin-bottom: 10px;
}

.buttons-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-divider {
    border: 0;
    border-top: 1px solid var(--border-color); /* تم التعديل */
    margin: 20px 0;
}

/* الأزرار داخل المودال */
.app-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    font-family: 'Tajawal', sans-serif;
}

/* الستايل الأساسي (أزرق) */
.app-btn.primary {
    background-color: rgba(0, 82, 204, 0.08);
    color: var(--primary-color);
}

.app-btn.primary:active {
    background-color: rgba(0, 82, 204, 0.2);
}

/* تعديل للدارك مود: نخلي الخلفية أوضح شوي */
[data-theme="dark"] .app-btn.primary {
    background-color: rgba(96, 165, 250, 0.15);
}

/* الستايل الثانوي (رمادي) */
.app-btn.secondary {
    background-color: var(--bg-color); /* تم التعديل */
    color: var(--text-dark); /* تم التعديل */
    border: 1px solid var(--border-color); /* تم التعديل */
}

.app-btn.secondary:active {
    filter: brightness(0.95); /* تأثير ضغط عام */
}

/* =========================================
   9. قسم الأحداث القادمة (Events Widget)
   ========================================= */

.events-section {
    padding: 0 20px 20px 20px;
    margin-top: 15px;
}

.events-wrapper {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 5px 5px 25px 5px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.events-wrapper::-webkit-scrollbar {
    display: none;
}

/* --- تصميم الكرت --- */
#calender-events > div {
    min-width: 240px;
    background: var(--surface-color); /* تم التعديل: يدعم الدارك */
    border-radius: 24px;
    padding: 20px 18px;
    box-shadow: 0 8px 20px var(--shadow-color); /* تم التعديل */
    position: relative;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(0, 82, 204, 0.05);
}

/* حدود خفيفة في الدارك مود */
[data-theme="dark"] #calender-events > div {
    border: 1px solid var(--border-color);
}

#calender-events > div:active {
    transform: scale(0.98);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* --- تنسيق النصوص الداخلية --- */

#calender-events h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-dark); /* تم التعديل */
    font-weight: 800;
    text-align: center;
    line-height: 1.4;
    height: 42px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* حاوية العداد التنازلي */
#calender-events .event-timer {
    background: #f0f7ff; /* أزرق ثلجي فاتح للوضع النهاري */
    border-radius: 16px;
    padding: 12px 10px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    direction: ltr;
    margin: 0 auto !important;
    width: 100%;
    border: 1px solid #e1effe;
}

/* تعديل العداد للوضع الليلي */
[data-theme="dark"] #calender-events .event-timer {
    background: rgba(96, 165, 250, 0.1); /* أزرق غامق شفاف */
    border-color: rgba(96, 165, 250, 0.2);
}

#calender-events .event-timer > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 45px;
}

/* تنسيق الأرقام */
#calender-events .event-timer span[style*="font-size: 20px"] {
    font-size: 22px !important;
    color: var(--primary-color) !important; /* تم التعديل */
    font-weight: 800 !important;
    line-height: 1;
    margin-bottom: 2px;
}

/* تنسيق الكلمات (يوم/ساعة) */
#calender-events .event-timer span[style*="font-size: 11px"] {
    font-size: 10px !important;
    color: #7b8ab5 !important;
    font-weight: 600;
}

/* تعديل الكلمات للدارك مود */
[data-theme="dark"] #calender-events .event-timer span[style*="font-size: 11px"] {
    color: var(--text-light) !important;
}

/* الفواصل (:) */
#calender-events .event-timer > span[style*="color: #ddd"] {
    color: #cbd5e1 !important;
    font-size: 20px !important;
    margin-top: -12px !important;
    font-weight: 300;
}

[data-theme="dark"] #calender-events .event-timer > span[style*="color: #ddd"] {
    color: #4b5563 !important;
}

/* التاريخ واليوم أسفل الكرت */
#calender-events > div > div[style*="font-size: 12px"] {
    margin-top: auto;
    padding-top: 15px;
    font-size: 11px !important;
    color: var(--text-light) !important; /* تم التعديل */
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    direction: rtl;
}

/* =========================================
   10. قسم الأخبار (News Widget)
   ========================================= */

.news-section {
    padding: 0 20px 20px 20px;
    margin-top: 20px;
    margin-bottom: 80px;
}

.news-wrapper {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px 30px 5px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.news-wrapper::-webkit-scrollbar {
    display: none;
}

.news-card {
    min-width: 280px;
    height: 240px;
    background: var(--surface-color); /* تم التعديل: يدعم الدارك */
    border-radius: 20px;
    box-shadow: 0 10px 20px var(--shadow-color); /* تم التعديل */
    overflow: hidden;
    scroll-snap-align: start;
    position: relative;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    border: 1px solid rgba(0,0,0,0.03);
}

[data-theme="dark"] .news-card {
    border: 1px solid var(--border-color);
}

.news-card:active {
    transform: scale(0.97);
}

.news-card-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background-color: var(--border-color); /* عشان ما تطلع بيضاء ساطعة لو ما حملت */
}

.news-card-content {
    padding: 12px 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.news-category {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 82, 204, 0.9);
    backdrop-filter: blur(4px);
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.news-card-title {
    font-size: 14px;
    color: var(--text-dark); /* تم التعديل */
    font-weight: 700;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-date {
    font-size: 11px;
    color: var(--text-light); /* تم التعديل */
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================================
   تنسيق الشاشات الكبيرة (iPad & PC Fix)
   ========================================= */

@media (min-width: 500px) {
    
    html {
        background-color: var(--bg-color); /* تم التعديل */
        overflow-x: hidden;
    }

    body {
        width: 480px;
        min-height: 100vh;
        margin: 0 auto;
        background-color: var(--surface-color); /* تم التعديل: الجوال يصير لونه زي الثيم */
        position: relative;
        box-shadow: 0 0 40px rgba(0,0,0,0.15);
        border-right: 1px solid var(--border-color); /* تم التعديل */
        border-left: 1px solid var(--border-color); /* تم التعديل */
    }

    .top-header, 
    .bottom-nav, 
    .news-filter-container, 
    .tabs-container, 
    .article-header {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        width: 480px !important;
        margin: 0 auto !important;
        transform: none !important;
        background-color: var(--surface-color); /* ضمان الخلفية */
    }

    /* إصلاح خاص للهيدر الشفاف في الـ PC */
    .top-header {
        background-color: var(--header-bg) !important;
    }

    .top-header { top: 0; z-index: 1000; }
    .bottom-nav { bottom: 0; z-index: 1000; }
    
    #sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        height: 100% !important;
        z-index: 9999 !important;
        left: 50% !important;
        margin-left: -240px !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        right: auto !important;
        border-radius: 0 !important;
        overflow-y: auto !important;
        background-color: var(--surface-color) !important; /* تم التعديل */
    }

    #sidebar.active {
        transform: translateX(0) !important;
        box-shadow: 5px 0 25px rgba(0,0,0,0.15) !important;
    }

    #sidebarOverlay {
        position: fixed !important;
        top: 0;
        bottom: 0;
        width: 480px !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
        z-index: 9998 !important;
    }
}

/* =========================================
   تصميم نافذة التثبيت (PWA Install Popup)
   ========================================= */
.pwa-popup {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--surface-color); /* تم التعديل: يدعم الدارك */
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    border-radius: 20px 20px 0 0;
    z-index: 99999;
    padding: 20px;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border-color); /* إضافة حد علوي خفيف */
}

.pwa-popup.show {
    bottom: 0;
}

.pwa-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pwa-header {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.pwa-logo {
    width: 50px;
    height: 50px;
    border-radius: 12px;
}

.pwa-text h3 {
    margin: 0 0 5px;
    font-size: 16px;
    color: var(--text-dark); /* تم التعديل */
}

.pwa-text p {
    margin: 0;
    font-size: 12px;
    color: var(--text-light); /* تم التعديل */
}

.pwa-close {
    position: absolute;
    left: 0;
    top: 0;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light); /* تم التعديل */
    cursor: pointer;
    padding: 5px;
}

/* تعليمات الآيفون */
.install-instructions {
    background: var(--bg-color); /* تم التعديل */
    padding: 15px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-dark); /* تم التعديل */
}

.install-instructions ol {
    padding-right: 20px;
    margin: 10px 0 0;
}

.install-instructions li {
    margin-bottom: 5px;
}

/* زر التثبيت (أندرويد) */
.install-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
}
/* =========================================
   تنسيق زر الوضع الليلي (Toggle Switch)
   ========================================= */

/* الحاوية العامة للسطر */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between; /* يوزع المسافة بينهم */
    padding: 12px 15px;
    border-radius: 12px;
    transition: 0.2s;
}

/* النص والأيقونة */
.theme-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-dark);
}

/* شكل السويتش (الإطار) */
.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 44px;
}

.theme-switch input {
    display: none; /* إخفاء مربع الاختيار العادي */
}

/* شكل الدائرة والخلفية */
.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

/* الدائرة البيضاء المتحركة */
.slider:before {
    background-color: #fff;
    bottom: 3px;
    content: "";
    height: 18px;
    left: 3px; /* مكانها وهي طافية */
    position: absolute;
    transition: .4s;
    width: 18px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* حالة التشغيل (أزرق) */
input:checked + .slider {
    background-color: var(--primary-color);
}

/* حركة الدائرة لليسار عند التشغيل */
input:checked + .slider:before {
    transform: translateX(20px);
}

/* تحسين الهوفر في الدارك مود */
[data-theme="dark"] .slider {
    background-color: #333; /* لون السويتش وهو طافي في الليلي */
}

/* =========================================
   شاشة التحميل (Preloader) - أنيقة وتدعم الدارك مود
   ========================================= */

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--surface-color); /* 👈 ياخذ لون الخلفية حسب المود */
    z-index: 999999; /* فوق كل شي حرفياً */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s; /* حركة اختفاء ناعمة */
}

/* الحاوية اللي فيها الشعار والسبينر */
.loader-content {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* الشعار داخل الشاشة */
.loader-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    animation: pulseLogo 2s infinite ease-in-out;
    position: relative;
    z-index: 2;
}

/* إذا كنت مفعل كود قلب ألوان الشعار للدارك مود، طبقه هنا بعد */
[data-theme="dark"] .loader-logo {
    filter: brightness(0) invert(1) opacity(0.9);
}

/* حلقة التحميل الدائرة */
.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color); /* لون التحميل أزرق */
    border-radius: 50%;
    animation: spinRing 1s linear infinite;
    z-index: 1;
}

/* كلاس الاختفاء (يضاف بالجافاسكربت) */
#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* --- الحركات (Animations) --- */

/* حركة النبض للشعار */
@keyframes pulseLogo {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* حركة دوران الحلقة */
@keyframes spinRing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}