/* ----------------- هدر سایت ----------------- */
body {
  font-family: sans-serif;
  direction: rtl;
  margin: 0;
  padding: 0;
  background-color: #fff;
}

header {
  background-color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 2px 8px rgb(22 7 7 / 33%);
}

.header-container {
  max-width: 1200px;
  margin: auto;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ----------------- بخش راست هدر (لوگو و سرچ) ----------------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 0;
}

.logo-img {
  height: 40px;
  width: auto;
  display: block;
}

.search-box {
  margin-right: 10px;
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 8px;
  background-color: #f1f2f4;
  overflow: hidden;
  height: 40px;
  width: 400px;
}

.search-box input {
  flex: 1;
  border: none;
  padding: 0 12px;
  font-size: 14px;
  background-color: transparent;
  outline: none;
  direction: rtl;
}

.search-box button {
  background-color: transparent;
  border: none;
  padding: 0 12px;
  font-size: 18px;
  color: #424750;
  cursor: pointer;
}

/* ----------------- بخش چپ هدر (ورود و سبد خرید) ----------------- */
.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* دکمه ورود | ثبت‌نام */
.login-btn {
  text-decoration: none;
  border: 1px solid #000;
  color: #000;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 14px;
  transition: 0.2s ease;
}

.login-btn:hover {
  background-color: #000;
  color: #fff;
}

/* آیکن سبد خرید */
.cart-icon {
  text-decoration: none;
  color: #333;
  font-size: 20px;
  position: relative;
}

.cart-count {
  background-color: red;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  position: absolute;
  top: -5px;
  left: 15px;
}

/* ----------------- نتایج جستجو ----------------- */
.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.search-results div {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #f1f1f1;
}

.search-results div:hover {
  background: #f9f9f9;
}

/* ---------- منوی کاربر ---------- */
.user-menu {
  position: relative;
  display: inline-block;
}

.user-toggle {
  display: flex;
  gap: 6px;
  transition: all 0.3s ease;
  width: 37px;
  height: 37px;
}

/*.user-toggle img {
  width: 30px;
  height: 30px;
}*/

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

/* منوی کشویی مخفی به صورت پیش‌فرض */
.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  width: 200px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  padding: 10px 0;
  z-index: 999;
  animation: fadeIn 0.2s ease-in-out;
}

.user-dropdown.active {
  display: block;
}

.user-dropdown li {
  list-style: none;
}

.user-dropdown li a {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.user-dropdown li a:hover {
  background-color: #f7f7f7;
}

.user-dropdown hr {
  margin: 6px 0;
  border: 0;
  border-top: 1px solid #eee;
}

/* انیمیشن نمایش */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================
   📱 استایل مخصوص موبایل
   ===================== */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 16px;
  }

  .header-top-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .logo-center-mobile {
    flex: 1;
    text-align: center;
  }

  .logo-img {
    height: 35px;
    margin: auto;
  }

  .header-right {
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .search-box {
    width: 100%;
    margin: 0;
  }

  .header-left {
    order: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
  }

  .login-btn {
    font-size: 13px;
    padding: 5px 12px;
  }

  .cart-icon {
    font-size: 18px;
  }

  .main-menu ul {
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 8px;
  }

  .main-menu>ul>li {
    position: relative;
  }

  .main-menu ul li a {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
  }

  .main-menu ul li ul.sub-menu {
    display: none;
    flex-direction: column;
    border: 1px solid #eee;
    margin-top: 4px;
    border-radius: 6px;
    padding: 5px;
    background: #f9f9f9;
  }

  .main-menu ul li:hover ul.sub-menu {
    display: flex;
  }
}

/* پیش‌فرض */
.site-header-m {
  display: none;
}

.search-results-m {
  max-height: 250px;
  overflow-x: auto;
}

/* استایل‌های هدر موبایل */
.site-header-m {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  background: white;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-container-m {
  padding: 10px 15px;
}

.header-top-m {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-top-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.menu-toggle-m {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
}

.logo-img {
  height: 40px;
}

.header-bottom-m {
  margin-top: 10px;
}

.search-box-m {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.search-box-m input {
  flex: 1;
  border: none;
  padding: 10px;
  outline: none;
  background: #f5f5f5;
}

.search-box-m button {
  border: none;
  background: #f0f0f0;
  padding: 0 15px;
  cursor: pointer;
}

/* استایل سایدبار موبایل */
.mobile-sidebar {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100%;
  background: white;
  z-index: 1001;
  transition: right 0.3s ease;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.mobile-sidebar.active {
  right: 0;
}

.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
}

.close-menu {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu>li {
  border-bottom: 1px solid #eee;
}

.sidebar-menu a {
  display: block;
  padding: 15px;
  text-decoration: none;
  color: #333;
  transition: background 0.2s;
}

.sidebar-menu a:hover {
  background: #f5f5f5;
}

.has-submenu {
  position: relative;
}

.submenu-toggle {
  position: absolute;
  left: 15px;
  top: 15px;
  transform: rotate(0);
  transition: transform 0.3s;
  cursor: pointer;
  font-size: 18px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.has-submenu.active .submenu-toggle {
  transform: rotate(90deg);
}

.sub-menu-m {
  display: none;
  padding-right: 20px;
  background: #f9f9f9;
}

.sub-menu-m li {
  border-bottom: 1px solid #eee;
  list-style: n;
}

.sub-menu-m a {
  padding: 12px 15px;
  font-size: 14px;
}

.has-submenu.active .sub-menu-m {
  display: block;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* استایل‌های منوی کاربر */
.user-menu-m {
  position: relative;
}

.login-btn-m {
  padding: 0 !important;
}

.login-btn-m:hover {
  background-color: unset !important;
}

.user-toggle-m {
  display: flex;
  gap: 6px;
  border-radius: 8px;
  background-color: #f3f3f3;
  border: 1px solid #e0e0e0;
  cursor: pointer;
}

.user-dropdown-m {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  width: 200px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  padding: 10px 0;
  z-index: 999;
}

.user-dropdown-m.active {
  display: block;
}

.cart-icon-m {
  text-decoration: none;
  color: #333;
  font-size: 20px;
  position: relative;
}

.cart-count-m {
  background-color: red;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  position: absolute;
  top: -5px;
  left: 15px;
}

/* 🎨 استایل حرفه‌ای جستجو */
#search-container {
  position: relative;
  display: inline-block;
  width: 100%;
  font-family: Vazir, sans-serif;
}

#search-results {
  position: absolute;
  top: 100%;
  width: 100% !important;
  max-height: 420px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  opacity: 0;
  padding: 0;
  transition: all .35s ease;
  z-index: 9999;
}

#search-results.active {
  opacity: 1;
  padding: 6px 0;
}

.search-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  transition: all .25s ease;
  border-radius: 8px;
  margin: 4px 6px;
  font-family: Vazir, sans-serif;
}

.search-item.show {
  opacity: 1;
  transform: translateY(0);
}

.search-item.selected,
.search-item:hover {
  background: #f9f9f9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.search-item .image-wrapper {
  width: 65px;
  height: 65px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-item .image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.search-item:hover .image-wrapper img {
  transform: scale(1.1);
}

.search-item .info {
  flex: 1;
  overflow: hidden;
}

.search-item .info .name {
  font-weight: 700;
  font-size: 14px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item .info .brand {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item .info .price {
  font-size: 13px;
  font-weight: 700;
  color: #d32f2f;
  margin-top: 4px;
}

.search-item .info .price del {
  color: #999;
  font-size: 12px;
  font-weight: 400;
  margin-right: 5px;
}

.search-item.no-result {
  justify-content: center;
  text-align: center;
  color: #999;
  font-size: 14px;
  cursor: default;
  opacity: 1;
  transform: translateY(0);
  padding: 15px 0;
}

#search-results mark {
  background: #ffecb3;
  color: #000;
  font-weight: 600;
  border-radius: 2px;
}

#search-results-m {
  z-index: 999;
}

/* موبایل */
@media (max-width: 768px) {
  .site-header {
    display: none;
  }

  .main-menu {
    display: none;
  }


  .site-header-m {
    display: block;
  }

  .header-top {
    justify-content: space-between;
  }

  .menu-toggle-m {
    display: block;
    margin-left: 12px;
  }

  .header-top-m .user-menu-m {
    display: block;
  }
}

/* ✅ نوار موبایل فقط در حالت موبایل نمایش داده شود */
.mobile-nav {
  display: none;
}

.mobile-submenu {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #ddd;
    padding: 8px 0;
    z-index: 1000;
    direction: rtl;
  }

  .mobile-submenu {
    display: block;
  }

  .mobile-nav a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #444;
    font-size: 13px;
    transition: color 0.3s;
    position: relative;
  }

  .mobile-nav a i {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
  }

  /* ✅ دایره تعداد */
  .cart-count {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(5px);
    background: #ff6600;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
    line-height: 16px;
  }

  /* ✅ استایل زیرمنو */
  .mobile-submenu {
    display: none;
    position: fixed;
    bottom: 50px;
    /* بالای نوار موبایل */
    right: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
    z-index: 999;
    direction: rtl;
  }

  .mobile-submenu ul {
    list-style: none;
    margin: 0;
    padding: 10px;
    overflow: auto;
    height: 400px;
  }

  .mobile-submenu ul li {
    border-bottom: 1px solid #f0f0f0;
  }

  .mobile-submenu ul li a {
    display: block;
    padding: 12px;
    color: #444;
    text-decoration: none;
  }

  .mobile-submenu ul li a:hover {
    background: #f8f8f8;
    color: #ff1c17;
  }

  .mobile-nav a:hover,
  .mobile-nav a.active {
    color: #ff1c17;
  }
}