/* ============================================================
   Aljazair Press v4.1.0 — الهيدر المُعاد تصميمه وفق المرجع البصري
   (الطقس الدوّار + أوقات الصلاة + أسعار الصرف + أرشيف الجريدة
   + الشريط الكحلي للتاريخ/RSS + أزرار الموجز/الفيديو + أزرار القائمة)
   يعتمد متغيرات الألوان القائمة في style.css فيعمل تلقائياً
   مع الوضع الليلي (--card-bg, --text-dark, --border-color...)
   ============================================================ */

/* ------------------------------------------------------------
   0-أ) الشريط الأبيض الموحّد .ajp-infobar
   يمين: [دخول] [أرشيف الجريدة ▾] — يسار: [صلوات] [عملات] [طقس]
   ------------------------------------------------------------ */
.ajp-infobar {
    background: var(--card-bg, #fff);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-size: 13px;
    position: relative;
    z-index: 1001;
}
.ajp-infobar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 48px;
    flex-wrap: nowrap;
    /* ملاحظة: بلا overflow-x هنا حتى لا تُقص القوائم المنسدلة (الأرشيف/البحث)
       — وضع التمرير الأفقي للهواتف فقط في استعلامات الوسائط أدناه */
    padding-top: 5px;
    padding-bottom: 5px;
}
.ajp-infobar-row::-webkit-scrollbar { display: none; }
.ajp-infobar-side,
.ajp-infobar-links,
.ajp-infobar-widgets {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.ajp-infobar-widgets { flex: 0 1 auto; gap: 16px; margin-inline-start: auto; }

/* قلب محاذاة قائمة الحساب: العنصر الآن أول العناصر يميناً،
   فاللوحة تُفتح نحو الداخل (يساراً) لا خارج الشاشة */
.ajp-infobar-side .ajp-account-menu .ajp-account-dropdown {
    inset-inline-end: auto;
    inset-inline-start: 0;
}
/* لوحة الأرشيف تُفتح نحو الداخل أيضاً */
.ajp-infobar-side .ajp-archive .ajp-dd-panel { inset-inline-start: 0; }

/* شارة التاريخ داخل الشريط الكحلي */
.ajp-tickerbar .ajp-date-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #ffffff;
    font-weight: 700;
    white-space: nowrap;
    font-size: 13px;
}
.ajp-tickerbar .ajp-date-ico { color: var(--accent-gold, #d9822b); display: inline-flex; }

/* ------------------------------------------------------------
   0-ب) الشريط الكحلي .ajp-tickerbar (التاريخ + العبارة + RSS)
   ------------------------------------------------------------ */
.ajp-tickerbar {
    background: linear-gradient(90deg, var(--primary-dark, #0b1e33) 0%, #123055 55%, var(--primary-dark, #0b1e33) 100%);
    color: #ffffff;
    font-size: 13px;
    position: relative;
    z-index: 1000;
    border-bottom: 2px solid rgba(217, 130, 43, .55);
}
.ajp-tickerbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 38px;
    flex-wrap: nowrap;
}
.ajp-tickerbar-right,
.ajp-tickerbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.ajp-tickerbar-slogan {
    color: rgba(255, 255, 255, .88);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
    position: relative;
    padding-inline-start: 16px;
}
.ajp-tickerbar-slogan::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-red, #d93025);
    box-shadow: 0 0 0 3px rgba(217, 48, 37, .25);
}
.ajp-tickerbar-rss {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    font-weight: 800;
    font-size: 12.5px;
    letter-spacing: .4px;
    padding: 4px 10px;
    border-radius: 8px;
    transition: background .2s ease, color .2s ease;
}
.ajp-tickerbar-rss:hover {
    background: rgba(255, 255, 255, .12);
    color: var(--accent-gold, #d9822b);
}

/* زر البث المصغّر داخل الشريط الكحلي */
.ajp-tickerbar .ajp-live-mini {
    border: 1px solid rgba(255, 255, 255, .28);
    color: #ffffff;
    background: rgba(255, 255, 255, .08);
}
.ajp-tickerbar .ajp-live-mini.is-live { border-color: rgba(255, 255, 255, .4); }

/* ------------------------------------------------------------
   1) دوّار الطقس حسب الولايات
   ------------------------------------------------------------ */
.ajp-wx {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}
.ajp-wx-pill {
    background: var(--ajp-deepred, #9c1616);
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 4px 13px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease;
}
.ajp-wx-pill:hover { background: #b51e1e; }
.ajp-wx-pill:active { transform: scale(.96); }

.ajp-wx-ico { display: inline-flex; align-items: center; color: #5470c6; }
.ajp-wx-ico .ajp-wx-svg { display: block; }
.ajp-wx-ico.is-day { color: #e8a013; }
.ajp-wx-ico.is-cloud { color: #64748b; }
.ajp-wx-ico.is-rain { color: #3b82c4; }
.ajp-wx-ico.is-storm { color: #7c3aed; }

.ajp-wx-temp {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-dark, #1e293b);
    line-height: 1;
    min-width: 34px;
    text-align: center;
    transition: opacity .25s ease;
}
.ajp-wx-hl {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    font-size: 10px;
    line-height: 1.25;
    color: var(--text-muted, #64748b);
    font-weight: 700;
}
.ajp-wx-hi { color: #b45309; }
.ajp-wx-lo { color: #2563eb; }
.ajp-wx-hi, .ajp-wx-lo { white-space: nowrap; }

.ajp-wx-arrows { display: inline-flex; gap: 3px; }
.ajp-wx-nav {
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-light, #f4f6f9);
    color: var(--text-muted, #64748b);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: all .2s ease;
}
.ajp-wx-nav:hover {
    background: var(--ajp-deepred, #9c1616);
    color: #fff;
    border-color: var(--ajp-deepred, #9c1616);
}

/* انتقال ناعم عند التبديل */
.ajp-wx.is-fading .ajp-wx-temp,
.ajp-wx.is-fading .ajp-wx-hl,
.ajp-wx.is-fading .ajp-wx-pill,
.ajp-wx.is-fading .ajp-wx-ico {
    opacity: .25;
}

/* ------------------------------------------------------------
   2) أسعار الصرف (الدينار يميناً ثم القيمة ثم شارة العملة)
   ------------------------------------------------------------ */
.ajp-fx {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ajp-fx-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.ajp-fx-code {
    background: #0c7a3d;
    color: #fff;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .3px;
}
.ajp-fx-value {
    color: var(--text-dark, #1e293b);
    font-weight: 800;
    font-size: 13.5px;
}
.ajp-fx-dzd {
    color: var(--text-muted, #64748b);
    font-size: 10.5px;
    font-weight: 700;
}
.ajp-fx-manual .ajp-fx-value { opacity: .75; }

/* ------------------------------------------------------------
   3) أوقات الصلاة
   ------------------------------------------------------------ */
.ajp-prayer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-light, #f4f6f9);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 999px;
    padding: 3px 8px;
}
.ajp-prayer-ico {
    color: var(--ajp-deepred, #9c1616);
    display: inline-flex;
    padding-inline-end: 4px;
}
.ajp-prayer-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
    padding: 1px 7px;
    border-radius: 9px;
    transition: background .2s ease, color .2s ease;
}
.ajp-prayer-name {
    font-size: 9.5px;
    color: var(--text-muted, #64748b);
    font-weight: 600;
}
.ajp-prayer-time {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-dark, #1e293b);
    font-variant-numeric: tabular-nums;
}
/* الصلاة القادمة — تمييز أحمر داكن كالمرجع */
.ajp-prayer-item.is-next {
    background: var(--ajp-deepred, #9c1616);
}
.ajp-prayer-item.is-next .ajp-prayer-name,
.ajp-prayer-item.is-next .ajp-prayer-time {
    color: #fff;
}
.ajp-prayer-count {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ajp-deepred, #9c1616);
    padding-inline-start: 4px;
    white-space: nowrap;
}

/* ------------------------------------------------------------
   4) القوائم المنسدلة العامة (الأرشيف / المزيد / البحث)
   ------------------------------------------------------------ */
.ajp-dd { position: relative; display: inline-flex; }
.ajp-dd-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 8px;
    transition: all .2s ease;
    white-space: nowrap;
}
.ajp-dd-trigger:hover {
    color: var(--accent-red, #d93025);
    background: rgba(217, 48, 37, .07);
}
.ajp-dd-panel {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    min-width: 190px;
    max-width: 320px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(11, 30, 51, .16);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    z-index: 1100;
}
.ajp-dd.is-open .ajp-dd-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.ajp-dd-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}
.ajp-dd-panel ul li a {
    display: block;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-dark, #1e293b);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.ajp-dd-panel ul li a:hover {
    background: rgba(217, 48, 37, .08);
    color: var(--accent-red, #d93025);
}
/* لوحة الأرشيف داخل جهة اليمين تُفتح نحو الداخل */
.ajp-infobar-side .ajp-archive .ajp-dd-panel { inset-inline-start: 0; }

/* عنصر الحساب داخل جهة اليمين — نفس أنماط header-tools دون تعديل الشكل */
.ajp-infobar-side .ajp-register-btn {
    display: none; /* يكفي زر الدخول في الشريط الموحّد */
}
.ajp-infobar-side .ajp-account-menu { position: static; }

/* زر البث المصغّر */
.ajp-live-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4.5px 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* ------------------------------------------------------------
   4-م) أزرار المنطقة الوسطى للهيدر (الموجز / الفيديو)
   وفق المرجع البصري: يسار البنر الإعلاني، حبوب كبيرة واضحة
   ------------------------------------------------------------ */
.ajp-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.ajp-haction-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 11px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(11, 30, 51, .14);
    transition: filter .18s ease, transform .18s ease, box-shadow .18s ease;
}
.ajp-haction-btn svg { flex: 0 0 auto; }
/* الموجز: تدرج وردي ← برتقالي كالمرجع */
.ajp-haction-mowjaz {
    background: linear-gradient(135deg, #e8467c 0%, #f26522 100%);
    box-shadow: 0 6px 16px rgba(232, 70, 124, .30);
}
/* الفيديو: أحمر واضح مع أيقونة تشغيل */
.ajp-haction-video {
    background: linear-gradient(135deg, #e23b30 0%, #b01414 100%);
    box-shadow: 0 6px 16px rgba(226, 59, 48, .28);
}
.ajp-haction-btn:hover {
    filter: brightness(1.09);
    transform: translateY(-1px);
    color: #fff;
}
.ajp-haction-btn:active { transform: translateY(0); }
.ajp-haction-btn:focus-visible {
    outline: 3px solid rgba(217, 130, 43, .6);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   5) اللافتة الحمراء للخبر الرئيسي
   ------------------------------------------------------------ */
.ajp-red-banner-wrap { margin-top: 14px; margin-bottom: 4px; }
.ajp-red-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #c31d1d 0%, #9c1616 100%);
    color: #fff;
    text-decoration: none;
    text-align: center;
    border-radius: 12px;
    padding: 15px 26px;
    font-size: clamp(16px, 2.1vw, 25px);
    font-weight: 800;
    line-height: 1.55;
    box-shadow: 0 10px 26px rgba(156, 22, 22, .30);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.ajp-red-banner:hover {
    filter: brightness(1.08);
    box-shadow: 0 12px 30px rgba(156, 22, 22, .40);
    transform: translateY(-1px);
    color: #fff;
}
.ajp-red-banner-tag {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .18);
    border-radius: 50%;
    font-size: 15px;
}
.ajp-red-banner-text { flex: 1 1 auto; }

/* ------------------------------------------------------------
   6) أزرار القائمة السريعة داخل nav (المزيد / الفيديو / البحث)
   ------------------------------------------------------------ */
.ajp-nav-quick {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: 8px;
}
.ajp-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #d3302a, #a31313);
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 6.5px 15px;
    font-size: 12.5px;
    font-weight: 700;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: filter .18s ease, transform .18s ease;
}
.ajp-quick-btn:hover { filter: brightness(1.12); transform: translateY(-1px); color: #fff; }
.ajp-more-btn .ajp-dd-panel { color: initial; }

.ajp-more .ajp-dd-panel {
    inset-inline-start: auto;
    inset-inline-end: 0;
    min-width: 220px;
}
.ajp-more .ajp-dd-panel ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
}
.ajp-more .ajp-dd-panel ul li a { border-radius: 8px; }

.ajp-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color, #e2e8f0);
    background: transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: all .2s ease;
}
.ajp-search-btn:hover,
.ajp-search.is-open .ajp-search-btn {
    background: var(--ajp-deepred, #9c1616);
    border-color: var(--ajp-deepred, #9c1616);
    color: #fff;
}
.ajp-search-panel { min-width: 260px; inset-inline-start: auto; inset-inline-end: 0; }
.ajp-search-form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ajp-search-form input[type="search"] {
    flex: 1 1 auto;
    width: 170px;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    padding: 7px 11px;
    font-family: inherit;
    font-size: 13px;
    background: var(--bg-light, #f4f6f9);
    color: var(--text-dark, #1e293b);
}
.ajp-search-form input[type="search"]:focus { outline: 2px solid rgba(156, 22, 22, .35); border-color: var(--ajp-deepred, #9c1616); }
.ajp-search-form button {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 0;
    background: var(--ajp-deepred, #9c1616);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: filter .18s ease;
}
.ajp-search-form button:hover { filter: brightness(1.15); }

/* ------------------------------------------------------------
   7) الاستجابة (Responsive)
   ------------------------------------------------------------ */
@media (max-width: 1200px) {
    .ajp-infobar-widgets { gap: 12px; }
}
@media (max-width: 1024px) {
    /* الهواتف/التابلت: شريط قابل للتمرير أفقياً + إخفاء ما لا يلزم،
       والقوائم المنسدلة تُخفى لأنها داخل سياق قصّ لا يمكن فتحها داخله */
    .ajp-infobar-row {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        justify-content: flex-start;
    }
    .ajp-infobar-row::-webkit-scrollbar { display: none; }
    .ajp-infobar-widgets { margin-inline-start: 0; }
    .ajp-infobar-links { display: none; }
    .ajp-prayer-count { display: none; }
    .ajp-archive { display: none; }
    .ajp-tickerbar-slogan { display: none; }
}
@media (max-width: 820px) {
    .ajp-wx-hl { display: none; }
    .ajp-wx-arrows { display: none; }
    .ajp-fx { display: none; }
}
@media (max-width: 640px) {
    .ajp-prayer { display: none; }
    .ajp-red-banner { padding: 12px 16px; gap: 9px; }
    .ajp-red-banner-tag { width: 25px; height: 25px; font-size: 13px; }
    .ajp-nav-quick { margin-inline-start: 4px; gap: 5px; }
    .ajp-quick-btn { padding: 5.5px 11px; font-size: 11.5px; }
    .ajp-search-panel { min-width: 210px; }
    .ajp-tickerbar .ajp-date-pill { font-size: 12px; }
    /* أزرار المنطقة الوسطى تبقى ظاهرة ومقروءة على الهاتف */
    .ajp-header-actions { gap: 7px; width: 100%; justify-content: flex-end; }
    .ajp-haction-btn { padding: 8px 13px; font-size: 12.5px; border-radius: 9px; }
}
@media (max-width: 420px) {
    .ajp-quick-btn span { display: none; } /* أيقونات فقط على الهواتف الصغيرة */
    .ajp-quick-btn { padding: 5.5px 9px; }
    .ajp-wx-pill { padding: 3.5px 10px; font-size: 12px; }
}

/* ------------------------------------------------------------
   8) الوضع الليلي (يرث المتغيرات — تعديلات دقيقة فقط)
   ------------------------------------------------------------ */
html[data-theme="dark"] .ajp-wx-pill,
html[data-theme="dark"] .ajp-prayer-item.is-next,
html[data-theme="dark"] .ajp-search-form button {
    background: #b52525;
}
html[data-theme="dark"] .ajp-fx-code { background: #128a48; }
html[data-theme="dark"] .ajp-fx-value { color: #35c47c; }
html[data-theme="dark"] .ajp-wx-temp { color: #f1f5f9; }
html[data-theme="dark"] .ajp-tickerbar {
    background: linear-gradient(90deg, #0a1626 0%, #0f2239 55%, #0a1626 100%);
    border-bottom-color: rgba(217, 130, 43, .4);
}
html[data-theme="dark"] .ajp-red-banner {
    background: linear-gradient(135deg, #d32a2a 0%, #a51818 100%);
}
html[data-theme="dark"] .ajp-quick-btn {
    background: linear-gradient(135deg, #d3302a, #a31313);
}
html[data-theme="dark"] .ajp-haction-mowjaz {
    background: linear-gradient(135deg, #d13a6d 0%, #d8551a 100%);
}
html[data-theme="dark"] .ajp-haction-video {
    background: linear-gradient(135deg, #cc3328 0%, #991111 100%);
}
html[data-theme="dark"] .ajp-dd-panel {
    box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
}

/* حركة مخفّضة */
@media (prefers-reduced-motion: reduce) {
    .ajp-wx-temp, .ajp-wx-hl, .ajp-wx-pill, .ajp-wx-ico,
    .ajp-dd-panel, .ajp-red-banner, .ajp-quick-btn, .ajp-haction-btn {
        transition: none !important;
    }
}
