/* ========================================== */
/* استایل منوی چندزبانه - با همبرگر و ستون‌بندی */
/* متن آیتم‌ها هرگز شکسته نمی‌شود */
/* ========================================== */

/* تعریف فونت‌ها */
@font-face {
  font-family: "Caza";
  src:
    url("./App_Styles/Font/FarCasablanca.eot?#") format("eot"),
    url("../App_Styles/Font/FarCasablanca.woff") format("woff"),
    url("./App_Styles/Font/FarCasablanca.ttf") format("truetype");
}
@font-face {
  font-family: "Yekan";
  src:
    url("./App_Styles/Font/IRANSans-Light-web.eot?#") format("eot"),
    url("../App_Styles/Font/IRANSans-Light-web.woff") format("woff"),
    url("./App_Styles/Font/IRANSans-Light-web.ttf") format("truetype");
}

/* ========================================== */
/* کانتینر منو */
/* ========================================== */
#menu-container {
  width: 100%;
  position: relative;
  z-index: 999;

  /* ⭐⭐ اصلاح: استفاده از متغیر به جای مقدار ثابت */
  margin-top: var(--menu-top-margin, 8px);

  padding: 0 var(--side-spacing, 0.3cm);
  box-sizing: border-box;
}

/* ========================================== */
/* منوی اصلی */
/* ========================================== */
.menu {
  background-color: #f3f2f2;
  padding: 0.8vh 1.2vw;
  position: relative;
  width: 100%;
  height: auto;
  min-height: 56px;
  border-radius: 1vw;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}
.menu-list {
  flex: 1;
  justify-content: flex-start;
  gap: 0.5vw;
  padding-right: 1.2vw;
}

/* ========================================== */
/* آیتم‌های منو */
/* ========================================== */
.menu-item {
  align-items: center;
  position: relative;
  margin: 0.2cm 0;
}

/* ========================================== */
/* ⭐⭐ متغیرهای اندازه فونت منو برای هر زبان */
/* ========================================== */

/* زبان فارسی (FA) */
.menu[lang="fa"] .menu-item > a {
  font-size: var(--menu-fa-font-size, 18px) !important;
  padding: 0.8vh 1.2vw !important;
}

/* زبان انگلیسی (EN) */
.menu[lang="en"] .menu-item > a {
  font-size: var(--menu-en-font-size, 16px) !important;
  padding: 0.8vh 1.2vw !important;
}

/* زبان عربی (AR) */
.menu[lang="ar"] .menu-item > a {
  font-size: var(--menu-ar-font-size, 18px) !important;
  padding: 0.8vh 1.2vw !important;
}

/* زبان روسی (RU) */
.menu[lang="ru"] .menu-item > a {
  font-size: var(--menu-ru-font-size, 14px) !important;
  padding: 0.6vh 0.8vw !important;
}

/* زبان عبری (HE) */
.menu[lang="he"] .menu-item > a {
  font-size: var(--menu-he-font-size, 18px) !important;
  padding: 0.8vh 1.2vw !important;
}

/* زبان چینی (ZH) */
.menu[lang="zh"] .menu-item > a {
  font-size: var(--menu-zh-font-size, 16px) !important;
  padding: 0.8vh 1.2vw !important;
}

/* ========================================== */
/* ⭐⭐ فاصله بین آیتم‌های منو - هر زبان */
/* ========================================== */

/* زبان فارسی (FA) */
.menu[lang="fa"] .menu-list {
  gap: var(--menu-fa-gap, 10px) !important;
}

/* زبان انگلیسی (EN) */
.menu[lang="en"] .menu-list {
  gap: var(--menu-en-gap, 10px) !important;
}

/* زبان عربی (AR) */
.menu[lang="ar"] .menu-list {
  gap: var(--menu-ar-gap, 10px) !important;
}

/* زبان روسی (RU) */
.menu[lang="ru"] .menu-list {
  gap: var(--menu-ru-gap, 12px) !important;
}

/* زبان عبری (HE) */
.menu[lang="he"] .menu-list {
  gap: var(--menu-he-gap, 10px) !important;
}

/* زبان چینی (ZH) */
.menu[lang="zh"] .menu-list {
  gap: var(--menu-zh-gap, 10px) !important;
}

/* ========================================== */
/* استایل پایه لینک‌های منو */
/* ========================================== */
.menu a {
  text-decoration: none;
  cursor: pointer;
  color: #444;
  opacity: 0.9;
  font-family: "Caza", "Segoe UI", Tahoma, sans-serif;
  border-radius: 0.6vw;
  transition:
    background-color 0.3s,
    color 0.3s;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.menu a:hover {
  background-color: #91bcee;
  color: #1a1a2e;
}

/* ========================================== */
/* زیرمنوها - با ستون‌بندی و عرض کافی برای متن بدون شکست */
/* ========================================== */
.submenu {
  position: absolute;
  top: 100%;
  border-radius: 0.6vw;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    visibility 0s 0.3s;
  overflow-y: auto;
  padding: 0.5vh 0.5vw;
  margin: 0;
  background: #f3f2f2;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border: 1px solid #e0e0e0;
  border-top: none;
  z-index: 1001;

  /* ستون‌بندی با فلکس - حداقل ۵ آیتم در هر ستون */
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  align-content: flex-start;
  max-height: 420px; /* ارتفاع کافی برای ۵ ردیف */
  column-gap: 0.5vw;
}

/* ⭐ تغییر اصلی: عرض آیتم‌ها به‌قدری افزایش یافته که متن در یک خط بماند */
.submenu li {
  margin: 0;
  flex: 0 0 auto;
  min-width: 220px; /* ⭐ عرض کافی برای بلندترین متن‌ها (روسی، چینی، ...) */
  max-width: none; /* بدون محدودیت برای جاگیری متن کامل */
  break-inside: avoid;
  page-break-inside: avoid;
}

.menu-item:hover .submenu {
  visibility: visible;
  opacity: 1;
  transition:
    opacity 0.3s ease,
    visibility 0s;
}

/* ========================================== */
/* ⭐ لینک‌های زیرمنو - متن هرگز شکسته نمی‌شود */
/* ========================================== */
.submenu a {
  padding: 0.5vh 0.8vw;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: right;
  font-family: "Yekan", "IRANSans", "Segoe UI", Tahoma, sans-serif;
  font-size: clamp(0.8rem, 1vw + 0.2rem, 1.1rem);
  color: #004985;
  white-space: nowrap; /* ⭐⭐ کلید اصلی: متن هرگز شکسته نمی‌شود */
  background: transparent;
  border-radius: 0;
  width: 100%; /* پر کردن عرض li */
  line-height: 1.4;
}
.submenu a:hover {
  background-color: #5d9cbf;
  color: #ffffff;
}

/* ========================================== */
/* عرض و موقعیت زیرمنوها (با ستون‌بندی) */
/* ========================================== */
.submenu-1,
.submenu-2,
.submenu-3,
.submenu-4 {
  right: 0;
  width: auto;
  min-width: 320px;
  max-width: 750px;
  top: 1.2cm;
}
.submenu-4 {
  left: 0;
  right: auto;
}

/* ========================================== */
/* آیکون‌ها */
/* ========================================== */
.MenuIcon {
  width: 2vw;
  height: auto;
  flex-shrink: 0;
  min-width: 18px;
  max-width: 26px;
  transition: transform 0.3s ease; /* ⭐ اضافه کردن انیمیشن */
}

/* ========================================== */
/* ⭐⭐ چرخش 180 درجه فلش منو در LTR (انگلیسی، روسی، چینی) ⭐⭐ */
/* ========================================== */

/* فلش در RTL (فارسی، عربی، عبری) - بدون چرخش */
.menu[dir="rtl"] .MenuIcon {
  transform: rotate(0deg);
}

/* فلش در LTR (انگلیسی، روسی، چینی) - 180 درجه چرخش */
.menu[dir="ltr"] .MenuIcon {
  transform: rotate(180deg);
}

/* ========================================== */
/* دکمه همبرگر - سه خط بزرگ (قابل مشاهده) */
/* ========================================== */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
  border-radius: 4px;
  transition: background 0.3s;
  width: 44px;
  height: 44px;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
}
.hamburger span {
  display: block;
  width: 32px;
  height: 4px;
  background-color: #444;
  margin: 4px 0;
  border-radius: 3px;
  transition: all 0.3s ease;
}
.hamburger:hover {
  background: rgba(0, 0, 0, 0.05);
}
.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
  width: 32px;
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}
.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
  width: 32px;
}

/* ========================================== */
/* حالت راست‌چین / چپ‌چین */
/* ========================================== */
.menu[dir="rtl"] .submenu {
  right: 0;
  left: auto;
}
.menu[dir="rtl"] .submenu-4 {
  left: auto;
  right: 0;
}
.menu[dir="rtl"] .submenu a {
  text-align: right;
}
.menu[dir="rtl"] .menu-list {
  padding-right: 0.5vw;
  padding-left: 0;
}

.menu[dir="ltr"] .submenu {
  left: 0;
  right: auto;
}
.menu[dir="ltr"] .submenu-4 {
  right: auto;
  left: 0;
}
.menu[dir="ltr"] .submenu a {
  text-align: left;
}
.menu[dir="ltr"] .menu-list {
  padding-left: 0.5vw;
  padding-right: 0;
}

/* ========================================== */
/* ⭐⭐ استایل فروشگاه (به زودی) */
/* ========================================== */

/* استایل آیتم فروشگاه - هر کجا که کلاس shop-link باشد */
.menu-item > a.shop-link {
  color: #2ecc71 !important;
  font-weight: 700 !important;
  position: relative;
}

/* انیمیشن چشمک زدن سبز */
@keyframes pulse-green {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

/* هاور روی فروشگاه */
.menu-item > a.shop-link:hover {
  background-color: rgba(46, 204, 113, 0.15) !important;
  color: #27ae60 !important;
}

/* ========================================== */
/* واکنش‌گرا - موبایل (عرض < 900px) */
/* ========================================== */
@media (max-width: 900px) {
  .hamburger {
    display: flex; /* نمایش همبرگر در موبایل */
  }

  #menu-container {
    padding: 0 var(--side-spacing, 0.1cm);
    /* ⭐⭐ اصلاح: استفاده از متغیر در موبایل */
    margin-top: var(--menu-top-margin, 8px);
  }

  .menu {
    height: auto;
    padding: 0.6vh 2vw;
    flex-wrap: wrap;
    border-radius: 10px;
    min-height: 50px;
    width: 100%;
  }

  .menu-list {
    display: none !important;
    flex-direction: column;
    width: 100%;
    background-color: #f3f2f2;
    padding: 0.8vh 0;
    margin-top: 0.5vh;
    border-top: 1px solid #ddd;
    flex: none;
    max-height: 65vh;
    overflow-y: auto;
    gap: 0;
    padding-right: 0;
  }
  .menu-list.open {
    display: flex !important;
  }

  .menu-item {
    width: 100%;
    margin: 0;
    border-bottom: 1px solid #eee;
  }
  .menu-item > a {
    display: block;
    padding: 1.2vh 4vw;
    border-radius: 0;
    background-color: transparent;
    white-space: normal;
    font-size: 1.1rem;
    width: 100%;
  }
  .menu-item > a:hover {
    background-color: transparent;
  }

  /* زیرمنو در موبایل - به‌صورت عمودی با متن بدون شکست */
  .submenu {
    position: static;
    visibility: visible;
    opacity: 1;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    background: #eaeaea;
    border-radius: 0;
    box-shadow: none;
    transition: max-height 0.4s ease;
    width: 100% !important;
    max-width: 100% !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    border: none;
    display: block; /* لغو ستون‌بندی در موبایل */
    flex-wrap: nowrap;
    flex-direction: column;
    max-height: 0;
  }
  .submenu.open {
    max-height: 450px;
    overflow-y: auto;
  }
  .submenu li {
    width: 100%;
    min-width: auto;
    max-width: none;
    flex: none;
  }
  /* ⭐ در موبایل هم متن نشکند */
  .submenu a {
    padding: 0.8vh 6vw;
    white-space: nowrap; /* ⭐ متن در موبایل هم یک خطی می‌ماند */
    border-bottom: 1px solid #ddd;
    width: 100% !important;
    min-width: auto !important;
    max-width: none !important;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    overflow-x: auto; /* در صورت لزوم اسکرول افقی برای متن‌های خیلی بلند */
  }
  .submenu a:hover {
    background-color: #d0d0d0;
    color: #004985;
  }

  .MenuIcon {
    width: 5vw;
    min-width: 22px;
    max-width: 28px;
  }

  /* غیرفعال کردن هاور در موبایل */
  .menu-item:hover .submenu {
    visibility: visible;
    opacity: 1;
    max-height: 0;
  }
  .menu-item:hover .submenu.open {
    max-height: 450px;
  }

  /* ========================================== */
  /* ⭐⭐ فروشگاه در موبایل - خط جداکننده در بالا */
  /* ========================================== */
  .menu-item.shop-item {
    border-top: 2px solid #2ecc71;
    border-bottom: none;
    padding-top: 8px;
    margin-top: 5px;
  }
  .menu-item.shop-item > a.shop-link {
    color: #2ecc71 !important;
  }

  /* ========================================== */
  /* ⭐⭐ تنظیمات روسی در موبایل */
  /* ========================================== */
  .menu[lang="ru"] .menu-item > a {
    font-size: var(--menu-ru-font-size-mobile, 12px) !important;
    padding: 0.8vh 1.5vw !important;
  }
  .menu[lang="ru"] .menu-list {
    gap: var(--menu-ru-gap-mobile, 6px) !important;
  }

  /* ========================================== */
  /* ⭐⭐ تنظیمات سایر زبان‌ها در موبایل */
  /* ========================================== */
  .menu[lang="fa"] .menu-item > a {
    font-size: var(--menu-fa-font-size-mobile, 16px) !important;
  }
  .menu[lang="en"] .menu-item > a {
    font-size: var(--menu-en-font-size-mobile, 14px) !important;
  }
  .menu[lang="ar"] .menu-item > a {
    font-size: var(--menu-ar-font-size-mobile, 16px) !important;
  }
  .menu[lang="he"] .menu-item > a {
    font-size: var(--menu-he-font-size-mobile, 16px) !important;
  }
  .menu[lang="zh"] .menu-item > a {
    font-size: var(--menu-zh-font-size-mobile, 14px) !important;
  }
}

/* ========================================== */
/* صفحه‌های خیلی کوچک */
/* ========================================== */
@media (max-width: 480px) {
  #menu-container {
    padding: 0 var(--side-spacing, 0.05cm);
    /* ⭐⭐ اصلاح: استفاده از متغیر در موبایل کوچک */
    margin-top: var(--menu-top-margin, 6px);
  }
  .menu-item > a {
    font-size: 0.95rem;
    padding: 1vh 3vw;
  }
  .submenu a {
    font-size: 0.8rem;
    padding: 0.6vh 5vw;
    white-space: nowrap; /* ⭐ در صفحه‌های خیلی کوچک هم یک خطی */
  }
  .hamburger span {
    width: 28px;
    height: 3px;
    margin: 3px 0;
  }
  .menu {
    padding: 0.4vh 2vw;
    min-height: 44px;
  }
  .MenuIcon {
    width: 4.5vw;
    min-width: 18px;
  }

  /* ⭐⭐ تنظیمات روسی در موبایل خیلی کوچک */
  .menu[lang="ru"] .menu-item > a {
    font-size: var(--menu-ru-font-size-mobile-small, 10px) !important;
    padding: 0.6vh 1vw !important;
  }
  .menu[lang="ru"] .menu-list {
    gap: var(--menu-ru-gap-mobile-small, 4px) !important;
  }

  /* ⭐⭐ تنظیمات سایر زبان‌ها در موبایل خیلی کوچک */
  .menu[lang="fa"] .menu-item > a {
    font-size: var(--menu-fa-font-size-mobile-small, 14px) !important;
  }
  .menu[lang="en"] .menu-item > a {
    font-size: var(--menu-en-font-size-mobile-small, 12px) !important;
  }
  .menu[lang="ar"] .menu-item > a {
    font-size: var(--menu-ar-font-size-mobile-small, 14px) !important;
  }
  .menu[lang="he"] .menu-item > a {
    font-size: var(--menu-he-font-size-mobile-small, 14px) !important;
  }
  .menu[lang="zh"] .menu-item > a {
    font-size: var(--menu-zh-font-size-mobile-small, 12px) !important;
  }
}

/* ========================================== */
/* انیمیشن‌ها و اسکرول */
/* ========================================== */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.submenu.open {
  animation: fadeInDown 0.3s ease;
}

.submenu::-webkit-scrollbar {
  width: 5px;
}
.submenu::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}
.submenu::-webkit-scrollbar-thumb {
  background: #91bcee;
  border-radius: 4px;
}
.submenu::-webkit-scrollbar-thumb:hover {
  background: #5d9cbf;
}
