/* =========================================
   تنسيق صفحة الأخبار (News Page) - محدث للدارك مود 🌑
   ========================================= */

/* توحيد الخط */
body, input, h1, h2, h3, p, span, div {
    font-family: 'Tajawal', sans-serif !important;
}

/* =========================================
   1. تنسيق شبكة الأخبار (News Grid)
   ========================================= */
.news-filter-container {
    padding: 10px 20px;
    background: var(--surface-color); /* يدعم الدارك */
    position: sticky;
    top: 60px;
    z-index: 80;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: background 0.3s ease;
}

.search-box {
    display: flex; 
    align-items: center; 
    gap: 10px;
    background: var(--bg-color); /* لون الخلفية عشان يتباين مع السطح */
    padding: 10px 15px; 
    border-radius: 12px;
    border: 1px solid transparent;
    transition: 0.3s;
}

/* تحسين السيرش بوكس في الدارك مود */
[data-theme="dark"] .search-box {
    border: 1px solid var(--border-color);
}

.search-box i {
    color: var(--text-light);
}

.search-box input {
    border: none; 
    background: transparent; 
    width: 100%;
    font-family: 'Tajawal'; 
    outline: none;
    color: var(--text-dark); /* النص يتغير لونه */
    font-size: 14px;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

.news-feed-container { 
    padding: 20px; 
    padding-bottom: 100px; 
}

/* =========================================
   2. كرت الخبر (Blog Card)
   ========================================= */
.blog-card {
    display: block;
    background: var(--surface-color); /* يدعم الدارك */
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px var(--shadow-color);
    text-decoration: none; 
    color: inherit;
    border: 1px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* حدود خفيفة في الدارك مود */
[data-theme="dark"] .blog-card {
    border: 1px solid var(--border-color);
}

.blog-card:active { transform: scale(0.98); }

.blog-img-wrapper {
    width: 100%; 
    height: 180px; 
    position: relative; 
    background-color: var(--border-color); /* لون تحميل الصورة */
}

.blog-img-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

.blog-category-badge {
    position: absolute; 
    top: 15px; 
    right: 15px;
    background: rgba(255, 255, 255, 0.95); 
    color: var(--primary-color);
    padding: 5px 12px; 
    border-radius: 20px; 
    font-size: 11px; 
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* تعديل بادج التصنيف في الدارك مود */
[data-theme="dark"] .blog-category-badge {
    background: rgba(30, 30, 30, 0.9);
    color: #60a5fa;
    border: 1px solid rgba(255,255,255,0.1);
}

.blog-content { padding: 15px; }

.blog-date { 
    font-size: 11px; 
    color: var(--text-light); 
    margin-bottom: 5px; 
    display: flex;
    align-items: center;
    gap: 5px;
}

.blog-title { 
    font-size: 15px; 
    font-weight: 800; 
    color: var(--text-dark); /* النص يتغير */
    line-height: 1.5; 
    margin: 0 0 8px 0; 
}

.blog-excerpt { 
    font-size: 12px; 
    color: var(--text-light); /* النص الثانوي */
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    line-height: 1.6;
}

/* =========================================
   3. تنسيق صفحة عرض المقال (Article Content)
   ========================================= */
.article-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px 20px; 
    background: var(--surface-color); /* هيدر المقال */
    position: sticky; 
    top: 0; 
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.3s ease;
}

.back-btn {
    font-size: 24px; 
    color: var(--text-dark); /* زر الرجوع */
    text-decoration: none; 
    display: flex;
    padding: 5px;
    border-radius: 50%;
    transition: 0.2s;
}

.back-btn:active {
    background: var(--bg-color);
}

.article-content-wrapper {
    padding: 20px;
    animation: fadeIn 0.4s ease;
    background-color: var(--bg-color); /* خلفية الصفحة كاملة */
    min-height: 100vh;
}

/* صورة المقال الكبيرة */
.article-main-image {
    width: 100%; 
    height: auto; 
    border-radius: 16px; 
    margin-bottom: 20px;
    box-shadow: 0 5px 15px var(--shadow-color);
    background-color: var(--border-color);
}

/* معلومات المقال */
.article-meta { 
    color: var(--text-light); 
    font-size: 12px; 
    margin-bottom: 15px; 
    display: flex; 
    gap: 10px; 
}

.article-badge { 
    color: var(--primary-color); 
    font-weight: bold; 
    background: #eef4ff; 
    padding: 2px 8px; 
    border-radius: 6px; 
}

[data-theme="dark"] .article-badge {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

/* تنسيق جسم المقال (Typography) */
.article-body h1 { 
    font-size: 20px; 
    font-weight: 800; 
    margin-bottom: 15px; 
    line-height: 1.4; 
    color: var(--text-dark); /* العناوين */
}

.article-body p { 
    font-size: 14px; 
    line-height: 1.8; 
    color: var(--text-dark); /* نص المقال الأساسي */
    margin-bottom: 15px; 
    opacity: 0.9; /* تخفيف بسيط للحدة */
}

.article-body ul { 
    padding-right: 20px; 
    margin-bottom: 15px; 
}

.article-body li { 
    margin-bottom: 5px; 
    color: var(--text-dark); 
    font-size: 14px; 
}

.article-body a { 
    color: var(--primary-color); 
    font-weight: bold; 
    text-decoration: none; 
}

/* تحسين الصور داخل المقال لو وجدت */
.article-body img {
    max-width: 100%;
    border-radius: 12px;
    margin: 10px 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   شاشة التحميل (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); }
}