/* =========================================
   GLOBAL TECH BLOG THEME (2026 Standard)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&family=Inter:wght@400;500;600&display=swap');

:root {
    /* ألوان عالمية (Slate Palette) */
    --bg-body: #0f1117;       /* خلفية الصفحة */
    --bg-card: #161b22;       /* خلفية الكروت */
    --bg-input: #0d1117;      /* خلفية البحث */
    --border: #30363d;        /* حدود ناعمة جداً */
    --text-primary: #f0f6fc;  /* أبيض مريح */
    --text-secondary: #8b949e;/* رمادي للنصوص الثانوية */
    --accent: #58a6ff;        /* أزرق عالمي (Github Blue) */
    --accent-hover: #1f6feb;
    
    --font-main: 'Cairo', sans-serif; /* خط القراءة العربي */
    --font-num: 'Inter', sans-serif;  /* للأرقام */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.7;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }

/* --- Navbar (Minimal) --- */
.blog-nav {
    border-bottom: 1px solid var(--border);
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-logo img { height: 35px; }
.nav-home-link {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex; align-items: center; gap: 5px;
}
.nav-home-link:hover { color: var(--accent); }

/* --- Layout Container (Main + Sidebar) --- */
.blog-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 2.5fr 1fr; /* المحتوى يأخذ 70% والسايدبار 30% */
    gap: 40px;
}

/* --- Featured Post (المقال الرئيسي الكبير) --- */
.featured-post {
    grid-column: 1 / -1; /* يمتد على كامل العرض */
    margin-bottom: 40px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.feat-img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    opacity: 0.8;
    transition: 0.3s;
}

.featured-post:hover .feat-img { opacity: 1; transform: scale(1.02); }

.feat-content {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    padding: 40px;
    background: linear-gradient(to top, #0f1117 10%, transparent);
}

.tag {
    background: var(--accent);
    color: #000;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    font-family: var(--font-num);
}

.feat-title {
    font-size: 2.5rem;
    margin: 10px 0;
    line-height: 1.2;
}

/* --- Main Content Area --- */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Standard Post Card (Horizontal) */
.post-card {
    display: flex;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    height: 220px;
    transition: 0.3s;
}

.post-card:hover {
    border-color: var(--text-secondary);
    transform: translateY(-2px);
}

.post-thumb {
    width: 35%;
    height: 100%;
    object-fit: cover;
}

.post-info {
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 65%;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    gap: 15px;
    font-family: var(--font-num);
}

.post-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.4;
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Sidebar (للقوائم الطويلة) --- */
.sidebar {
    position: sticky;
    top: 90px; /* يثبت لما تنزل */
    height: fit-content;
}

/* Search Widget */
.widget {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border);
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 12px 40px 12px 15px;
    border-radius: 6px;
    color: white;
    font-family: inherit;
    transition: 0.3s;
}

.search-box input:focus {
    border-color: var(--accent);
    outline: none;
}

.search-box i {
    position: absolute;
    left: 15px; /* RTL */
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Categories List (Scalable) */
.widget h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    border-right: 3px solid var(--accent);
    padding-right: 10px;
}

.cat-list {
    max-height: 300px; /* لو القائمة طويلة جداً */
    overflow-y: auto;  /* بيطلع سكرول داخلي */
    padding-left: 10px;
}

/* ستايل السكرول بار للقائمة */
.cat-list::-webkit-scrollbar { width: 4px; }
.cat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.02);
    cursor: pointer;
    font-size: 0.95rem;
}

.cat-item:hover { color: var(--accent); padding-right: 5px; }
.cat-count { font-family: var(--font-num); font-size: 0.8rem; background: var(--border); padding: 2px 8px; border-radius: 10px; }

/* Newsletter Widget */
.newsletter-widget {
    background: rgba(88, 166, 255, 0.1);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid rgba(88, 166, 255, 0.2);
    text-align: center;
}

.newsletter-widget h4 { color: var(--accent); margin-bottom: 10px; }
.newsletter-widget p { font-size: 0.9rem; margin-bottom: 15px; color: var(--text-secondary); }
.news-btn { width: 100%; padding: 10px; background: var(--accent); border: none; border-radius: 6px; font-weight: 700; cursor: pointer; }

/* --- Mobile --- */
@media (max-width: 900px) {
    .blog-container {
        grid-template-columns: 1fr; /* عمود واحد */
    }
    
    .sidebar { position: static; order: 2; } /* السايدبار ينزل تحت المحتوى */
    
    .post-card {
        flex-direction: column;
        height: auto;
    }
    
    .post-thumb { width: 100%; height: 200px; }
    .post-info { width: 100%; }
    
    .feat-title { font-size: 1.8rem; }

    /* =========================================
       FEATURED POST MOBILE FIX (Magazine Style)
       ========================================= */
    
    /* جعل الكرت طويل وفخم */
    .featured-post {
        height: 450px !important; /* ارتفاع ثابت وكبير */
        border: 1px solid var(--accent); /* حدود زرقاء لتمييزه */
        box-shadow: 0 10px 40px rgba(0, 210, 255, 0.15); /* توهج خفيف */
        position: relative;
        margin-bottom: 40px; /* مسافة عن اللي تحته */
    }

    /* الصورة تغطي الكرت بالكامل */
    .featured-post .feat-img {
        height: 100%;
        width: 100%;
        object-fit: cover;
        opacity: 1; /* صورة واضحة */
    }

    /* تحسين خلفية النص لتكون مقروءة فوق الصورة */
    .feat-content {
        background: linear-gradient(
            to top, 
            #0f1117 10%, 
            rgba(15, 17, 23, 0.8) 50%, 
            transparent 100%
        );
        padding: 30px 20px 20px;
        bottom: 0;
    }

    /* تكبير العنوان */
    .feat-title {
        font-size: 1.8rem; /* أكبر من باقي المقالات */
        margin-bottom: 10px;
        line-height: 1.3;
    }

    /* إظهار التاج بشكل واضح */
    .featured-post .tag {
        position: absolute;
        top: 2px;
        right: 20px;
        background: var(--accent);
        color: black;
        padding: 6px 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }
}


/* =========================================
   PRO ARTICLE LAYOUT (MAGAZINE STYLE)
   ========================================= */

/* 1. Full Width Hero (العنوان والصورة بالعرض الكامل) */
.article-hero-section {
    grid-column: 1 / -1; /* يمتد على كل الأعمدة */
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 40px;
}

.article-hero-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--accent);
    font-family: var(--font-num);
}

.article-big-title {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    line-height: 1.2;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.article-cover-img {
    width: 100%;
    height: 500px; /* ارتفاع فخم */
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* 2. Content Layout (Grid) */
/* نستخدم نفس الـ blog-container بس بنعدل التوزيع */
.article-layout {
    display: grid;
    grid-template-columns: 2.5fr 1fr; /* المحتوى أعرض من السايدبار */
    gap: 60px;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 5%;
}

/* 3. The Content (Typography) */
.article-content {
    font-size: 1.2rem; /* خط كبير ومقروء */
    color: #e6edf3; /* أبيض مريح (مش ساطع) */
    line-height: 1.8;
}

.article-content h2 {
    font-size: 2rem;
    margin: 50px 0 20px;
    color: var(--text-primary);
    position: relative;
}

.article-content h2::after {
    content: '#';
    color: var(--accent);
    opacity: 0.5;
    margin-right: 10px;
    font-size: 1.5rem;
}

.article-content p { margin-bottom: 25px; }

.article-content ul {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px 40px 30px 20px;
    margin-bottom: 30px;
}

.article-content li { margin-bottom: 10px; list-style-type: square; marker-color: var(--accent); }

/* Highlight Box */
.highlight-box {
    background: linear-gradient(to right, rgba(88, 166, 255, 0.1), transparent);
    border-right: 4px solid var(--accent);
    padding: 20px;
    margin: 30px 0;
    font-style: italic;
    color: white;
}

/* 4. Sticky Sidebar (تعبئة الفراغ) */
.article-sidebar {
    position: sticky;
    top: 100px; /* يثبت لما تنزل */
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Table of Contents */
.toc-widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
}

.toc-widget h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toc-widget-s {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
}

.toc-widget-s h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.toc-list li {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.toc-list a {
    color: var(--text-primary);
    opacity: 0.8;
    display: block;
    padding-right: 10px;
    border-right: 2px solid transparent;
}

.toc-list a:hover {
    color: var(--accent);
    border-right-color: var(--accent);
    opacity: 1;
}

/* Share Buttons */
.share-widget {
    display: flex;
    gap: 10px;
}

.share-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-primary);
    transition: 0.3s;
}

.share-icon:hover {
    background: var(--accent);
    color: black;
    transform: translateY(-3px);
}

/* Mobile */
@media (max-width: 900px) {
    .article-layout { grid-template-columns: 1fr; }
    .article-sidebar { position: static; margin-top: 50px; }
    .article-big-title { font-size: 2rem; }
    .article-cover-img { height: 300px; }
}


/* =========================================
   GLOBAL FOOTER FIX (DESKTOP + MOBILE)
   ========================================= */

.blog-footer {
    margin-top: 120px;              /* يفصل الفوتر عن المحتوى */
    padding: 50px 20px;
    border-top: 1px solid var(--border);
    background: linear-gradient(
        to top,
        #0b0d12 0%,
        #0f1117 60%
    );
    text-align: center;
}

.blog-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: var(--font-num);
    letter-spacing: 0.5px;
}

/* === Article Page Specific Fix === */
.article-layout + .blog-footer {
    margin-top: 140px;
}


/* =========================================
   MOBILE ORDER FIX (Table of Contents First)
   ========================================= */
@media (max-width: 900px) {
    
    .article-layout {
        /* تحويل الصفحة لعمود واحد مرن */
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* 1. العنوان والصورة (الترتيب الأول) */
    .article-hero-section {
        order: 1;
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid var(--border);
    }

    /* 
       2. تفكيك السايدبار (الخدعة السحرية) 
       هذا السطر بيخلي السايدبار يختفي كـ "صندوق" 
       ويسمح للعناصر اللي جواته تترتب بحرية مع باقي الصفحة
    */
    .article-sidebar {
        display: contents;
    }

    /* 3. فهرس المحتويات (الترتيب الثاني - تحت الصورة) */
    .toc-widget {
        order: 2; 
        margin-bottom: 40px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--accent); /* تمييز بسيط */
    }

    /* 4. نص المقال (الترتيب الثالث) */
    .article-content {
        order: 3;
        margin-bottom: 50px;
    }

    /* 5. باقي عناصر السايدبار (الترتيب الأخير - تحت المقال) */
    .toc-widget-s,          /* صندوق المشاركة */
    .newsletter-widget {    /* صندوق الإعلان */
        order: 4; 
        margin-bottom: 30px;
    }

    /* تحسينات عامة للموبايل */
    .article-big-title { font-size: 1.8rem; }
    .article-cover-img { height: 250px; }
}


/* =========================================
   PREMIUM CTA BUTTON
   ========================================= */

.cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 14px 36px;
    margin-top: 10px;

    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    font-weight: 700;

    color: #c0c3cb;
    background: linear-gradient(
        135deg,
        var(--accent),
        var(--accent-hover)
    );

    border-radius: 14px;
    border: none;
    text-decoration: none;

    box-shadow:
        0 10px 30px rgba(88, 166, 255, 0.25),
        inset 0 -2px 0 rgba(0,0,0,0.15);

    position: relative;
    overflow: hidden;

    transition: all 0.35s ease;
}

/* Hover */
.cta-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 15px 45px rgba(88, 166, 255, 0.45);
    color: #041e2d;
}

/* Active (click) */
.cta-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow:
        0 6px 20px rgba(88, 166, 255, 0.3);
}

/* Subtle Shine Effect */
.cta-btn::before {
    content: '';
    position: absolute;
    top: 0;
    right: -120%;
    width: 120%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255,255,255,0.4),
        transparent
    );
    transition: 0.6s;
}

.cta-btn:hover::before {
    right: 120%;
}

/* Mobile Enhancement */
@media (max-width: 600px) {
    .cta-btn {
        width: 100%;
        padding: 16px;
        font-size: 1.05rem;
        border-radius: 12px;
    }
}


/* --- Navbar Menu --- */
.nav-menu {
    display: flex;
    gap: 30px;
    align-items: center;
    list-style: none;
}

.nav-menu a {
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: 0.3s;
    position: relative;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--accent);
}

/* خط صغير تحت العنصر النشط */
.nav-menu a::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: 0.3s;
}

.nav-menu a:hover::after,
.nav-menu a.active::after {
    width: 100%;
}

/* زر CTA */
.nav-cta {
    background: var(--accent);
    color: #000 !important;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 700;
}

.nav-cta:hover {
    background: var(--accent-hover);
}

/* Mobile Toggle */
.nav-toggle {
    display: none;
    font-size: 1.4rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* --- Mobile --- */
@media (max-width: 900px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        right: 0;
        width: 100%;
        background: var(--bg-body);
        flex-direction: column;
        gap: 25px;
        padding: 30px 0;
        display: none;
        border-top: 1px solid var(--border);
    }

    .nav-menu.show {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }
}

/* =========================================
   MOBILE ORDER FIX (BLOG HOME)
   ========================================= */
@media (max-width: 900px) {
    
    .blog-container {
        /* تحويل الحاوية لنظام مرن (Flex) عمودي */
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* 1. تفكيك السايدبار (عشان نقدر نتحكم بعناصره كل واحد لحال) */
    .sidebar {
        display: contents;
    }

    /* 2. البحث والتصنيفات (يظهروا أول شي فوق) */
    .widget {
        order: 1; /* الترتيب الأول */
        margin-bottom: 20px;
        background: rgba(255, 255, 255, 0.03); /* تمييز خفيف */
        padding: 20px;
        border-radius: 12px;
        border: 1px solid var(--border);
    }

    /* 3. المقال المميز (تحتهم) */
    .featured-post {
        order: 2; /* الترتيب الثاني */
        margin-bottom: 30px;
    }

    /* 4. قائمة المقالات (تحتهم) */
    .posts-list {
        order: 3; /* الترتيب الثالث */
        margin-bottom: 40px;
    }

    /* 5. النشرة البريدية (تنزل لآخر الصفحة) */
    .newsletter-widget {
        order: 4; /* الترتيب الرابع والأخير */
        margin-bottom: 30px;
    }
}

/* --- ستايل السهم (مخفي في الديسكتوب) --- */
.arrow-icon {
    display: none;
}

.cat-toggle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: default;
}

/* =========================================
   MOBILE CATEGORY TOGGLE (Accordion)
   ========================================= */
@media (max-width: 900px) {
    
    /* إظهار السهم في الموبايل */
    .arrow-icon {
        display: block;
        transition: 0.3s;
        font-size: 0.9rem;
    }

    .cat-toggle-header {
        cursor: pointer; /* جعل العنوان قابل للضغط */
        margin-bottom: 0 !important; /* إلغاء المسافة السفلية عند الإغلاق */
    }

    /* إخفاء القائمة افتراضياً */
    .cat-list {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-out;
        padding-left: 0; /* إلغاء البادينغ */
    }

    /* كلاس التفعيل (عند الفتح) */
    .cat-widget-box.open .cat-list {
        max-height: 400px; /* ارتفاع كافي للمحتوى */
        margin-top: 15px; /* مسافة بعد الفتح */
    }

    /* تدوير السهم عند الفتح */
    .cat-widget-box.open .arrow-icon {
        transform: rotate(180deg);
        color: var(--accent);
    }
}

.blog-main-title {
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.25;
    color: #f8fafc;
    margin: 40px auto 32px auto; /* نزول من فوق */
    max-width: 900px;
    letter-spacing: -0.3px;
}

@media (max-width: 768px) {
    .blog-main-title {
        font-size: 28px;
        line-height: 1.35;
        margin-top: 32px;
        padding: 0 16px;
    }
}


/* تنسيق الموبايل: التاريخ والوقت بجانب بعض + شكل أنيق */
@media (max-width: 768px) {
    
    .article-hero-meta {
        display: flex;
        flex-wrap: wrap;       /* يسمح للعناصر بالترتيب المرن */
        justify-content: center; /* توسيط كل شيء */
        align-items: center;
        gap: 10px;             /* مسافة بين العناصر */
        margin-bottom: 25px;
    }

    /* 1. التصنيف (أول عنصر): نجعله في سطر لوحده في الأعلى */
    .article-hero-meta span:first-child {
        flex-basis: 100%;      /* يأخذ عرض السطر كامل ليكون في الأعلى */
        text-align: center;
        color: var(--accent, #007bff);
        background: rgba(0, 123, 255, 0.1); /* خلفية زرقاء خفيفة جداً */
        padding: 5px 15px;
        border-radius: 20px;   /* حواف دائرية */
        font-weight: bold;
        font-size: 0.85rem;
        width: fit-content;    /* العرض على قد الكلام فقط */
        margin: 0 auto 5px auto; /* توسيطه ومسافة تحته */
    }

    /* 2. إخفاء الفواصل القديمة (النقاط) */
    .article-hero-meta span:nth-child(2),
    .article-hero-meta span:nth-child(4) {
        display: none;
    }

    /* 3. تنسيق التاريخ ووقت القراءة (ليكونوا بجانب بعض) */
    .article-hero-meta span:nth-child(3), /* وقت القراءة */
    .article-hero-meta span:nth-child(5) { /* التاريخ */
        color: #ccc;           /* لون فضي */
        font-size: 0.9rem;
        font-weight: 500;
    }

    /* 4. إضافة خط فاصل أنيق بين التاريخ والوقت بالكود */
    /* نضع الفاصل بعد "وقت القراءة" */
    .article-hero-meta span:nth-child(3)::after {
        content: "|";          /* خط عمودي */
        margin-right: 10px;    /* مسافة يمين */
        margin-left: 10px;     /* مسافة يسار */
        color: #555;           /* لون غامق قليلاً */
        font-weight: normal;
    }

    /* 5. آخر تحديث: في سطر لوحده في الأسفل مع خط فاصل */
    .article-hero-meta span:last-child {
        flex-basis: 100%;      /* سطر جديد كامل */
        text-align: center;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.1); /* خط رفيع فوقه */
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.6);
    }
    
    .article-hero-meta span:last-child i {
        color: #4caf50; /* لون الأيقونة أخضر */
        margin-left: 5px;
    }
}