/* =====================================================================
   HEADER — RESPONSIVE FIX
   ملحوظة الاستخدام: ضيف السطر ده بعد style.css الأصلي عشان ياخد الأولوية:
   <link rel="stylesheet" href="assets/css/header-fix.css?v=1">
   الملف مبني على نفس الـ classes الموجودة في header.php فمفيش أي تعديل
   مطلوب في الـ HTML، غير سطر الـ <link> ده، وإضافة header-fix.js
   قبل إغلاق </body> (اختياري لكن بينفّذ فتح/قفل القوائم على الموبايل).
   ===================================================================== */

:root{
  --header-h: 60px;
  --topbar-h: 34px;
  --offers-h: 38px;
  --header-z: 1000;
  --overlay-z: 500;
}

*{box-sizing:border-box;}

/* الأوفرلاي كان بيظهر طول الوقت فوق الصفحة كلها — لازم يكون مخفي افتراضيًا
   وميظهرش غير لما القائمة تتفتح على الموبايل */
.page-overlay{
  display:none !important;
  pointer-events:none;
}
.page-overlay.active{
  display:block !important;
  pointer-events:auto;
}

/* ---------------------------------------------------------------
   Sticky container: topbar + offers bar + main bar تتحسب زي الطبيعي
   --------------------------------------------------------------- */
.site-header{
  position: sticky;
  top: 0;
  z-index: var(--header-z);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  width: 100%;
}

.offers-announce-bar{
  background: var(--primary);
  color:#fff;
}
.offers-announce-inner{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height: var(--offers-h);
  padding: 6px 16px;
  font-size: 13.5px;
  position: relative;
  text-align:center;
}
.offers-announce-inner a{ color:#fff; text-decoration:none; display:flex; align-items:center; gap:8px; }
.offers-announce-close{
  position:absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  background:none;
  border:none;
  color:#fff;
  font-size:20px;
  line-height:1;
  cursor:pointer;
  opacity:.85;
}
.offers-announce-close:hover{ opacity:1; }

.header-topbar{
  background:#f4f5f7;
  border-bottom:1px solid #ececec;
  font-size:12.5px;
}
.header-topbar-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  min-height: var(--topbar-h);
  gap:16px;
}
.header-topbar-inner > a,
.header-topbar-end > a{
  color:#555;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap:6px;
  white-space:nowrap;
}
.header-topbar-end{ display:flex; align-items:center; gap:18px; }

/* ---------------------------------------------------------------
   Main bar
   --------------------------------------------------------------- */
.header-inner{
  display:flex;
  align-items:center;
  gap:18px;
  min-height: var(--header-h);
  padding-top:8px;
  padding-bottom:8px;
}

.logo{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  font-weight:800;
  font-size:20px;
  color: var(--primary);
  text-decoration:none;
  white-space:nowrap;
}
.logo span{ color: var(--primary-dark); }

/* ---------------------------------------------------------------
   Mega menu
   --------------------------------------------------------------- */
.mega-menu-wrap{ position:relative; flex:0 0 auto; }
.mega-menu-trigger{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid #e3e5e9;
  background:#fff;
  border-radius:8px;
  padding:9px 14px;
  font-size:14px;
  font-weight:600;
  color:#222;
  cursor:pointer;
  white-space:nowrap;
}
.mega-menu-trigger .account-caret{ font-size:11px; transition:transform .2s; }
.mega-menu-wrap.open .mega-menu-trigger .account-caret{ transform:rotate(180deg); }

.mega-menu-panel{
  position:absolute !important;
  inset-inline-start:0 !important;
  top: calc(100% + 8px) !important;
  background:#fff !important;
  border:1px solid #eceef1 !important;
  border-radius:12px !important;
  box-shadow:0 12px 32px rgba(0,0,0,.12) !important;
  display:flex !important;
  flex-wrap:wrap;
  gap:0;
  width: min(720px, 90vw);
  max-height: 70vh;
  overflow:auto;
  padding:18px !important;
  opacity:0;
  visibility:hidden;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  z-index: calc(var(--header-z) + 1) !important;
}
.mega-menu-wrap.open .mega-menu-panel{
  opacity:1;
  visibility:visible;
  transform: translateY(0);
}
.mega-menu-col{ flex:1 1 220px; min-width:200px; padding:0 12px; }
.mega-menu-col h4{ font-size:13px; color:#888; margin:0 0 10px; font-weight:700; }
.mega-menu-link{
  display:flex !important; align-items:center; gap:10px;
  padding:8px 6px; border-radius:8px;
  color:#333 !important; text-decoration:none !important; font-size:14px;
}
.mega-menu-link i{ width:18px; text-align:center; color:#888; }
.mega-menu-link:hover{ background:#f6f7f9; color:var(--primary) !important; }
.mega-menu-grid{
  display:grid !important;
  grid-template-columns:repeat(2,1fr);
  gap:8px;
}
.mega-menu-tile{
  display:flex !important; align-items:center; gap:8px;
  padding:8px; border-radius:8px;
  text-decoration:none !important; color:#333 !important; font-size:13.5px;
}
.mega-menu-tile:hover{ background:#f6f7f9; }
.mega-menu-tile-icon{
  width:30px; height:30px; border-radius:8px;
  display:flex !important; align-items:center; justify-content:center;
  flex:0 0 auto;
}

/* ---------------------------------------------------------------
   Search
   --------------------------------------------------------------- */
.search-wrap.header-search-wrap{ position:relative; flex:1 1 auto; min-width:0; }
.header-search-box{
  display:flex;
  align-items:center;
  gap:8px;
  background:#f4f5f7;
  border:1px solid #e9eaed;
  border-radius:10px;
  padding:0 12px;
  height:42px;
}
.header-search-box i{ color:#9a9ea6; font-size:14px; }
.header-search-box input{
  flex:1;
  min-width:0;
  border:none;
  background:transparent;
  outline:none;
  font-size:14px;
  height:100%;
}
.header-search-box button{
  border:none;
  background: var(--primary);
  color:#fff;
  border-radius:8px;
  padding:8px 14px;
  display:flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  white-space:nowrap;
  flex:0 0 auto;
}
.search-suggest-box{
  position:absolute;
  top:calc(100% + 6px);
  inset-inline-start:0;
  width:100%;
  background:#fff;
  border:1px solid #eceef1;
  border-radius:10px;
  box-shadow:0 12px 28px rgba(0,0,0,.1);
  z-index: calc(var(--header-z) + 1);
}
/* ملحوظة: أنماط .smart-search-toggle-btn و .smart-search-panel موجودة بالكامل في
   assets/css/style.css (المصدر الوحيد لهم)، عمدًا مش متكررين هنا — بعد المشكلة اللي
   حصلت قبل كده من تعارض نفس الـ class في ملفين CSS مختلفين في نفس الوقت */

/* ---------------------------------------------------------------
   Nav icons
   --------------------------------------------------------------- */
.header-nav{
  display:flex;
  align-items:center;
  gap:6px;
  flex:0 0 auto;
}
.header-icon-link{
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  padding:8px 10px;
  border-radius:8px;
  color:#333;
  text-decoration:none;
  font-size:11px;
  line-height:1.1;
  white-space:nowrap;
  min-width:56px;
  text-align:center;
}
.header-icon-link i{ font-size:17px; }
.header-icon-link:hover{ background:#f6f7f9; color:var(--primary); }
.nav-text-col{ display:flex; flex-direction:column; align-items:center; }
.nav-text-col small{ font-size:10px; color:#8b8f96; font-weight:400; }

.cart-badge{
  position:absolute;
  top:2px;
  inset-inline-end:2px;
  background:var(--primary);
  color:#fff;
  font-size:10px;
  font-weight:700;
  min-width:16px;
  height:16px;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 3px;
}

/* Account dropdown */
.account-menu-wrap{ position:relative; }
.account-menu-trigger{ cursor:pointer; border:none; background:none; font:inherit; }
.account-menu-trigger .account-caret{ font-size:10px; margin-inline-start:2px; }
.account-menu-dropdown{
  position:absolute;
  inset-inline-end:0;
  top:calc(100% + 8px);
  background:#fff;
  border:1px solid #eceef1;
  border-radius:12px;
  box-shadow:0 12px 32px rgba(0,0,0,.12);
  width:220px;
  padding:10px;
  opacity:0;
  visibility:hidden;
  transform:translateY(-8px);
  transition:opacity .18s ease, transform .18s ease, visibility .18s;
  z-index: calc(var(--header-z) + 1);
}
.account-menu-wrap.open .account-menu-dropdown{
  opacity:1; visibility:visible; transform:translateY(0);
}
.account-menu-head{ font-size:12px; color:#9a9ea6; padding:6px 8px; }
.account-menu-dropdown a{
  display:flex; align-items:center; gap:10px;
  padding:9px 8px; border-radius:8px;
  color:#333; text-decoration:none; font-size:14px;
}
.account-menu-dropdown a:hover{ background:#f6f7f9; color:var(--primary); }
.account-menu-divider{ height:1px; background:#eceef1; margin:6px 4px; }
.account-menu-login-btn{ justify-content:center; background:var(--primary); color:#fff !important; }

/* Mobile toggle button (hidden on desktop) */
.header-mobile-toggle{
  display:none;
  border:none;
  background:#f4f5f7;
  width:40px;
  height:40px;
  border-radius:8px;
  align-items:center;
  justify-content:center;
  font-size:18px;
  cursor:pointer;
  flex:0 0 auto;
}

/* Floating WhatsApp button */
.floating-whatsapp{
  position:fixed;
  bottom:20px;
  inset-inline-end:20px;
  width:52px;
  height:52px;
  border-radius:50%;
  background:#25D366;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:24px;
  box-shadow:0 8px 20px rgba(0,0,0,.2);
  z-index: calc(var(--header-z) - 1);
}

/* =====================================================================
   BREAKPOINTS
   ===================================================================== */

/* Tablet: نص الآيقونات بيختفي، البحث بيصغر شوية */
@media (max-width: 1200px){
  .header-topbar-inner a span,
  .header-topbar-end a span{ display:none; }
  .header-icon-link .nav-text,
  .header-icon-link .nav-text-col{ display:none; }
  .mega-menu-trigger .nav-text{ display:none; }
  .header-search-box button .nav-text{ display:none; }
}

/* Mobile: هيدر بالكامل بيتحول لهامبرجر + قوائم منسدلة full-width */
@media (max-width: 980px){
  :root{ --header-h:56px; }

  .header-topbar-inner{ font-size:11.5px; }
  .header-topbar-end{ gap:10px; }

  .header-inner{ flex-wrap:wrap; gap:10px; }
  .logo{ order:1; }
  .header-mobile-toggle{ order:2; display:flex; margin-inline-start:auto; }

  /* البحث ياخد سطر كامل تحت اللوجو */
  .search-wrap.header-search-wrap{
    order:4;
    flex:0 0 100%;
    width:100%;
  }

  .mega-menu-wrap{ order:3; }
  .mega-menu-panel{
    position:fixed !important;
    inset:auto 0 0 0 !important;
    top:auto !important;
    width:100% !important;
    max-height:80vh !important;
    border-radius:16px 16px 0 0 !important;
    flex-direction:column !important;
    background:#fff !important;
    z-index: 99998 !important;
  }
  .mega-menu-col{ padding:10px 4px !important; flex:1 1 100% !important; min-width:0 !important; }

  /* نافبار الآيقونات: مخفي افتراضيًا، بيتحول لقائمة جانبية عند الفتح */
  .site-header .header-nav{
    order:5;
    position:fixed !important;
    inset-inline-start:-100% !important;
    inset-inline-end:auto !important;
    top:0 !important;
    bottom:0 !important;
    height:100vh !important;
    width:78% !important;
    max-width:320px !important;
    background:#ffffff !important;
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    padding:70px 14px 20px !important;
    margin:0 !important;
    gap:2px !important;
    box-shadow:2px 0 24px rgba(0,0,0,.25) !important;
    transition: inset-inline-start .25s ease !important;
    z-index: 99999 !important;
    overflow-y:auto !important;
  }
  .site-header .header-nav.open{ inset-inline-start:0 !important; }

  .site-header .header-icon-link{
    flex-direction:row !important;
    justify-content:flex-start !important;
    gap:12px !important;
    width:100% !important;
    text-align:start !important;
    font-size:14px !important;
    padding:12px 10px !important;
    color:#222 !important;
  }
  .site-header .header-icon-link .nav-text,
  .site-header .header-icon-link .nav-text-col{ display:flex !important; font-size:14px !important; }
  .site-header .header-icon-link i{ width:22px; text-align:center; }
  .site-header .cart-badge{ position:static !important; margin-inline-start:auto !important; }

  .site-header .account-menu-dropdown{
    position:static !important;
    box-shadow:none !important;
    border:none !important;
    width:100% !important;
    opacity:1 !important; visibility:visible !important; transform:none !important;
    display:none !important;
    padding:0 0 0 32px !important;
  }
  .site-header .account-menu-wrap.open .account-menu-dropdown{ display:block !important; }

  /* -------------------------------------------------------------
     BUG FIX: الأوفرلاي كان z-index بتاعه (99990) أعلى من الهيدر
     (--header-z: 1000)، فكان بيتغطى بيه الهيدر بالكامل — يعني زرار
     الهامبرجر وزرار "الأقسام" نفسهم كانوا بيتغطوا بطبقة شفافة من
     الأوفرلاي، فأي دوسة عليهم كانت بتقفل كل حاجة (closeAll) بدل ما
     تفتح/تبدّل القائمة التانية. الحل: نخلي z-index بتاع الأوفرلاي أقل
     من الهيدر، عشان الهيدر وزراره يفضلوا فوق وقابلين للدوس عليهم،
     والقوائم المفتوحة (اللي z-index بتاعها 99998/99999) تفضل زي ما هي.
     ------------------------------------------------------------- */
  .page-overlay.active{
    position:fixed !important; inset:0 !important;
    background:rgba(0,0,0,.45) !important;
    z-index: var(--overlay-z) !important;
    display:block !important;
  }

  /* عشان زرار الأقسام وزرار الهامبرجر ميتلخبطوش في بعض */
  .mega-menu-trigger{
    background:var(--primary) !important;
    color:#fff !important;
    border-color:var(--primary) !important;
  }
  .mega-menu-trigger i,
  .mega-menu-trigger .account-caret{ color:#fff !important; }

  .floating-whatsapp{ width:46px; height:46px; font-size:20px; bottom:16px; }
}

@media (max-width: 380px){
  .header-topbar-end{ gap:8px; }
  .logo{ font-size:17px; }
}

/* أضيفي المقطع ده في آخر header-fix.css
   بيمنع أي تمرير/سكرول تاني للصفحة اللي تحت لما أي قائمة موبايل تكون
   مفتوحة (الهامبرجر / الأقسام / الحساب) — ده اللي بيحل مشكلة القائمة
   "العالقة" اللي بتفضل ظاهرة فوق الصفحة وانت بتمرر في محتوى تاني.
   ملحوظة: عمدًا مستخدمين .menu-scroll-lock على html وعلى body مع بعض
   (مش :has()) عشان يشتغل صح على كل المتصفحات بما فيها Safari القديم. */
html.menu-scroll-lock,
body.menu-scroll-lock{
  overflow: hidden !important;
}

/* زرار "تسجيل الدخول" لما يكون المستخدم زائر (مش مسجل دخول) — بيبان
   بلون مميز بدل ما يتلخبط مع "حسابي" العادي، عشان يكون واضح إنه زرار
   تسجيل دخول من أول وهلة، من غير ما تحتاج تفتح الـ dropdown الأول. */
.account-menu-trigger-guest{
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  border-radius: 8px;
}
.account-menu-trigger-guest i{ color:#fff !important; }

@media (max-width: 980px){
  .site-header .account-menu-trigger-guest{
    background: var(--primary) !important;
    color: #fff !important;
    border-radius: 8px;
  }
  .site-header .account-menu-trigger-guest i{ color:#fff !important; }
}