/*=============================================
  ملف التنسيقات النهائي لموقع moe networks (نسخة مصححة)
===============================================*/

/* * 1. المتغيرات وإعادة الضبط
 * ------------------------------------------- */
:root {
    --bg-color: #0A192F;
    --container-bg-color: #172A45;
    --card-bg-color: #0E2038;
    --text-color: #CCD6F6;
    --heading-color: #58E6D9;
    --border-color: #2F4462;
    --link-color: #58E6D9;
    --code-bg-color: #071426;
    --transition-speed: 0.3s;
}

body.light-mode {
    --bg-color: #F8F9FA;
    --container-bg-color: #FFFFFF;
    --card-bg-color: #FFFFFF;
    --text-color: #343A40;
    --heading-color: #004AAD;
    --border-color: #DEE2E6;
    --link-color: #0056B3;
    --code-bg-color: #E9ECEF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* * 2. التنسيقات العامة
 * ------------------------------------ */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Cairo', sans-serif;
    line-height: 1.6;
    direction: rtl;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color var(--transition-speed);
}
a:hover { color: var(--heading-color); }
h1, h2, h3 { color: var(--heading-color); }
hr { border: 0; height: 1px; background-color: var(--border-color); margin: 40px 0; }
img, iframe { max-width: 100%; height: auto; }
p, li { unicode-bidi: isolate; }

/* * 3. الهيكل والتخطيط
 * ----------------------------- */
.container {
    width: 80%;
    max-width: 960px;
    margin: 20px auto;
    padding: 20px;
    background-color: var(--container-bg-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: background-color var(--transition-speed);
}

/* * 4. المكونات
 * ------------------------- */
/* الهيدر */
header {
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(-45deg, #0A192F, #172A45, #004AAD, #58E6D9);
    background-size: 400% 400%;
    animation: gradient-animation 15s ease infinite;
}
header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5em;
    margin-bottom: 15px;
    background: linear-gradient(-45deg, #FFFFFF, #58E6D9, #A7DDEE, #FFFFFF);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: text-animation 15s ease infinite;
}
header p {
    color: #FFFFFF;
    text-shadow: 0px 1px 4px rgba(0, 0, 0, 0.5);
    font-size: 1.1em;
    padding: 0 20px;
}

/* شعار SVG */
.dynamic-logo { width: 280px; height: auto; margin: 0 auto 15px auto; display: block; }
.dynamic-logo path, .dynamic-logo circle, .dynamic-logo rect, .dynamic-logo polygon {
    fill: var(--heading-color);
    animation: logo-color-animation 12s ease-in-out infinite;
}

/* قائمة التنقل */
nav {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
}
#nav-links a { color: var(--text-color); margin: 0 10px; font-size: 1.1em; padding: 8px 15px; border-radius: 5px; position: relative; transition: transform var(--transition-speed), background-color var(--transition-speed), box-shadow var(--transition-speed); }
#nav-links a:hover { transform: translateY(-4px); background-color: var(--card-bg-color); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
#nav-links a:active { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* بطاقات المحتوى */
.articles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; }
.searchable-item { background-color: var(--card-bg-color); border-radius: 8px; border: 1px solid var(--border-color); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; display: flex; }
.searchable-item:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); }
.article-link { display: block; text-decoration: none; color: inherit; width: 100%; text-align: right; }
.article-link h3 { font-size: 1.4em; margin-bottom: 10px; }
.article-date { font-size: 0.9em; opacity: 0.7; margin-bottom: 15px; }
.article-excerpt { font-size: 1em; line-height: 1.7; }
.article-image { margin-top: 15px; border-radius: 5px; }

/* الفوتر */
footer { text-align: center; padding: 20px; margin-top: 40px; border-top: 1px solid var(--border-color); }

/* * 5. ميزات الجافاسكريبت
 * ----------------------------------- */
/* زر العودة للأعلى */
#back-to-top-btn { position: fixed; bottom: 20px; left: 20px; background-color: var(--heading-color); color: white; width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; z-index: 1000; }
#back-to-top-btn.show { opacity: 1; visibility: visible; }

/* شريط البحث */
.search-container { margin: 0 20px; }
#search-bar { width: 220px; padding: 8px 15px; border-radius: 20px; border: 1px solid var(--border-color); background-color: var(--container-bg-color); color: var(--text-color); font-family: inherit; font-size: 0.9em; transition: all var(--transition-speed); }
#search-bar:focus { outline: none; width: 250px; border-color: var(--heading-color); }

/* صفحة الفيديوهات */
.video-item { display: flex; flex-direction: column; align-items: center; border-left: none; border-top: 4px solid var(--heading-color); padding: 25px; }
.video-item .video-description { width: 100%; margin-bottom: 25px; text-align: right; }
.video-item .video-description h3 { font-size: 1.8em; margin-bottom: 10px; }
.video-item .video-container { width: 100%; max-width: 854px; }
.video-container { position: relative; overflow: hidden; width: 100%; padding-top: 56.25%; margin: 20px 0; }
.video-container iframe { position: absolute; top: 0; left: 0; bottom: 0; right: 0; width: 100%; height: 100%; border: none; }

/* صفحة الأقسام */
.category-section { margin-top: 50px; }
.category-section h2 { font-size: 2em; margin-bottom: 10px; border-right: 4px solid var(--heading-color); padding-right: 15px; }
.category-section h2 a { color: inherit; text-decoration: none; transition: color 0.3s; }
.category-section h2 a:hover { text-decoration: underline; }
body.light-mode .category-section h2 a:hover { color: #0056B3; }
.category-divider { border: 0; height: 1px; background-color: var(--border-color); margin-bottom: 30px; }

/* * 6. التجاوب مع الشاشات (Media Queries) - نسخة نهائية ومصححة */
@media (max-width: 768px) {
    .container { 
        width: 95%; 
        padding: 15px; 
    }
    
    /* شريط التنقل للجوال */
    nav {
        position: sticky; 
        top: 0; 
        background-color: var(--container-bg-color); 
        z-index: 1100;
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        padding: 10px 15px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        min-height: 65px;
    }

    #hamburger-btn, #theme-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        background: transparent;
        border: none;
        cursor: pointer;
    }

    #hamburger-btn { z-index: 1300; }
    #theme-toggle-btn { z-index: 1200; color: var(--text-color); }
    #hamburger-btn svg { fill: var(--text-color); }

    .search-container { display: none; }

    /* حركة أيقونة الهمبرجر */
    .line { transition: all 0.3s ease-in-out; transform-origin: center; }
    #hamburger-btn.is-active .top { transform: rotate(45deg); y: 35; }
    #hamburger-btn.is-active .middle { opacity: 0; }
    #hamburger-btn.is-active .bottom { transform: rotate(-45deg); y: 35; }

    /* القائمة الجانبية */
    #nav-links {
        display: none; /* مخفية بشكل افتراضي */
        position: fixed;
        top: 0;
        right: 0;
        width: 80%;
        max-width: 300px;
        height: 100%;
        background-color: var(--bg-color);
        flex-direction: column;
        align-items: center;
        padding-top: 100px;
        box-shadow: -4px 0px 15px rgba(0,0,0,0.3);
        z-index: 1250;
        transform: translateX(100%);
        transition: transform 0.4s ease-in-out;
        visibility: hidden;
    }

    #nav-links.show {
        visibility: visible;
        transform: translateX(0);
        display: flex; /* <-- السطر الحاسم هنا */
    }

    #nav-links a { width: 100%; padding: 20px 0; font-size: 1.3em; }
    #nav-links a:hover { transform: none; box-shadow: none; background-color: var(--card-bg-color); }
    
    /* تعديلات عامة للجوال */
    header h1 { font-size: 2.2em; }
    .category-section h2 { font-size: 1.5em; }
}

@media (prefers-reduced-motion) {
  header, #nav-links, .line, .dynamic-logo path { 
      animation: none;
      transition: none;
    }
}

/* * 7. حركات الأنيميشن
 * ------------------------------------- */
@keyframes gradient-animation { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes text-animation { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes logo-color-animation { 0% { fill: #58E6D9; } 50% { fill: #FFFFFF; } 100% { fill: #58E6D9; } }
@media (prefers-reduced-motion) { header, #nav-links, .line, .dynamic-logo path { animation: none; transition: none; } }