/* =========================================================
   header.css — الهيدر الكامل الموحد
   جميع الخطوط والأحجام تتبع المتغيرات الديناميكية من header.php:
   --font-ui-scale / --font-heading-scale / --font-ui-ar / --font-heading-ar
   ========================================================= */

/* =========================================================
   1) الهيكل العام
   ========================================================= */
.site-header {
    position: relative;
    z-index: 100;
    box-shadow: 0 4px 18px rgba(0,0,0,.08);
    background: #01579b;
}

.header-top {
    background: #01579b;
    color: #fff;
    padding: 12px 0 10px;
    position: relative;
}

.header-top::before {
    content: "";
    position: absolute;
    top: 0; right: 0; left: 0;
    height: 4px;
    background: linear-gradient(90deg, #ffb74d, #4facfe);
}

/* ---------- الصف الأول (همبرغر | شعار | بحث) ---------- */
.header-top-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 18px;
}

.header-left   { display: flex; justify-content: flex-start; }
.header-center { display: flex; justify-content: center; }
.header-right  { display: flex; justify-content: flex-end; }

.site-logo {
    height: 65px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
}

/* ---------- زر الهامبرغر ---------- */
.mobile-nav-toggle {
    width: 50px; height: 50px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,.12);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .25s, transform .25s;
}
.mobile-nav-toggle:hover  { background: rgba(255,255,255,.22); }
.mobile-nav-toggle:active { transform: scale(.96); }

.hamburger-box {
    display: flex; flex-direction: column; gap: 5px;
    width: 24px; height: 18px;
    justify-content: center; align-items: center;
}
.hamburger-line {
    display: block;
    width: 100%; height: 2px;
    background-color: #fff;
    transition: all .3s ease;
    border-radius: 1px;
}
.mobile-nav-toggle.open .hamburger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-nav-toggle.open .hamburger-line:nth-child(2) { opacity: 0; }
.mobile-nav-toggle.open .hamburger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- زر أيقونة البحث ---------- */
.search-toggle-btn {
    width: 50px; height: 50px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,.12);
    color: #fff;
    cursor: pointer;
    font-size: calc(1.15rem * var(--font-ui-scale, 1));
    display: flex; align-items: center; justify-content: center;
    transition: background .25s, transform .25s;
}
.search-toggle-btn:hover  { background: rgba(255,255,255,.22); }
.search-toggle-btn:active { transform: scale(.96); }
.search-toggle-btn.active {
    background: linear-gradient(135deg, #ffd27a, #00b0c7);
    color: #014978;
}

/* =========================================================
   2) لوحة البحث المنبثقة
   ========================================================= */
.search-panel {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #01579b;
    padding: 14px 0;
    border-top: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 12px 28px rgba(0,0,0,.25);
    display: none;
    z-index: 999;
    animation: searchSlideIn .22s ease-out;
}
.search-panel.open { display: block; }

@keyframes searchSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.search-box-wrap {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
}
.header-search-form { position: relative; width: 100%; }

.header-search-input {
    width: 100%;
    border: 1px solid rgba(255,255,255,.2);
    background: #fff;
    color: #0a384b;
    border-radius: 999px;
    padding: 13px 100px 13px 18px;
    font-size: calc(1rem * var(--font-ui-scale, 1));
    outline: none;
    transition: all .3s;
    box-shadow: inset 0 2px 8px rgba(1,73,120,.08);
}
.header-search-input:focus {
    border-color: #ffd27a;
    box-shadow: 0 0 0 4px rgba(255,210,122,.25);
}

.header-search-btn {
    position: absolute;
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px; height: 38px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd27a, #00b0c7);
    color: #014978;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(1.05rem * var(--font-ui-scale, 1));
    transition: all .3s;
}
.header-search-btn:hover { transform: translateY(-50%) scale(1.06); }

.search-close-btn {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(1rem * var(--font-ui-scale, 1));
    transition: background .25s;
}
.search-close-btn:hover { background: #cbd5e1; }

/* =========================================================
   3) نتائج البحث المنسدلة
   ========================================================= */
.search-results-box {
    position: absolute;
    top: calc(100% + 6px);
    right: 16px; left: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    border: 1px solid #e2e8f0;
    z-index: 10050;
    display: none;
    max-height: 70vh;
    overflow-y: auto;
    direction: rtl;
    text-align: right;
}
.search-results-box.active { display: block; }

.search-results-header {
    padding: 10px 14px;
    border-bottom: 1px solid #eef2f7;
    background: #f8fbfe;
    font-weight: 800;
    color: #475569;
    font-size: calc(0.85rem * var(--font-heading-scale, 1));
    letter-spacing: 0;
}

.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: #0f172a;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    width: 100%;
    text-align: right;
    font-family: inherit;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    box-sizing: border-box;
}
.search-result-item:hover { background: #f0f9ff; }

.search-result-icon {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(1rem * var(--font-ui-scale, 1));
    color: #fff;
    background: #64748b;
}
.search-result-icon.type-imam     { background: #0ea5e9; }
.search-result-icon.type-topic    { background: #8b5cf6; }
.search-result-icon.type-dialogue { background: #f59e0b; }
.search-result-icon.type-fatwa    { background: #10b981; }
.search-result-icon.type-book     { background: #3b82f6; }
.search-result-icon.type-research { background: #6366f1; }
.search-result-icon.type-video    { background: #ef4444; }
.search-result-icon.type-audio    { background: #14b8a6; }
.search-result-icon.type-post     { background: #64748b; }
.search-result-icon.type-news     { background: #84cc16; }
.search-result-icon.type-scholar  { background: #a855f7; }

.search-result-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.search-result-title {
    font-weight: 700;
    font-size: calc(0.95rem * var(--font-heading-scale, 1));
    color: #0f172a;
    line-height: 1.5;
    letter-spacing: 0;
}
.search-result-title mark { background: #fef08a; color: #713f12; padding: 0 2px; border-radius: 3px; }

.search-result-meta {
    font-size: calc(0.8rem * var(--font-heading-scale, 1));
    color: #64748b;
    margin-top: 3px;
    letter-spacing: 0;
}
.search-result-type-badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
    font-size: calc(0.75rem * var(--font-heading-scale, 1));
}
.search-result-excerpt {
    font-size: calc(0.85rem * var(--font-heading-scale, 1));
    color: #64748b;
    line-height: 1.55;
    margin-top: 4px;
    letter-spacing: 0;
}
.search-result-excerpt mark { background: #fef08a; color: #713f12; padding: 0 2px; border-radius: 3px; }

.search-result-footer {
    display: block;
    padding: 11px 14px;
    text-align: center;
    background: #f8fbfe;
    color: #1d4ed8;
    font-weight: 800;
    font-size: calc(0.88rem * var(--font-heading-scale, 1));
    text-decoration: none;
    border-top: 1px solid #eef2f7;
}
.search-result-footer:hover { background: #eff6ff; }

.search-result-empty,
.search-result-error,
.search-result-loading {
    padding: 18px 14px;
    text-align: center;
    color: #64748b;
    font-size: calc(0.9rem * var(--font-heading-scale, 1));
    letter-spacing: 0;
}
.search-result-error { color: #dc2626; }

.loading-spinner { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================================
   4) الصف الثاني (اللغة | التاريخ | الترحيب)
   ========================================================= */
.header-bottom-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.hb-lang    { display: flex; justify-content: flex-start; }
.hb-date    { display: flex; justify-content: center; }
.hb-welcome { display: flex; justify-content: flex-end; }

.header-meta-badge {
    background: rgba(255,255,255,.12);
    color: #fff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: calc(0.95rem * var(--font-heading-scale, 1));
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,.1);
    transition: background .25s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    letter-spacing: 0;
    line-height: 1.4;
}
.header-meta-badge:hover { background: rgba(255,255,255,.22); }

.date-badge {
    background: #fff;
    color: #01579b;
    box-shadow: 0 4px 14px rgba(0,0,0,.15);
    font-weight: 800;
    padding: 10px 22px;
}
.date-badge:hover { background: #fff; }

.lang-badge {
    background: rgba(150, 200, 255, .22);
    color: #e0f2fe;
    font-weight: 800;
}
.lang-badge:hover {
    background: rgba(150, 200, 255, .4);
    color: #fff;
}

/* =========================================================
   5) الماركي (شريط الأخبار)
   ========================================================= */
.marquee-container {
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 10px;
    background: #01579b;
}

/* =========================================================
   6) القائمة الرئيسية (ديسكتوب)
   ========================================================= */
.main-nav {
    background: #01579b;
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, #ffb74d, #4facfe) 1;
}

.desktop-nav {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.desktop-nav > li {
    position: relative;
    flex: 1 1 auto;
    min-width: 130px;
}

.desktop-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 58px;
    padding: 12px 14px;
    color: #fff;
    font-weight: 800;
    font-size: calc(1rem * var(--font-heading-scale, 1));
    text-decoration: none;
    text-align: center;
    transition: background .25s, color .25s;
    white-space: nowrap;
    letter-spacing: 0;
    line-height: 1.4;
}

.desktop-nav .nav-link:hover,
.desktop-nav .nav-link.active {
    background: #fff;
    color: #014978;
}

/* القوائم المنسدلة */
.desktop-nav .has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.desktop-nav .dropdown-menu {
    list-style: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 260px;
    margin: 0;
    padding: 0;
    background: #fff;
    border-radius: 0 0 16px 16px;
    border: 1px solid #e2e8f0;
    border-top: 3px solid #ffb74d;
    box-shadow: 0 15px 35px rgba(0,0,0,.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all .25s ease;
    overflow: hidden;
    z-index: 150;
}

.desktop-nav .dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    color: #0f172a;
    font-weight: 700;
    font-size: calc(0.98rem * var(--font-heading-scale, 1));
    text-decoration: none;
    border-bottom: 1px solid #eef2f7;
    transition: background .2s;
    letter-spacing: 0;
    line-height: 1.5;
}
.desktop-nav .dropdown-menu li:last-child a { border-bottom: none; }
.desktop-nav .dropdown-menu a:hover {
    background: #f8fbfe;
    color: #014978;
}

/* =========================================================
   7) قائمة الجوال
   ========================================================= */
.mobile-nav-menu {
    display: none;
    background: #01457a;
    max-height: 80vh;
    overflow-y: auto;
}
.mobile-nav-menu.open { display: block; }

.mobile-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.mobile-nav-item {
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.mobile-nav-link,
.mobile-submenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px;
    color: #fff;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-heading-ar, sans-serif);
    font-size: calc(1.02rem * var(--font-heading-scale, 1));
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.5;
    text-align: right;
}
.mobile-nav-link:hover,
.mobile-submenu-toggle:hover { background: rgba(255,255,255,.1); }

.mobile-nav-link.active,
.mobile-submenu-toggle.active {
    background: rgba(255,255,255,.15);
    font-weight: 800;
}

.mobile-submenu {
    display: none;
    background: rgba(0,0,0,.2);
}
.mobile-submenu.open { display: block; }

.mobile-submenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    color: #fff;
    text-decoration: none;
    font-family: var(--font-heading-ar, sans-serif);
    font-size: calc(0.98rem * var(--font-heading-scale, 1));
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.5;
}
.mobile-submenu a:hover { background: rgba(255,255,255,.1); }

.chevron {
    transition: transform 0.25s ease;
    display: inline-block;
    font-size: 0.8em;
}
.mobile-submenu.open .chevron { transform: rotate(180deg); }

/* أدوات إضافية داخل قائمة الجوال */
.header-utility {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: rgba(0,0,0,.1);
}
.header-utility a {
    color: #fff;
    text-decoration: none;
    padding: 9px 15px;
    background: rgba(255,255,255,.1);
    border-radius: 20px;
    font-size: calc(0.92rem * var(--font-heading-scale, 1));
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.4;
    transition: background .2s;
}
.header-utility a:hover { background: rgba(255,255,255,.2); }

/* =========================================================
   8) الصفحات الداخلية
   ========================================================= */
body.minimal-header .header-top,
body.minimal-header .marquee-container {
    display: none !important;
}

/* =========================================================
   9) 🔍 الاستجابة — وضع الجوال (≤ 992px)
   ⚠️ أحجام الخطوط في هذا القسم محسّنة لوضوح العربية
   ========================================================= */
@media (max-width: 992px) {
    .desktop-nav { display: none; }
    .mobile-nav-toggle { display: flex; }
    .mobile-nav-menu.open { display: block; }
}

@media (min-width: 993px) {
    .desktop-nav { display: flex; }
    .mobile-nav-menu { display: none !important; }
    .mobile-nav-toggle { display: none !important; }
}

/* =========================================================
   10) 📱 وضوح الخط على الجوال — مهم جداً للعربية
   الحد الأدنى لقراءة العربية المريحة: 14px = 0.875rem
   ========================================================= */
@media (max-width: 768px) {
    /* الصف الأول */
    .header-top-inner { gap: 8px; }
    .site-logo { height: 42px; }
    .mobile-nav-toggle,
    .search-toggle-btn { width: 42px; height: 42px; }

    /* الصف الثاني — 3 شرائح في سطر واحد */
    .header-bottom-inner {
        grid-template-columns: 1fr auto 1fr;
        gap: 6px;
        padding-top: 10px;
        margin-top: 10px;
    }

    /* 🔧 إصلاح وضوح الشرائح (التاريخ + اللغة + الترحيب) */
    .header-meta-badge {
        font-size: 0.85rem !important;         /* 13.6px — حد أدنى مريح */
        padding: 8px 12px !important;
        gap: 6px;
        font-weight: 700;
        letter-spacing: 0.01em;
        line-height: 1.45;
        min-height: 34px;
    }
    .date-badge {
        font-size: 0.85rem !important;
        padding: 8px 14px !important;
        font-weight: 800;
        letter-spacing: 0.02em;
    }
    .date-badge i,
    .date-badge .footer-emoji,
    .header-meta-badge .footer-emoji {
        font-size: 0.95rem;
        line-height: 1;
    }
    .lang-badge {
        font-weight: 800;
        letter-spacing: 0.02em;
    }

    /* 🔧 تحسين وضوح روابط القائمة على الجوال */
    .mobile-nav-link,
    .mobile-submenu-toggle {
        font-size: 1.05rem;
        padding: 16px;
        font-weight: 700;
        letter-spacing: 0.01em;
        line-height: 1.55;
    }
    .mobile-submenu a {
        font-size: 1rem;
        padding: 14px 26px;
        font-weight: 600;
        letter-spacing: 0.01em;
    }
    .header-utility a {
        font-size: 0.95rem;
        padding: 10px 16px;
    }

    /* لوحة البحث */
    .search-box-wrap { padding: 0 10px; }
    .header-search-input {
        padding: 13px 90px 13px 14px;
        font-size: 1rem;
        letter-spacing: 0.01em;
    }
    .header-search-btn { left: 46px; width: 34px; height: 34px; }
    .search-close-btn { width: 32px; height: 32px; }

    /* نتائج البحث */
    .search-result-title { font-size: 1rem; }
    .search-result-excerpt { font-size: 0.9rem; }
    .search-result-meta { font-size: 0.85rem; }
    .search-result-footer { font-size: 0.95rem; padding: 12px 14px; }
}

/* =========================================================
   11) 📱 شاشات صغيرة جداً (≤ 400px)
   ========================================================= */
@media (max-width: 400px) {
    .header-meta-badge {
        font-size: 0.8rem !important;
        padding: 7px 10px !important;
        gap: 4px;
    }
    .date-badge {
        font-size: 0.8rem !important;
        padding: 7px 11px !important;
    }
    .date-badge .footer-emoji {
        font-size: 0.85rem;
    }
    .site-logo { height: 38px; }
    .mobile-nav-toggle,
    .search-toggle-btn { width: 40px; height: 40px; }
}

/* =========================================================
   12) 📱 شاشات صغيرة جداً جداً (≤ 360px)
   ========================================================= */
@media (max-width: 360px) {
    .header-meta-badge {
        font-size: 0.75rem !important;
        padding: 6px 9px !important;
    }
    .date-badge {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
    .date-badge .footer-emoji {
        display: none;                          /* إخفاء الإيموجي لتوفير مساحة */
    }
}