/* =========================================
   header.css
   هيدر نادي الفرسان – RTL / LTR
   ========================================= */

/* لو لم تُعرّف في style.css */
:root {
  --color-main: #0f6b63;       /* أخضر رئيسي */
  --color-main-dark: #053c37;  /* أخضر داكن للهفر */
  --color-light: #dde3ec;      /* رمادي فاتح */
  --color-body: #272727;
}
/* ========== الهيكل الأساسي ========== */

.site-header {
  position: sticky;
  top: 0;
  inset-inline: 0;
  z-index: 1000;
  background-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02),
              0 8px 20px rgba(0, 0, 0, 0.06);
}

.header-inner {
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 28px;
  padding-block: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* ========== الشعار ========== */

.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo img {
  display: block;
  height: 40px;
  width: auto;
}

/* ========== زر القائمة (Burger) ========== */

.header-burger {
  display: none;                /* يظهر فقط في الجوال داخل الميديا كويري */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;             /* بدون خلفية */
  border: none;                 /* بدون حدود */
  cursor: pointer;
  color: #0f6b63;               /* لون الأيقونة (currentColor) */
}

/* أيقونة SVG داخل الزر */
.header-burger .menu-icon {
  width: 26px;
  height: 26px;
  pointer-events: none;
  /* لو حاب تتأكد أكثر إن اللون ينطبق على الـ stroke */
  stroke: #0f6b63;
}

/* تأثير بسيط عند التحويم في الديسكتوب */
.header-burger:hover {
  color: #053c37;               /* لون أغمق عند التحويم */
}

.header-burger:hover .menu-icon {
  stroke: #053c37;
}

/* ========== القائمة الرئيسية ========== */

.header-nav {
  flex: 1;
  display: flex;
  justify-content: center;
}

.nav-list {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 26px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  position: relative;
}

/* عنصر يحتوي قوائم فرعية */
.nav-item--has-children {
  position: relative;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 4px;
  padding-block: 22px; /* يتحكم في ارتفاع الهيدر */
  font-size: 15px;
  text-decoration: none;
  color: #444;
  border-bottom: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--color-main-dark);
}

.nav-item.is-active > .nav-link {
  color: var(--color-main-dark);
  border-bottom-color: var(--color-main);
}

/* سهم صغير يشير لوجود قائمة فرعية (ديسكتوب) */
.nav-item--has-children > .nav-link::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-inline-end: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  margin-inline-start: 6px;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}
/* طبقة تغطية خلف المنيو في الجوال */
.header-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 998;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* حالة الظهور */
.header-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* منع التمرير عند فتح المنيو (اختياري لكن مريح) */
html.no-scroll,
html.no-scroll body {
  overflow: hidden;
}
/* ========== القوائم الفرعية (Dropdown) – مستوى أول ========== */

.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  min-width: 190px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
  z-index: 1000;
}

.nav-sublist .nav-link {
  display: block;
  width: 100%;
  padding-inline: 14px;
  padding-block: 8px;
  font-size: 14px;
  text-align: start;
  border-bottom: 0;
  justify-content: flex-start;
  color: #444;
}

.nav-sublist .nav-link:hover,
.nav-sublist .nav-link:focus-visible {
  background-color: #f5f7fa;
  color: var(--color-main-dark);
}

/* مستوى ثاني جانبي (داخل الفرق مثلاً) */
.nav-sublist--level2 {
  top: 0;
  inset-inline-start: 100%;
  margin-inline-start: 4px;
}

/* إظهار القوائم الفرعية – ديسكتوب */
@media (min-width: 992px) {
  .nav-item--has-children:hover > .nav-sublist,
  .nav-item--has-children:focus-within > .nav-sublist {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-item--has-children:hover > .nav-link::after {
    transform: rotate(225deg) translateY(1px);
  }

  .nav-sublist .nav-item--has-children:hover > .nav-sublist--level2,
  .nav-sublist .nav-item--has-children:focus-within > .nav-sublist--level2 {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* ========== الأزرار (لغة + CTA) ========== */

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* سويتش اللغة */
.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px 4px;
  background-color: #f5f7fa;
  border-radius: 999px;
  gap: 4px;
}

.lang-btn {
  border: 0;
  background: transparent;
  min-width: 42px;
  padding-inline: 10px;
  padding-block: 6px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  color: #555;
  transition: background-color 0.18s ease, color 0.18s ease;
}

/* تفعيل اللغة الفعلية حسب اتجاه الصفحة */
html[dir="rtl"] .lang-btn[data-lang="ar"],
html[dir="ltr"] .lang-btn[data-lang="en"] {
  background-color: var(--color-main);
  color: #ffffff;
}

html[dir="rtl"] .lang-btn[data-lang="en"],
html[dir="ltr"] .lang-btn[data-lang="ar"] {
  background-color: transparent;
  color: #555;
}

/* أزرار CTA */

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 18px;
  padding-block: 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  background-color: #ffffff;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: #333;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.header-btn--primary {
  border-color: transparent;
  background-color: var(--color-main);
  color: #ffffff;
}

.header-btn:hover,
.header-btn:focus-visible {
  border-color: var(--color-main-dark);
  color: var(--color-main-dark);
}

.header-btn--primary:hover,
.header-btn--primary:focus-visible {
  background-color: var(--color-main-dark);
  color: #ffffff;
}

/* زر بعرض كامل (للموبايل داخل المنيو) */
.header-btn--full {
  width: 100%;
  justify-content: center;
}

/* Helpers */
.desktop-only {
  display: inline-flex;
}
.mobile-only {
  display: none !important;
}

/* ===========================
   RESPONSIVE – تدرجياً
   =========================== */

@media (max-width: 1200px) {
  .nav-list {
    gap: 18px;
  }
}

@media (max-width: 1024px) {
  .header-inner {
    padding-inline: 18px;
    gap: 16px;
  }

  .nav-link {
    padding-block: 18px;
    font-size: 14px;
  }

  .header-btn {
    padding-inline: 16px;
    padding-block: 7px;
    font-size: 11px;
  }
}

/* ===========================
   موبايل / تابلت
   =========================== */

@media (max-width: 991.98px) {

  .header-inner {
    padding-inline: 16px;
    gap: 8px;
  }

  /* ترتيب العناصر: الشعار أولاً، ثم اللغة، ثم زر المنيو بأقصى الطرف */
  .header-logo {
    order: 1;
  }

  .header-actions {
    order: 2;
    margin-inline-start: auto;
    gap: 8px;
  }

  .header-burger {
    order: 3;
    display: inline-flex;
  }

  /* في الجوال: نخفي CTAs، نبقي سويتش اللغة */
  .header-actions .header-btn {
    display: none;
  }

  .header-actions .lang-switch {
    display: inline-flex;
  }

  /* منيو جانبية بأسلوب offcanvas
     تفتح من اليمين في RTL ومن اليسار في LTR */
  .header-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    width: min(360px, 80vw);       /* تقريباً ثلث – نصف الشاشة */
    background-color: #ffffff;
    padding-top: calc(var(--header-height-desktop) + 8px); /* نخليها تحت الهيدر */
    padding-bottom: 16px;
    padding-inline: 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 999;
    justify-content: flex-start;
    overflow-y: auto;   /* لو القائمة طويلة تنزل بسكرول داخلي */
    overflow-x: hidden; /* ما في تمرير أفقي */
    box-sizing: border-box;
  }

  /* مكان المنيو في العربية (يمين) */
  html[dir="rtl"] .header-nav {
    right: 0;
    left: auto;
    box-shadow:
      -24px 0 40px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
  }

  /* مكان المنيو في الإنجليزية (يسار) */
  html[dir="ltr"] .header-nav {
    left: 0;
    right: auto;
    box-shadow:
      24px 0 40px rgba(0, 0, 0, 0.18);
    transform: translateX(-100%);
  }

  /* ✳ هنا الأهم: نرجّعها داخل الشاشة عند الفتح
     ونستخدم نفس درجة التحديد مثل القواعد اللي فوق */
  html[dir="rtl"] .header-nav.is-open,
  html[dir="ltr"] .header-nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  /* القائمة داخل المنيو: رأسية وبكامل العرض */
  .header-nav .nav-list {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0;
    width: 100%;
  }

  .nav-item {
    width: 100%;
    display: block;
  }

  .nav-link {
    width: 100%;
    display: block;
    justify-content: flex-start;
    padding-inline: 0;
    padding-block: 12px;
    border-bottom: 1px solid #f0f0f0;
  }

  .nav-item.is-active > .nav-link {
    background-color: #f2f7fb;
    border-bottom-color: transparent;
    color: var(--color-main-dark);
  }

  .nav-item-cta {
    margin-top: 8px;
  }

  .header-btn--full {
    margin-top: 4px;
  }

  /* القوائم الفرعية في الموبايل: متداخلة، تظهر فقط عند .submenu-open */

  .nav-sublist {
    position: static;
    box-shadow: none;
    border-radius: 0;
    padding: 4px 0 8px 0;
    margin-top: -4px;
    margin-bottom: 4px;
    margin-inline-start: 12px;
    border-inline-start: 2px solid #eef2f7;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    display: none; /* مخفية افتراضياً في الجوال */
  }

  .nav-item.submenu-open > .nav-sublist {
    display: block;
  }

  .nav-sublist .nav-link {
    padding-block: 8px;
    border-bottom: 0;
    font-size: 13px;
    opacity: 0.9;
  }

  .nav-sublist--level2 {
    margin-inline-start: 16px;
  }

  .nav-item--has-children > .nav-link::after {
    margin-inline-start: 8px;
  }

  .mobile-only {
    display: block !important;
  }
}

/* ===========================
   RTL – دعم العربية
   =========================== */

html[dir="rtl"] .site-header,
html[dir="rtl"] .header-inner {
  direction: rtl;
}

/* القائمة تبقى صف أفقي في الديسكتوب فقط */
@media (min-width: 992px) {
  html[dir="rtl"] .nav-list {
    flex-direction: row;
  }
}

/* الخط العربي لعناصر الهيدر */
html[dir="rtl"] .nav-link,
html[dir="rtl"] .header-btn,
html[dir="rtl"] .lang-btn {
  font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* سويتش اللغة: AR يمين في العربي */
html[dir="rtl"] .lang-switch {
  direction: rtl;
}

/* منيو الموبايل بالعربي */
@media (max-width: 991.98px) {
  html[dir="rtl"] .header-nav {
    text-align: right;
  }

  html[dir="rtl"] .nav-list {
    align-items: flex-start;
  }
}
