/* =========================================
   تنسيق صفحة المكتبة (Library Style) - محدث للدارك مود 🌑
   ========================================= */

/* =========================================
   تنسيق القائمة الجانبية (تفتح من اليسار)
   ========================================= */

/* 1. طبقة التعتيم الخلفية */
#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;
}

/* 2. القائمة نفسها */
#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;
    box-shadow: 5px 0 15px var(--shadow-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#sidebar.active {
    left: 0;
}

/* 3. محتويات القائمة */
.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; }

/* =========================================
   تنسيق شريط التبويبات (Tabs Styling)
   ========================================= */

.tabs-container {
    display: flex;
    overflow-x: auto;
    background: var(--surface-color); /* يدعم الدارك */
    padding: 10px 15px;
    gap: 10px;
    position: sticky;
    top: 60px;
    z-index: 90;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab-item {
    white-space: nowrap;
    padding: 8px 16px;
    background: var(--bg-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    transition: 0.3s;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    user-select: none;
    border: 1px solid transparent;
}

[data-theme="dark"] .tab-item {
    border: 1px solid var(--border-color);
}

.tab-item.active {
    background: var(--primary-color);
    color: white; /* النص دائماً أبيض في النشط */
    box-shadow: 0 4px 10px rgba(0, 82, 204, 0.2);
    border-color: var(--primary-color);
}

/* =========================================
   إدارة عرض الأقسام
   ========================================= */
.lib-view {
    display: none;
    padding: 20px;
    padding-bottom: 100px;
    animation: fadeIn 0.3s ease-in-out;
}

.lib-view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   تنسيق كروت المستندات (Documents Cards)
   ========================================= */

.doc-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--surface-color); /* يدعم الدارك */
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: all 0.2s ease-in-out;
}

/* حدود خفيفة في الدارك مود */
[data-theme="dark"] .doc-card {
    border: 1px solid var(--border-color);
}

.doc-card:active, 
.doc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.05);
}

/* حاوية الأيقونة */
.doc-icon {
    width: 45px;
    height: 45px;
    min-width: 45px;
    background-color: #f0f7ff; /* أزرق فاتح */
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 20px;
}

[data-theme="dark"] .doc-icon {
    background-color: rgba(96, 165, 250, 0.15); /* شفاف في الدارك */
    color: #60a5fa;
}

/* النصوص داخل الكرت */
.doc-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dark);
}

.doc-info p {
    margin: 0;
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.4;
}

/* =========================================
   تنسيق الأسئلة الشائعة (FAQ Accordion)
   ========================================= */

.faq-item {
    background: var(--surface-color);
    border-radius: 16px;
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid transparent;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: all 0.3s ease;
}

[data-theme="dark"] .faq-item {
    border: 1px solid var(--border-color);
}

.faq-item.open {
    box-shadow: 0 8px 15px var(--shadow-color);
    border-color: var(--primary-color);
}

/* عنوان السؤال */
.faq-question {
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
    background: var(--surface-color);
    user-select: none;
}

.faq-question i {
    font-size: 16px;
    color: var(--text-light);
    transition: transform 0.3s ease;
}

.faq-item.open .faq-question i {
    transform: rotate(180deg);
    color: var(--primary-color);
}

/* منطقة الجواب */
.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-color); /* لون خلفية خفيف للجواب */
    font-size: 13px;
    color: var(--text-dark); /* النص الأساسي */
    line-height: 1.7;
    transition: max-height 0.3s ease-out, padding 0.3s ease;
}

.faq-answer ul {
    margin: 10px 0;
    padding-right: 20px;
}

.faq-answer li {
    margin-bottom: 5px;
    color: var(--text-dark);
}

.faq-item.open .faq-answer {
    padding: 15px 20px 20px 20px;
    max-height: 1000px;
    border-top: 1px solid var(--border-color);
}

/* =========================================
   تنسيق قسم الموارد الإضافية (الفريق والروابط)
   ========================================= */

/* بوكس النبذة */
.about-platform-box {
    text-align: center;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    padding: 30px 20px;
    border-radius: 20px;
    margin-bottom: 30px;
    border: 1px solid #eee;
}

/* دارك مود لبوكس النبذة */
[data-theme="dark"] .about-platform-box {
    background: linear-gradient(135deg, #1e1e1e 0%, #121212 100%);
    border: 1px solid var(--border-color);
}

.about-platform-box h3 { margin: 15px 0 10px; color: var(--primary-color); }
.about-platform-box p { font-size: 12px; color: var(--text-light); line-height: 1.6; max-width: 90%; margin: 0 auto; }

/* عناوين الأقسام */
.section-header-small h3 {
    font-size: 15px;
    color: var(--text-dark);
    margin-bottom: 15px;
    padding-right: 5px;
}

/* حاوية السحب */
.horizontal-scroll-wrapper {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 20px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.horizontal-scroll-wrapper::-webkit-scrollbar { display: none; }

/* --- 1. تنسيق كروت الفريق --- */
.team-card {
    min-width: 260px;
    background: var(--surface-color);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 5px 15px var(--shadow-color);
    border: 1px solid transparent;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    text-align: center;
}

[data-theme="dark"] .team-card {
    border: 1px solid var(--border-color);
}

/* حاوية الصورة */
.team-img-container {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    background: var(--border-color);
}

.team-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* معلومات العضو */
.team-info h4 { margin: 0 0 5px; font-size: 15px; font-weight: 800; color: var(--text-dark); }

.major-badge { 
    background: #eef4ff; 
    color: var(--primary-color); 
    padding: 4px 10px; 
    border-radius: 8px; 
    font-size: 10px; 
    font-weight: bold; 
    display: inline-block; 
    margin-bottom: 10px;
}

[data-theme="dark"] .major-badge {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.team-info p { 
    font-size: 11px; 
    color: var(--text-light); 
    line-height: 1.5; 
    margin-bottom: 15px; 
    height: 50px; 
    overflow: hidden; 
}

/* زر التواصل */
.contact-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--surface-color);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 10px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    transition: 0.2s;
}

[data-theme="dark"] .contact-btn {
    background: transparent;
}

.contact-btn:hover { background: var(--primary-color); color: white; }

/* --- 2. تنسيق روابط المصادر --- */
.links-wrapper { padding-left: 20px; }

.link-square-card {
    min-width: 110px;
    height: 110px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: white; /* النص أبيض دائماً لأن الخلفية ملونة */
    scroll-snap-align: start;
    box-shadow: 0 5px 15px var(--shadow-color);
    transition: transform 0.2s;
}

.link-square-card:active { transform: scale(0.95); }
.link-square-card i { font-size: 28px; margin-bottom: 5px; }
.link-square-card span { font-size: 11px; font-weight: 700; }

/* ألوان الكروت (Gradient) تبقى كما هي لأنها جميلة في الوضعين */
.bb-card { background: linear-gradient(135deg, #6c3483, #8e44ad); }
.edu-card { background: linear-gradient(135deg, #2980b9, #3498db); }
.jic-card { background: linear-gradient(135deg, #16a085, #1abc9c); }
.jti-card { background: linear-gradient(135deg, #d35400, #e67e22); }
.rc-card { background: linear-gradient(135deg, #2c3e50, #34495e); }

/* =========================================
   شاشة التحميل (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); }
}