/* =========================================================
   Header - Professional Design
   تصميم احترافي ومتناسق مع جميع الشاشات
   ========================================================= */

/* ===== CSS Variables ===== */
:root {
  --edu-green: #1b5e20;
  --edu-blue: #1976d2;
  --edu-orange: #ef6c00;
  --text-on: #ffffff;
  --text: #0f172a;
  --bg: #fff;
  --border: #e5e7eb;
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-hover: rgba(0, 0, 0, 0.12);

  --mx-container-max: 1200px;
  --mx-gap: clamp(12px, 2vw, 20px);

  --mx-topbar-h: clamp(36px, 4vw, 44px);
  --mx-mainbar-h-desktop: clamp(70px, 8vw, 90px);
  --mx-mainbar-h-mobile: clamp(60px, 7vw, 70px);

  --mx-header-offset: 0px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.mx-nav-open {
  overflow: hidden;
}

/* ===== Container ===== */
.mx-container {
  max-width: var(--mx-container-max);
  margin-inline: auto;
  padding-inline: var(--mx-gap);
  width: 100%;
}

/* ===== Header Structure ===== */
.mx-header {
  position: relative;
  z-index: 1000;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}

/* ===== Topbar: الشريط العلوي - تصميم احترافي وأنيق ===== */
.mx-topbar {
  background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
  color: var(--text-on);
  border-bottom: none;
  box-shadow: 0 2px 12px rgba(27, 94, 32, 0.15);
  position: relative;
  overflow: hidden;
  display: block;
}

.mx-topbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
}

.mx-topbar .mx-container {
  min-height: var(--mx-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.5vw, 16px);
  position: relative;
}

.mx-topbar-nav {
  flex: 1;
  min-width: 0;
  overflow: visible;
  display: flex;
  align-items: center;
}

.mx-menu--topbar {
  display: flex;
  gap: clamp(8px, 1.5vw, 16px);
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
  width: 100%;
  justify-content: flex-start;
}

/* زر القائمة المنسدلة للشاشات الصغيرة */
.mx-topbar-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-on);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
}

.mx-topbar-toggle:hover,
.mx-topbar-toggle:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mx-topbar-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.5;
}

.mx-topbar-toggle.is-open {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

.mx-topbar__extra {
  flex-shrink: 0;
}

.mx-menu--topbar li {
  position: relative;
  flex-shrink: 0;
}

.mx-menu--topbar a {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  padding: clamp(10px, 1.4vw, 14px) clamp(16px, 2.5vw, 24px);
  font-weight: 600;
  font-size: clamp(0.9rem, 1.3vw, 1rem);
  letter-spacing: 0.2px;
  white-space: nowrap;
  display: block;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: transparent;
}

.mx-menu--topbar a::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px;
}

.mx-menu--topbar a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px 2px 0 0;
}

.mx-menu--topbar a:hover,
.mx-menu--topbar a:focus {
  color: #ffffff;
  background: transparent;
  transform: translateY(0);
}

.mx-menu--topbar a:hover::before,
.mx-menu--topbar a:focus::before {
  opacity: 1;
}

.mx-menu--topbar a:hover::after,
.mx-menu--topbar a:focus::after {
  width: 70%;
}

.mx-menu--topbar .current-menu-item > a,
.mx-menu--topbar .current_page_item > a {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 700;
}

.mx-menu--topbar .current-menu-item > a::before,
.mx-menu--topbar .current_page_item > a::before {
  opacity: 1;
}

.mx-menu--topbar .current-menu-item > a::after,
.mx-menu--topbar .current_page_item > a::after {
  width: 70%;
  background: rgba(255, 255, 255, 1);
}

.mx-topbar__extra {
  flex-shrink: 0;
}

/* ===== Mainbar: الهيدر الرئيسي - تصميم أنيق واحترافي ===== */
.mx-mainbar {
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border-block-end: 2px solid transparent;
  background-image: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%), 
                    linear-gradient(90deg, var(--edu-green) 0%, var(--edu-blue) 50%, var(--edu-orange) 100%);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  position: relative;
}

.mx-mainbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(25, 118, 210, 0.3) 50%, transparent 100%);
}

.mx-mainbar__inner {
  min-height: var(--mx-mainbar-h-desktop);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mx-gap);
  position: relative;
}

/* ===== Brand: الشعار ===== */
.mx-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 10;
}

.mx-brand img {
  height: clamp(45px, 6vw, 60px);
  width: auto;
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.mx-brand__title {
  background: linear-gradient(135deg, var(--edu-green) 0%, var(--edu-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: -0.5px;
  position: relative;
}

.mx-brand__title::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--edu-green), var(--edu-blue));
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mx-brand__title:hover {
  transform: translateY(-1px);
}

.mx-brand__title:hover::after {
  width: 100%;
}

/* ===== Toggle Button: زر القائمة ===== */
.mx-toggle {
  width: clamp(44px, 5vw, 48px);
  height: clamp(44px, 5vw, 48px);
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 100;
  transition: transform 0.3s ease;
}

.mx-toggle:hover {
  transform: scale(1.05);
}

.mx-toggle__bar {
  background: linear-gradient(90deg, var(--edu-green), var(--edu-blue));
  display: block;
  width: clamp(24px, 3vw, 28px);
  height: 3px;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.mx-toggle.is-open .mx-toggle__bar:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.mx-toggle.is-open .mx-toggle__bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.mx-toggle.is-open .mx-toggle__bar:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

/* ===== Primary Navigation: القائمة الرئيسية ===== */
.mx-primary-nav {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  position: relative;
}

.mx-menu-wrapper {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}

.mx-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.mx-menu--primary {
  gap: clamp(2px, 0.8vw, 8px);
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  overflow: visible;
  position: relative;
  width: 100%;
  max-width: 100%;
}

.mx-menu--primary > li {
  position: relative;
  flex-shrink: 0;
}

.mx-menu--primary > li > a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(0.9rem, 1.3vw, 1rem);
  padding: clamp(10px, 1.4vw, 14px) clamp(14px, 2.2vw, 20px);
  border-block-end: 3px solid transparent;
  line-height: 1.5;
  display: block;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px 8px 0 0;
  position: relative;
  overflow: hidden;
}

.mx-menu--primary > li > a::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--edu-green), var(--edu-blue));
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px 2px 0 0;
}

.mx-menu--primary > li > a:hover,
.mx-menu--primary > li > a:focus {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(27, 94, 32, 0.08) 0%, rgba(25, 118, 210, 0.08) 100%);
  color: var(--edu-green);
  transform: translateY(-2px);
}

.mx-menu--primary > li > a:hover::before,
.mx-menu--primary > li > a:focus::before {
  width: 80%;
}

.mx-menu--primary > li.current-menu-item > a,
.mx-menu--primary > li.current_page_item > a,
.mx-menu--primary > li.current-menu-ancestor > a {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(27, 94, 32, 0.12) 0%, rgba(25, 118, 210, 0.12) 100%);
  color: var(--edu-green);
  font-weight: 800;
}

.mx-menu--primary > li.current-menu-item > a::before,
.mx-menu--primary > li.current_page_item > a::before,
.mx-menu--primary > li.current-menu-ancestor > a::before {
  width: 100%;
  background: linear-gradient(90deg, var(--edu-green), var(--edu-blue));
}

/* ===== Dropdown: القوائم الفرعية (Desktop) ===== */
.mx-menu--primary li:hover > ul,
.mx-menu--primary li:focus-within > ul {
  display: block;
}

.mx-menu--primary ul {
  display: none;
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 0;
  min-width: 240px;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(229, 231, 235, 0.8);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  margin-top: 8px;
  padding: 8px 0;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.mx-menu--primary ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--edu-green), var(--edu-blue), var(--edu-orange));
}

.mx-menu--primary ul li {
  position: relative;
}

.mx-menu--primary ul li a {
  display: block;
  padding: 12px 18px;
  white-space: nowrap;
  line-height: 1.6;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  margin: 0 4px;
  border-radius: 8px;
}

.mx-menu--primary ul li a::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, var(--edu-green), var(--edu-blue));
  border-radius: 0 4px 4px 0;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mx-menu--primary ul li a:hover,
.mx-menu--primary ul li a:focus {
  background: linear-gradient(90deg, rgba(27, 94, 32, 0.08) 0%, rgba(25, 118, 210, 0.08) 100%);
  color: var(--edu-green);
  padding-inline-start: 22px;
  transform: translateX(-2px);
}

.mx-menu--primary ul li a:hover::before,
.mx-menu--primary ul li a:focus::before {
  height: 60%;
}

.mx-menu--primary ul ul {
  inset-inline-start: 100%;
  inset-block-start: 0;
  margin-inline-start: 4px;
}

html[dir="rtl"] .mx-menu--primary ul ul {
  inset-inline-start: auto;
  inset-inline-end: 100%;
  margin-inline-start: 0;
  margin-inline-end: 4px;
}

/* ===== Overlay ===== */
.mx-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1090;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.mx-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mx-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.mx-overlay[hidden] {
  display: none !important;
}

/* ===== Accessibility ===== */
a:focus,
button:focus {
  outline: 3px solid var(--edu-orange);
  outline-offset: 2px;
}

/* ===== Responsive: Tablet (768px - 1024px) ===== */
@media (max-width: 1024px) {
  .mx-menu--primary {
    gap: 4px;
}

  .mx-menu--primary > li > a {
    padding: 10px 12px;
    font-size: 0.95rem;
  }
}

/* ===== Desktop: إخفاء القائمة المدمجة وإظهار القائمة العلوية ===== */
@media (min-width: 769px) {
  /* إخفاء القائمة المدمجة على الشاشات الكبيرة */
  .mx-mobile-topbar-menu {
    display: none !important;
  }

  /* إظهار القائمة العلوية على الشاشات الكبيرة */
  .mx-topbar {
    display: block !important;
  }

  /* إخفاء زر الإغلاق على الشاشات الكبيرة */
  .mx-close-btn {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* ===== Medium Desktop: Scroll أفقي إذا لزم الأمر ===== */
@media (min-width: 769px) and (max-width: 1400px) {
  .mx-menu-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: 4px;
    margin-bottom: -4px;
  }

  .mx-menu-wrapper::-webkit-scrollbar {
    height: 4px;
  }

  .mx-menu-wrapper::-webkit-scrollbar-track {
    background: transparent;
  }

  .mx-menu-wrapper::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  .mx-menu-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--edu-orange);
  }

  .mx-menu--primary {
    min-width: max-content;
    width: max-content;
  }
}

/* ===== Responsive: Mobile (max-width: 768px) ===== */
@media (max-width: 768px) {
  .mx-mainbar__inner {
    min-height: var(--mx-mainbar-h-mobile);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(8px, 2vw, 12px);
  }

  /* Toggle Button */
  .mx-toggle {
    display: flex;
    grid-column: 1;
    justify-self: start;
  }

  html[dir="ltr"] .mx-toggle {
    justify-self: end;
    grid-column: 3;
  }

  /* Brand */
  .mx-brand {
    grid-column: 2;
    justify-content: center;
  }

  /* Primary Navigation - Hidden by default */
  .mx-primary-nav {
    display: none;
  }

  /* Hide topbar completely on mobile */
  .mx-topbar {
    display: none !important;
  }

  /* Hide topbar when mobile menu is open (backup) */
  .mx-topbar--hidden {
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s ease, 
                visibility 0.3s ease;
  }

  /* After JS loads - Mobile Menu */
  .mx-js .mx-primary-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: min(85vw, 380px);
    max-width: 100%;
    height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-inline-start: 3px solid var(--edu-blue);
    box-shadow: -8px 0 32px var(--shadow-hover);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    overflow-y: auto;
    overflow-x: hidden;
    visibility: hidden;
    will-change: transform;
  }

  html[dir="ltr"] .mx-js .mx-primary-nav {
    right: auto;
    left: 0;
    border-inline-start: none;
    border-inline-end: 3px solid var(--edu-blue);
    box-shadow: 8px 0 32px var(--shadow-hover);
  }

  /* Menu Open State */
  .mx-js .mx-primary-nav.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  /* زر الإغلاق */
  .mx-close-btn {
    display: none;
    position: absolute;
    top: clamp(16px, 3vw, 24px);
    left: clamp(16px, 3vw, 24px);
    width: 44px;
    height: 44px;
    border: 2px solid var(--edu-blue);
    background: #fff;
    color: var(--edu-blue);
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
  }

  .mx-close-btn:hover,
  .mx-close-btn:focus {
    background: var(--edu-blue);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.3);
  }

  .mx-close-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  .mx-js .mx-primary-nav.is-open .mx-close-btn {
    display: flex;
  }

  /* إخفاء القائمة العلوية على الموبايل */
  .mx-topbar {
    display: none !important;
  }

  /* القائمة العلوية المدمجة في الموبايل - نفس تصميم القائمة الرئيسية تماماً */
  .mx-mobile-topbar-menu {
    display: none;
    padding: 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .mx-js .mx-primary-nav.is-open .mx-mobile-topbar-menu {
    display: block;
  }

  /* توحيد الحاويات: نفس المساحات للقائمة العلوية المدمجة والقائمة الرئيسية */
  .mx-mobile-topbar-menu,
  .mx-menu-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    display: block !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    overflow: visible !important;
  }

  /* توحيد القائمتين: استخدام نفس القواعد للقائمة العلوية المدمجة والقائمة الرئيسية */
  .mx-menu--mobile-topbar,
  .mx-menu--primary {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 clamp(16px, 3vw, 24px) clamp(16px, 3vw, 24px) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    align-items: stretch !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
  }

  .mx-menu--mobile-topbar > li,
  .mx-menu--primary > li {
    width: 100% !important;
    border-bottom: 1px solid var(--border) !important;
    position: relative !important;
    flex-shrink: 0 !important;
  }

  .mx-menu--mobile-topbar > li:last-child,
  .mx-menu--primary > li:last-child {
    border-bottom: none !important;
  }

  .mx-menu--mobile-topbar > li > a,
  .mx-menu--primary > li > a {
    padding: clamp(14px, 2.5vw, 18px) clamp(16px, 3vw, 24px) !important;
    border: 0 !important;
    border-inline-start: 4px solid transparent !important;
    font-size: 1.05rem !important;
    line-height: 1.6 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    color: var(--text) !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    white-space: normal !important;
    border-block-end: 0 !important;
    border-radius: 0 !important;
    transform: none !important;
  }

  .mx-menu--mobile-topbar > li > a::before,
  .mx-menu--primary > li > a::before {
    display: none !important;
  }

  .mx-menu--mobile-topbar > li > a:hover,
  .mx-menu--mobile-topbar > li > a:focus,
  .mx-menu--primary > li > a:hover,
  .mx-menu--primary > li > a:focus {
    border-inline-start-color: var(--edu-orange) !important;
    background: rgba(239, 108, 0, 0.08) !important;
    color: var(--edu-orange) !important;
    transform: none !important;
  }

  .mx-menu--mobile-topbar > li > a:hover::before,
  .mx-menu--mobile-topbar > li > a:focus::before,
  .mx-menu--primary > li > a:hover::before,
  .mx-menu--primary > li > a:focus::before {
    display: none !important;
  }

  .mx-menu--mobile-topbar > li.current-menu-item > a,
  .mx-menu--mobile-topbar > li.current_page_item > a,
  .mx-menu--primary > li.current-menu-item > a,
  .mx-menu--primary > li.current_page_item > a {
    border-inline-start-color: var(--edu-green) !important;
    background: rgba(27, 94, 32, 0.08) !important;
    color: var(--edu-green) !important;
    font-weight: 700 !important;
  }

  .mx-menu--mobile-topbar > li.current-menu-item > a::before,
  .mx-menu--mobile-topbar > li.current_page_item > a::before,
  .mx-menu--primary > li.current-menu-item > a::before,
  .mx-menu--primary > li.current_page_item > a::before {
    display: none !important;
  }

  /* Dropdown Indicator */
  .mx-menu--mobile-topbar > li.menu-item-has-children > a::after,
  .mx-menu--primary > li.menu-item-has-children > a::after {
    content: "▼" !important;
    font-size: 0.7rem !important;
    margin-inline-start: 8px !important;
    transition: transform 0.3s ease !important;
    opacity: 0.5 !important;
  }

  .mx-menu--mobile-topbar > li.menu-item-has-children.open > a::after,
  .mx-menu--primary > li.menu-item-has-children.open > a::after {
    transform: rotate(180deg) !important;
  }

  /* Mobile Dropdown */
  .mx-menu--mobile-topbar ul,
  .mx-menu--primary ul {
    position: static !important;
    display: none !important;
    border: 0 !important;
    box-shadow: none !important;
    background: rgba(0, 0, 0, 0.02) !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    min-width: auto !important;
    inset-block-start: auto !important;
    inset-inline-start: auto !important;
  }

  .mx-menu--mobile-topbar ul::before,
  .mx-menu--primary ul::before {
    display: none !important;
  }

  .mx-menu--mobile-topbar li.open > ul,
  .mx-menu--mobile-topbar li.menu-item-has-children.open > ul,
  .mx-menu--primary li.open > ul,
  .mx-menu--primary li.menu-item-has-children.open > ul {
    display: block !important;
  }

  .mx-menu--mobile-topbar ul li,
  .mx-menu--primary ul li {
    position: relative !important;
  }

  .mx-menu--mobile-topbar ul li a,
  .mx-menu--primary ul li a {
    padding: 12px clamp(16px, 3vw, 24px) 12px clamp(32px, 5vw, 48px) !important;
    font-size: 0.95rem !important;
    color: #475569 !important;
    display: block !important;
    white-space: normal !important;
    line-height: 1.6 !important;
    font-weight: 700 !important;
  }

  .mx-menu--mobile-topbar ul li a::before,
  .mx-menu--primary ul li a::before {
    display: none !important;
  }

  .mx-menu--mobile-topbar ul li a:hover,
  .mx-menu--mobile-topbar ul li a:focus,
  .mx-menu--primary ul li a:hover,
  .mx-menu--primary ul li a:focus {
    background: rgba(27, 94, 32, 0.1) !important;
    color: var(--edu-green) !important;
    padding-inline-start: clamp(36px, 5.5vw, 52px) !important;
    transform: none !important;
  }

  .mx-menu--mobile-topbar ul li a:hover::before,
  .mx-menu--mobile-topbar ul li a:focus::before,
  .mx-menu--primary ul li a:hover::before,
  .mx-menu--primary ul li a:focus::before {
    display: none !important;
  }

  .mx-menu--mobile-topbar ul ul,
  .mx-menu--primary ul ul {
    position: static !important;
    margin: 0 !important;
    inset-inline-start: auto !important;
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
  }

  .mx-menu--mobile-topbar ul ul li a,
  .mx-menu--primary ul ul li a {
    padding-inline-start: clamp(48px, 7vw, 64px) !important;
  }

  /* Mobile Menu List - القائمة الرئيسية تستخدم نفس القواعد المشتركة أعلاه */
  .mx-menu--primary {
    flex: 1;
    overflow-y: auto;
  }

  /* Topbar Mobile - قائمة منسدلة احترافية وأنيقة */
  .mx-topbar .mx-container {
    flex-wrap: nowrap;
    min-height: var(--mx-topbar-h);
    padding-block: clamp(10px, 2vw, 14px);
    padding-inline: clamp(12px, 2.5vw, 20px);
    position: relative;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }

  .mx-topbar-toggle {
    display: flex;
    position: static;
    left: auto;
    transform: none;
    top: auto;
    margin-top: 0;
    z-index: 15;
    order: 2;
    flex-shrink: 0;
  }

  .mx-topbar-toggle:hover,
  .mx-topbar-toggle:focus {
    transform: scale(1.05);
  }

  .mx-topbar-toggle.is-open {
    transform: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  .mx-topbar-nav {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
                margin 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
    opacity: 0;
    order: 3;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
    box-shadow: 0 8px 24px rgba(27, 94, 32, 0.3);
    z-index: 1000;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }

  .mx-topbar-nav.is-open {
    max-height: 80vh;
    padding: clamp(16px, 3vw, 24px) clamp(16px, 3vw, 24px) clamp(12px, 2.5vw, 20px);
    margin-top: 0;
    opacity: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mx-menu--topbar {
    flex-direction: column;
    gap: 0;
    width: 100%;
    align-items: stretch;
    flex-wrap: nowrap;
    text-align: right;
    direction: rtl;
    padding: 0;
    margin: 0;
  }

  .mx-menu--topbar li {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transition: background 0.2s ease;
    margin: 0;
  }

  .mx-menu--topbar li:last-child {
    border-bottom: none;
  }

  .mx-menu--topbar li:hover {
    background: transparent;
  }

  .mx-menu--topbar a {
    font-size: clamp(0.95rem, 1.6vw, 1.05rem);
    padding: clamp(14px, 2.5vw, 18px) clamp(18px, 3.5vw, 26px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: right;
    direction: rtl;
    border-radius: 0;
    margin: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    min-height: 48px;
  }

  .mx-menu--topbar a::before {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(255, 255, 255, 0.9);
    transform: scaleY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 4px 4px 0;
  }

  .mx-menu--topbar a::after {
    content: "←";
    margin-left: 12px;
    opacity: 0.6;
    transform: translateX(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1em;
    font-weight: 600;
    flex-shrink: 0;
  }

  .mx-menu--topbar a:hover,
  .mx-menu--topbar a:focus {
    background: rgba(255, 255, 255, 0.12);
    padding-inline-end: clamp(18px, 3.5vw, 26px);
    transform: translateX(0);
    color: #ffffff;
  }

  .mx-menu--topbar a:hover::before,
  .mx-menu--topbar a:focus::before {
    transform: scaleY(1);
  }

  .mx-menu--topbar a:hover::after,
  .mx-menu--topbar a:focus::after {
    opacity: 1;
    transform: translateX(-4px);
  }

  .mx-menu--topbar .current-menu-item > a,
  .mx-menu--topbar .current_page_item > a {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-weight: 700;
    padding-inline-end: clamp(18px, 3.5vw, 26px);
  }

  .mx-menu--topbar .current-menu-item > a::before,
  .mx-menu--topbar .current_page_item > a::before {
    transform: scaleY(1);
  }

  .mx-menu--topbar .current-menu-item > a::after,
  .mx-menu--topbar .current_page_item > a::after {
    opacity: 1;
    transform: translateX(-4px);
  }

  .mx-topbar__extra {
    display: none;
  }
}

/* ===== Responsive: Small Mobile (max-width: 480px) ===== */
@media (max-width: 480px) {
  .mx-mainbar__inner {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }

  .mx-toggle {
    width: 40px;
    height: 40px;
  }

  .mx-toggle__bar {
    width: 22px;
  }

  .mx-brand img {
    height: 40px;
  }

  .mx-brand__title {
    font-size: 1rem;
  }

  .mx-js .mx-primary-nav {
    width: 90vw;
  }

  .mx-menu--primary > li > a {
    font-size: 1rem;
    padding: 14px 16px;
  }

  .mx-topbar-toggle {
    width: 38px;
    height: 38px;
    margin-top: 0;
  }

  .mx-topbar-toggle svg {
    width: 18px;
    height: 18px;
  }

  .mx-topbar .mx-container {
    padding-inline: clamp(10px, 2vw, 14px);
    gap: 8px;
  }

  .mx-topbar-nav.is-open {
    padding: clamp(12px, 2.2vw, 18px) clamp(12px, 2.2vw, 18px) clamp(10px, 1.8vw, 14px);
    max-height: 75vh;
  }

  .mx-menu--topbar a {
    padding: clamp(12px, 2vw, 16px) clamp(14px, 2.5vw, 22px);
    font-size: clamp(0.9rem, 1.4vw, 0.98rem);
    min-height: 44px;
  }

  /* تحسينات إضافية للقائمة العلوية على الشاشات الصغيرة */
  .mx-topbar-nav.is-open {
    max-height: 75vh;
  }

  .mx-menu--topbar a {
    min-height: 44px;
  }
}

/* ===== Responsive: Extra Small (max-width: 360px) ===== */
@media (max-width: 360px) {
  .mx-container {
    padding-inline: 10px;
  }

  .mx-mainbar__inner {
    gap: 6px;
  }

  .mx-toggle {
    width: 36px;
    height: 36px;
  }

  .mx-toggle__bar {
    width: 20px;
    height: 2.5px;
  }

  .mx-brand img {
    height: 36px;
  }

  .mx-brand__title {
    font-size: 0.9rem;
  }

  .mx-js .mx-primary-nav {
    width: 95vw;
  }
}

/* ===== Print Styles ===== */
@media print {
  .mx-header {
    display: none;
  }
}
