.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    width: 100%;
}

.header__cta {
    color: var(--text-black) !important;
}

.header__inner {
    height: 100%;
    width: 100%;
    max-width: 1440px;
    margin-inline: auto;
    display: flex;
    align-items: center;
    padding-inline: 40px;
    box-sizing: border-box;
}

/* ── الرئيسية: هيدر داكن فوق الـ Hero ──
   الشريط نفسه شفاف، والـ nav جوه كبسولة زجاجية؛ الصف ارتفاعه 73 ويبدأ من top 24 */
.header--dark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    padding-top: 24px;
    background: none;
    color: var(--white);
}

.header--dark .header__inner {
    height: 73px;
}

.header--dark .header__nav {
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    border-radius: 100px;
}

.header--dark .header__nav a,
.header--dark .header__dropdown-trigger {
    color: var(--n300);
}

.header--dark .header__nav a.active,
.header--dark .header__dropdown-trigger.active {
    background: #2D2F2F;
    color: var(--white);
    font-weight: 600;
    border-radius: 100px;
}

/* اللوجو: أبيض فوق الـ Hero، ملوّن في الكبسولة الفاتحة */
.header__logo-img--on-light {
    display: none !important;
}

.header--dark .header__cart,
.header--dark .header__lang-switch {
    background: rgba(255, 255, 255, 0.09);
    border-color: transparent;
    color: var(--white);
}

/* ── الرئيسية بعد الـ scroll: كبسولة فاتحة ثابتة 1352×88 في النص ──
   الخلفية + الـ blur على ::before مش على الهيدر نفسه، علشان backdrop-filter على الهيدر
   كان هيخلي قائمة الموبايل (position: fixed جواه) تتحسب بالنسبة له بدل الشاشة. */
.header--dark.header--scrolled {
    position: fixed;
    top: 16px;
    left: 0;
    right: 0;
    width: min(1352px, calc(100% - 88px));
    height: 88px;
    margin-inline: auto;
    padding-top: 0;
    border-radius: 99px;
    color: var(--text-black);
    animation: header-pill-in .3s ease-out;
}

/* كبسولة زجاجية: أبيض 20% + blur 5 فوق المحتوى اللي وراها.
   الخلفية + الـ blur على ::before علشان قائمة الموبايل (position: fixed) تفضل بالنسبة للشاشة. */
.header--dark.header--scrolled::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    pointer-events: none;
    transition: background-color .25s ease;
}

/* فوق الأقسام الداكنة (الـ CTA والفوتر) الخلفية تتقل علشان النص الغامق يفضل مقروء */
.header--dark.header--scrolled.header--over-dark::before {
    background: rgba(255, 255, 255, 0.88);
}

@supports not ((-webkit-backdrop-filter: blur(5px)) or (backdrop-filter: blur(5px))) {
    .header--dark.header--scrolled::before {
        background: rgba(255, 255, 255, 0.92);
    }
}

.header--dark.header--scrolled .header__inner {
    height: 100%;
    max-width: none;
    padding-inline: 40px;
}

.header--dark.header--scrolled .header__nav {
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.header--dark.header--scrolled .header__nav a,
.header--dark.header--scrolled .header__dropdown-trigger {
    color: var(--text-black);
}

.header--dark.header--scrolled .header__nav a.active,
.header--dark.header--scrolled .header__dropdown-trigger.active {
    background: #F2F3F3;
    color: #041507;
}

.header--dark.header--scrolled .header__logo-img--on-dark {
    display: none;
}

.header--dark.header--scrolled .header__logo-img--on-light {
    display: block !important;
}

.header--dark.header--scrolled .header__cart,
.header--dark.header--scrolled .header__lang-switch {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--n200);
}

.header--dark.header--scrolled .header__cart {
    color: var(--primary-600);
}

.header--dark.header--scrolled .header__lang-switch {
    color: var(--text-black);
}

.header--dark.header--scrolled .header__cart:hover,
.header--dark.header--scrolled .header__lang-switch:hover {
    background: var(--n100);
}

@keyframes header-pill-in {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .header--dark.header--scrolled {
        animation: none;
    }
}

.header--light {
    background: var(--white);
    color: var(--text-black);
}

.header--light .header__nav a,
.header--light .header__dropdown-trigger {
    color: var(--text-black);
}

.header--light .header__nav a.active,
.header--light .header__dropdown-trigger.active {
    background: var(--n100);
    color: var(--primary-700);
    border-radius: 99px;
}

.header__logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 99.42px;
    height: 73.83px;
}

.header__logo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

.header__nav {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
    padding: 5px 12px;
    margin-inline: auto;
}

.header__nav a,
.header__dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 4px 8px;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    transition: background-color .2s, color .2s;
    white-space: nowrap;
}

.header__nav a:hover,
.header__dropdown-trigger:hover {
    opacity: 0.8;
}

.header__nav a.active,
.header__dropdown-trigger.active {
    padding: 4px 16px;
}

.header__dropdown-trigger {
    gap: 8px;
}

.header__dropdown {
    position: relative;
}

.header__dropdown-trigger {
    background: none;
    cursor: pointer;
}

.icon-arrow-down {
    transition: transform .2s ease;
}

.header__dropdown.open .icon-arrow-down {
    transform: rotate(180deg);
}

.header__dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    width: 224px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 50;
}

.header__dropdown.open .header__dropdown-panel {
    display: flex;
}

.header__dropdown-panel a,
.header--dark .header__dropdown-panel a {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--n700) !important;
    font-size: 14px;
    display: block;
}

.header__dropdown-panel a:hover,
.header--dark .header__dropdown-panel a:hover {
    background: var(--primary-50);
    color: var(--primary-700) !important;
    opacity: 1;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header__cart {
    position: relative;
    width: 56px;
    height: 48px;
    padding: 10px 16px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--primary-600);
    transition: background-color .2s;
}

.header--light .header__cart {
    border-color: var(--n200);
}

.header--dark .header__cart:hover { background: rgba(255,255,255,0.16); }
.header--light .header__cart:hover { background: var(--n100); }

.header__cart-count {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    background: var(--primary-500);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-inline: 2px;
}

.header__lang-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 109px;
    height: 48px;
    padding: 8px 16px;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .2s;
}

.header__lang-label[lang="ar"] {
    font-family: var(--font-ar);
}

.header__lang-label[lang="en"] {
    font-family: var(--font-en);
}

.header--light .header__lang-switch {
    border-color: var(--n200);
}

.header__cta.btn {
    min-width: 129px;
    height: 48px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.header__lang-flag {
    position: relative;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.header__lang-flag-img {
    position: absolute;
    display: block;
    max-width: none;
}

.header__lang-flag-img--eg {
    width: 23px;
    height: 15.68px;
    top: 4px;
    left: 0.5px;
}

.header__lang-flag-img--uk {
    width: 22px;
    height: 17px;
    top: 3.5px;
    left: 0.71px;
}

.header--dark .header__lang-switch:hover { background: rgba(255,255,255,0.16); }
.header--light .header__lang-switch:hover { background: var(--n100); }

.header__burger {
    color: inherit; /* الزرار مبيورثش اللون افتراضيًا — كان بيظهر أسود فوق الـ Hero الداكن */
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.header__burger span {
    width: 22px;
    height: 2px;
    background: currentColor;
    transition: transform .2s, opacity .2s;
}

@media (max-width: 1300px) {
    .header__inner { padding-inline: 24px; }
    .header__nav { gap: 4px; padding-inline: 8px; }
    .header__nav a, .header__dropdown-trigger { padding: 4px 8px; font-size: 15px; }
    .header__nav a.active, .header__dropdown-trigger.active { padding: 4px 12px; }
    .header__actions { gap: 8px; }
}

@media (max-width: 1100px) {
    .header__cta { display: none; }
}

@media (max-width: 1000px) {
    .header__nav { display: none; }
    .header__burger { display: flex; }
    .header__actions { margin-inline-start: auto; }
    .header--dark { padding-top: 12px; }
    .header--dark.header--scrolled {
        top: 12px;
        width: calc(100% - 24px);
        height: 72px;
    }
    .header--dark.header--scrolled .header__inner { padding-inline: 16px; }
    /* على الشاشات الصغيرة العناوين الكبيرة بتعدّي ورا اللوجو، فالزجاج أتقل شوية */
    .header--dark.header--scrolled::before {
        background: rgba(255, 255, 255, 0.6);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }
    .header--dark.header--scrolled .header__logo { width: 76px; height: 56px; }
    /* قائمة الموبايل في الرئيسية تبدأ تحت الهيدر الشفاف / الكبسولة */
    .header--dark .header__mobile-menu.open { top: 96px; }
}

@media (max-width: 520px) {
    .header__inner { padding-inline: 16px; gap: 8px; }
    .header__actions { gap: 6px; }
    .header__cart { width: 44px; height: 44px; padding: 0; }
    /* زرار اللغة: العلم بس على الشاشات الصغيرة */
    .header__lang-switch { min-width: 44px; height: 44px; padding: 0 10px; }
    .header__lang-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

@media (max-width: 360px) {
    .header__inner { padding-inline: 12px; }
    .header__logo { width: 80px; height: 60px; }
}

.header__mobile-menu {
    display: none;
}

.header__mobile-menu.open {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: var(--white);
    z-index: 99;
    padding: 24px;
    overflow-y: auto;
}

.header__mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header__mobile-nav a {
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 500;
    color: var(--n700);
    border-radius: 8px;
}

.header__mobile-nav a.active {
    background: var(--primary-50);
    color: var(--primary-700);
}

.header__mobile-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 500;
    color: var(--n700);
    border-radius: 8px;
    background: none;
}

.header__mobile-dropdown-trigger.active {
    background: var(--primary-50);
    color: var(--primary-700);
}

.header__mobile-dropdown-panel {
    display: none;
    flex-direction: column;
    padding-inline-start: 16px;
}

.header__mobile-dropdown.open .header__mobile-dropdown-panel {
    display: flex;
}

.header__mobile-dropdown.open .icon-arrow-down {
    transform: rotate(180deg);
}

.header__mobile-dropdown-panel a {
    padding: 12px 16px;
    font-size: 15px;
    color: var(--n600);
}
