
/* ==========================================
   1. الإعدادات العامة والمتغيرات
   ========================================== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #0f172a;
    --accent: #38bdf8;
    --bg-dark: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    direction: rtl;
}

/* توهج خلفي جمالي */
.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e3a8a 0%, transparent 50%);
    opacity: 0.15;
    z-index: -1;
}

/* ==========================================
   2. شريط التنقل (Navbar)
   ========================================== */
.navbar {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 15px 0;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo-text {
    font-size: 26px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 1px;
}

/* روابط القائمة */
.nav-links {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 25px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: 0.3s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent);
}

/* زر القائمة للجوال */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
}

/* ==========================================
   3. الصفحة الرئيسية (Hero Section)
   ========================================== */
.hero {
    padding: 100px 5% 60px;
    text-align: center;
}

.hero h1 {
    font-size: 45px;
    margin-bottom: 20px;
    color: white;
}

.hero .highlight {
    color: var(--primary);
    text-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

.main-search {
    max-width: 600px;
    margin: 40px auto;
    display: flex;
    background: var(--glass);
    padding: 8px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
}

.main-search input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px;
    color: white;
    outline: none;
}

.main-search button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
}

/* ==========================================
   4. صفحة الأرشيف (Filter & Grid)
   ========================================== */
.archive-container {
    display: flex;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    gap: 30px;
}

.smart-filter-bar {
    background: var(--glass);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    margin-bottom: 30px;
}

.filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-row select, .filter-row input, .btn-filter-apply {
    flex: 1;
    min-width: 150px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.6);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    outline: none;
}

.btn-filter-apply {
    background: var(--primary);
    border: none;
    font-weight: bold;
    cursor: pointer;
    flex: 0.5;
}

/* تقسيم المستويات */
.level-section {
    margin-bottom: 40px;
}

.level-title {
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

/* شبكة المواد */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.subject-card {
    background: var(--glass);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    transition: 0.3s;
}

.subject-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}

.subject-code {
    background: var(--primary);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    display: inline-block;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-view {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: 0.3s;
}

.btn-view:hover {
    background: var(--primary);
}

.btn-solution {
    border-color: var(--accent);
    color: var(--accent);
}

/* ==========================================
   5. صفحة تفاصيل المادة (Subject Details)
   ========================================== */
.subject-header {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    padding: 60px 20px;
    text-align: center;
    margin-bottom: 40px;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.content-section {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 25px;
    border-radius: 20px;
}

.file-list {
    list-style: none;
    margin-top: 15px;
}

.file-list li a {
    display: block;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
    border-radius: 10px;
    color: var(--accent);
    text-decoration: none;
    transition: 0.3s;
}

.file-list li a:hover {
    background: var(--primary);
    color: white;
}

/* ==========================================
   6. لوحة التحكم (Admin Panel)
   ========================================== */
.admin-grid {
    display: grid;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.setup-card, .editor-card {
    background: var(--glass);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.admin-grid input, .admin-grid select {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #0f172a;
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 10px;
}

/* ==========================================
   7. التوافق مع الشاشات (Responsiveness)
   ========================================== */

/* للهواتف (أقل من 768px) */
@media screen and (max-width: 768px) {
    .menu-toggle { display: flex; }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 260px;
        height: 100vh;
        background: #0f172a;
        flex-direction: column;
        padding-top: 100px;
        transition: 0.4s;
        z-index: 1001;
    }

    .nav-links.active { right: 0; }

    .nav-overlay {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.7);
        display: none;
        z-index: 1000;
    }
    .nav-overlay.active { display: block; }

    .hero h1 { font-size: 30px; }
    
    .archive-container, .admin-grid {
        flex-direction: column;
        display: block;
    }

    .filter-row { flex-direction: column; }
    
    .level-grid, .content-grid {
        grid-template-columns: 1fr;
    }

    .setup-card { margin-bottom: 30px; }
}

/* للآيباد (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .level-grid { grid-template-columns: 1fr 1fr; }
    .hero h1 { font-size: 38px; }
}

/* حالة فارغة */
.empty-state {
    text-align: center;
    padding: 50px;
    color: var(--text-muted);
    border: 2px dashed var(--glass-border);
    border-radius: 20px;
    grid-column: 1 / -1;
}
/* ==========================================
   تنسيق قسم الخدمات (Cards Section)
   ========================================== */

.features {
    padding: 80px 10%;
    background: transparent;
}

.section-title {
    text-align: center;
    margin-bottom: 60px;
}

.section-title h2 {
    font-size: 32px;
    color: #fff;
    margin-bottom: 15px;
}

.section-title p {
    color: var(--text-muted);
    font-size: 18px;
}

/* شبكة البطاقات - Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

/* تصميم البطاقة الفردية */
.card {
    background: var(--glass); /* تأثير الزجاج الشفاف */
    border: 1px solid var(--glass-border);
    padding: 40px 30px;
    border-radius: 24px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* تأثير التوهج عند الوقوف على البطاقة */
.card:hover {
    transform: translateY(-12px);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* الأيقونة داخل البطاقة */
.card-icon {
    font-size: 50px;
    margin-bottom: 25px;
    display: block;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.3));
}

/* العنوان داخل البطاقة */
.card h3 {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 15px;
}

/* النص الوصفي */
.card p {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 25px;
    flex-grow: 1; /* لجعل الأزرار متساوية المحاذاة */
}

/* الرابط/الزر داخل البطاقة */
.card a {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    padding: 10px 25px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    transition: 0.3s;
}

.card a:hover {
    background: var(--accent);
    color: var(--secondary);
    box-shadow: 0 0 15px var(--accent);
}

/* ==========================================
   توافق الشاشات (Responsive)
   ========================================== */
@media (max-width: 768px) {
    .features {
        padding: 50px 5%;
    }
    
    .cards-grid {
        grid-template-columns: 1fr; /* بطاقة واحدة في السطر للجوال */
    }
    
    .card {
        padding: 30px 20px;
    }
}


/* تنسيق النافذة المنبثقة (Modal) */
.modal {
    display: none; 
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
}

.modal-content {
    width: 95%;
    max-width: 1000px;
    height: 90vh;
    margin: 2vh auto;
    background: #020617;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 15px 20px;
    background: #0f172a;
    border-bottom: 1px solid var(--glass-border);
}

.modal-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#modal-search-input {
    flex: 1;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--primary);
    border-radius: 10px;
    color: white;
    outline: none;
}

.modal-body {
    flex: 1;
    background: white; /* لجعل صفحات التجميعات واضحة */
}

#resource-iframe {
    width: 100%;
    height: 100%;
}

.btn-close {
    background: #ef4444;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 8px;
    cursor: pointer;
}
.search-nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 5px 10px;
    border-radius: 8px;
}

#search-status {
    color: var(--accent);
    font-size: 13px;
    min-width: 40px;
    text-align: center;
}

.btn-nav {
    background: var(--primary);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.btn-nav:hover { background: var(--accent); }

/* هذه الكلاسات سيتم حقنها داخل الـ Iframe لتظليل الكلمات */
/* ملاحظة: سنضيفها برمجياً لملف الـ Iframe */
.itg-mark {
    background-color: yellow !important;
    color: black !important;
    border-radius: 2px;
}

.itg-mark-current {
    background-color: orange !important;
    box-shadow: 0 0 8px orange;
    outline: 2px solid red;
}
/* حاوية البحث الكبرى */
.modal-search-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
}

/* الحاوية التي تجعل العناصر داخل المربع */
.search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

#modal-search-input {
    width: 100%;
    padding: 12px 15px;
    padding-left: 110px; /* مساحة للأزرار جهة اليسار (إذا كان الاتجاه RTL) */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--primary);
    border-radius: 12px;
    color: white;
    outline: none;
    font-size: 15px;
}

/* موضع العناصر داخل مربع البحث */
.inner-search-controls {
    position: absolute;
    left: 10px; /* بما أن اللغة عربية، الأزرار تكون غالباً جهة اليسار */
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
}

/* عداد النتائج (0/0) */
#search-status {
    color: var(--accent);
    font-size: 12px;
    font-weight: bold;
    margin-left: 5px;
    user-select: none;
}

/* الفاصل الصغير بين العداد والأزرار */
.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    margin: 0 5px;
}

/* أزرار الأسهم الداخلية */
.btn-inner-nav {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 5px;
    transition: 0.2s;
    line-height: 1;
}

.btn-inner-nav:hover {
    color: var(--accent);
    transform: scale(1.2);
}

.btn-inner-nav:active {
    transform: scale(0.9);
}

/* زر الإغلاق الخارجي */
.btn-close {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}