/* =========================================
   📄 تنسيق الصفحات الداخلية الموحد (Posts, Pages, Services)
   ========================================= */

/* 1. التعديل هنا: إضافة .page للـ Selector */
body.single, 
body.page:not(.home):not(.page-template-page-about) { 
    /* :not عشان نستثني الرئيسية ومن نحن لو ليهم كلاسات خاصة */
    overflow-x: hidden;
    background-color: #f9f9f9;
    box-sizing: border-box;
}

/* --- 2. رأس المقالة (Hero Header) --- */
.post-header {
    position: relative;
    /* تقليل الـ padding العلوي من 140 لـ 100 أو أقل حسب رغبتك */
    padding: 100px 0 80px; 
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: #fff;
    /* تأكد إن مفيش مارجن علوي */
    margin-top: 0 !important; 
    z-index: 10;
}

.hero-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0.9));
    z-index: -1;
}

.hero-content-wrapper {
    position: relative;
    z-index: 2;
    width: 95%;
    max-width: 1200px;
}

/* النصوص الذهبية (Breadcrumbs & Meta) */
.breadcrumbs, .entry-meta, .entry-meta i, .breadcrumbs a {
    color: var(--secondary-color) !important;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    /* إضافة مسافة صغيرة عشان ميقدروش يلزقوا في العنوان */
    margin-bottom: 15px; 
    display: inline-block; /* مهم عشان المارجن يشتغل */
}

/* عنوان المقال الرئيسي */
.entry-title {
    font-size: clamp(2rem, 5vw, 4.5rem);
    color: #fff;
    font-weight: 900;
    /* زيادة المسافات فوق وتحت العنوان */
    margin: 20px 0 35px; 
    /* ⚠️ التعديل الأهم: زيادة ارتفاع السطر لمنع التداخل */
    line-height: 1.4; 
    text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
    /* قيد العنوان */
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* تنسيق خاص للميتا داتا تحت العنوان */
.entry-meta {
     margin-bottom: 0; /* إعادة ضبط المارجن للعنصر الأخير */
     margin-top: 10px; /* مسافة إضافية فوقه */
}

/* --- 3. الهيكل الرئيسي (Smart Grid) --- */
.content-container {
    max-width: 1200px;
    margin: -60px auto 60px;
    position: relative;
    z-index: 20;
    padding: 0 15px;
}

.grid-layout {
    display: grid;
    /* تثبيت العرض: المقال 75% والسايدبار 23% */
    grid-template-columns: 75% 23%;
    gap: 2%;
    align-items: flex-start; /* ضروري لعمل الـ Sticky */
    width: 100%; /* ضمان عدم التمدد */
}

/* --- 📝 منطقة المقال (اليمين) --- */
.single-article {
    background: #fff;
    padding: 60px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    border-top: 5px solid var(--secondary-color);
    /* قيد المحتوى الداخلي */
    max-width: 100%;
    overflow: hidden; 
}

/* --- 📋 السايدبار "المقيد" (اليسار) --- */
.sidebar {
    height: auto; 
    position: -webkit-sticky;
    position: sticky;
    top: 100px;
    /* أهم جزء: تحديد العرض ومنع التمدد */
    width: 100%; 
    max-width: 100%;
    min-width: 0; /* خدعة CSS لمنع الجريد من التمدد */
}

/* تنسيق الودجات الصارم */
.widget {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    border-bottom: 3px solid var(--secondary-color);
    /* 🛡️ الحماية القصوى ضد الكسر */
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* قص أي شيء يخرج */
    box-sizing: border-box;
}

.widget h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--primary-dark);
    font-weight: 700;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* --- ⛓️ قيد النصوص والروابط في السايدبار ⛓️ --- */
.sidebar ul {
    padding: 0;
    margin: 0;
    width: 100%;
}

.sidebar ul li {
    margin-bottom: 0;
    border-bottom: 1px solid #f5f5f5;
    width: 100%;
    list-style: none;
}

.sidebar ul li a, 
.widget p, 
.widget div {
    /* الإجبار على الكسر والنزول لسطر جديد */
    white-space: normal !important; /* السماح بتعدد الأسطر */
    overflow-wrap: break-word !important; /* كسر الكلمات الطويلة */
    word-break: break-word !important; /* كسر السلاسل المتصلة */
    word-wrap: break-word !important; /* دعم للمتصفحات القديمة */
    
    display: block; /* عشان ياخد العرض كامل */
    width: 100%;
    max-width: 100%;
    
    text-decoration: none;
    color: #444;
    padding: 12px 0;
    font-size: 15px;
    transition: 0.3s;
    line-height: 1.6;
}

/* الهوفر لروابط السايدبار العادية */
.sidebar ul:not(.toc-list) li a:hover {
    color: var(--secondary-color) !important;
    padding-right: 10px;
    background-color: #fcfcfc;
}

/* =========================================
   📑 تنسيق جدول المحتويات (TOC) - الإصلاح الشامل
   ========================================= */
.anadel-toc-container {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    /* 🛡️ إجبار الاتجاه يمين */
    direction: rtl !important; 
    text-align: right !important;
}

.toc-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-header h3 {
    margin: 0 !important;
    font-size: 18px !important;
    color: var(--primary-dark);
    font-weight: 700;
    border: none !important; /* إزالة الخط السفلي المكرر لو موجود */
}

/* 🛡️ إلغاء النقاط السوداء المزعجة */
.toc-list, .toc-list li {
    list-style: none !important;
    list-style-type: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.toc-list li {
    margin-bottom: 8px;
    position: relative;
    width: 100%;
}

/* 🛡️ تنسيق الروابط (إزالة الخط واللون الأزرق) */
.toc-list li a {
    text-decoration: none !important; /* إزالة الخط */
    color: #555 !important; /* لون رمادي شيك */
    font-size: 15px !important;
    display: block; /* عشان ياخد السطر كله */
    width: 100%;
    text-align: right !important; /* محاذاة يمين إجباري */
    padding: 8px 10px 8px 0;
    border-right: 3px solid transparent; /* تجهيز لخط التفعيل */
    transition: all 0.2s ease-in-out;
    background: transparent; /* إزالة أي خلفية موروثة */
}

/* تنسيق العناوين الفرعية (H3) */
.toc-list li.h3-item a { 
    margin-right: 15px !important; 
    font-size: 14px !important; 
    color: #777 !important;
}

/* 🔥 حالة التفعيل (Active) والهوفر 🔥 */
.toc-list li.active > a,
.toc-list li a:hover {
    color: var(--secondary-color) !important; /* اللون الذهبي */
    font-weight: bold;
    border-right-color: var(--secondary-color) !important;
    background: rgba(212, 175, 55, 0.05) !important; /* خلفية ذهبية خفيفة */
    padding-right: 15px !important; /* حركة بسيطة لليسار */
}

/* --- 📊 شريط التقدم --- */
.progress-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 4px;
    background: transparent; z-index: 99999;
}
.progress-bar {
    height: 4px; background: var(--secondary-color); width: 0%;
    box-shadow: 0 0 10px var(--secondary-color); transition: width 0.1s linear;
}

/* --- المحتوى الداخلي --- */
.entry-content { font-size: 20px; line-height: 1.8; color: #333; }
.entry-content h2 { color: var(--primary-dark); font-size: 30px; margin: 50px 0 20px; }

/* مقالات ذات صلة */
.related-posts {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid #eee;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.related-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    transition: 0.3s;
}

.related-card:hover img { transform: scale(1.03); }

/* --- 📱 تجاوب الموبايل --- */
@media (max-width: 992px) {
    .post-header { padding: 100px 15px 60px !important; }
    
    .grid-layout { 
        display: block !important; 
        width: 100% !important;
    }
    
    .content-container { margin-top: 0 !important; padding: 0 !important;}

    .single-article {
        padding: 30px 20px !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border-top: none !important;
    }

    .sidebar {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 30px 20px;
        margin-top: 20px;
    }
    
    .related-grid {
        grid-template-columns: 1fr !important;
    }

    /* زيادة الحماية في الموبايل */
    .sidebar ul li a {
        word-break: break-all !important; /* كسر عنيف في الموبايل لضمان عدم الخروج */
    }
}

/* ==========================================================
   📱 إصلاحات تجاوب الموبايل (Mobile Responsiveness Fixes)
   ========================================================== */

/* 1. إجبار النصوص الطويلة على النزول لسطر جديد وعدم كسر التصميم */
body, .entry-content, .entry-title, .single-content, h1, h2, h3, p, a {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    -webkit-hyphens: auto;
    hyphens: auto;
}

/* 2. منع السكرول الأفقي (اليمين واليسار) في الموبايل تماماً */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* 3. التأكد من أن الصور والفيديوهات لا تتخطى حجم الشاشة */
img, iframe, video, figure {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* 4. هوامش آمنة للموبايل (Safe Padding) */
@media (max-width: 768px) {
    .container, .single-container, .content-area {
        width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box !important;
    }
    
    /* تصغير حجم العناوين الضخمة في الموبايل */
    .entry-title, h1 {
        font-size: 1.5rem !important;
        line-height: 1.4 !important;
    }
}
/* =========================================
   🔧 إصلاحات مفقودة - Missing Styles Fix
   ========================================= */

/* حاوية الودجات الثابتة */
.sticky-widget {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ودجت الاتصال (CTA) */
.cta-widget {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    color: #fff;
    text-align: center;
    border-bottom: 3px solid var(--secondary-color) !important;
}
.cta-widget h3 { color: #fff !important; border-color: rgba(255,255,255,0.2) !important; }
.cta-widget p  { color: rgba(255,255,255,0.85) !important; font-size: 14px; margin-bottom: 15px; }
.cta-widget .btn-main {
    background: var(--secondary-color) !important;
    color: #fff !important;
    font-weight: 700;
    border-radius: var(--btn-radius);
    padding: 12px 20px;
    display: block;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
}
.cta-widget .btn-main:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }

/* مساعدات عامة */
.w-100 { width: 100%; }
.text-center { text-align: center; }

/* عنوان قسم المواضيع المشابهة */
.related-posts .section-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--secondary-color);
}

/* بطاقة المقال المشابه */
.related-card {
    display: block;
    text-decoration: none;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #eee;
    transition: var(--transition);
    background: #fff;
}
.related-card:hover { border-color: var(--secondary-color); transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.related-card h4 { font-size: 14px; color: var(--primary-dark); font-weight: 600; line-height: 1.5; margin: 0; padding: 12px; }
