/* --- HEADER --- */
#header {
  background: white;
  position: fixed;
  top: 0;
  right: 0;
  min-width: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transform: translateY(0);
  transition: transform 0.4s ease, background-color 0.3s ease;
}

#header.hide {
  transform: translateY(-100%);
}

.container {
  max-width: calc(100% - 250px);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- TOP BAR --- */
.top-bar {
  padding: 12px 0;
}

.logo {
  font-weight: bold;
  font-size: 22px;
  margin-left: 10px;
}

.search-bar-container {
  display: flex;
  justify-content: space-between;
  flex-grow: 1;
  margin: 0 20px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: #fafafa;
  border-radius: 25px;
  padding: 5px 12px;
  border: 1px solid #ccc;
  flex: 1;
  max-width: 600px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
}

.search-bar button {
  border: none;
  background: #007bff;
  color: white;
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.search-bar button:hover {
  background: #005dc5;
}

.auth-buttons {
  display: flex;
  gap: 10px;
  margin-left: 15px;
}

.auth-button {
  background: #e0e0e0;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

.auth-button:hover {
  background: #d0d0d0;
}

/* --- NAV MENU --- */
#nav {
  
  padding: 15px 0;
}

#nav ul {
  list-style: none;
  display: flex;
  gap: 25px;
  margin: 0;
  padding: 0;
  padding-right: 30px;
}

#nav ul li {
  position: relative;
}

#nav ul li a {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  transition: color 0.3s;
}

#nav ul li a:hover {
  color: #007bff;
}

/* --- DROPDOWN --- */
.dropdown-content {
  position: absolute;
  top: 35px;
  right: 0;
  background: white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  min-width: 150px;
  opacity: 0;
  transform: translateY(-15px);
  pointer-events: none;
  transition: all 0.3s ease;
}

.dropdown:hover .dropdown-content {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-content:hover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-content a {
  display: block;
  padding: 10px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s;
}

.dropdown-content a:hover {
  background: #f0f0f0;
}

/* --- OVERLAY --- */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: calc(100% - 250px);
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 995;
}

#overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* --- MOBILE --- */
.menu-toggle {
  display: none;
  font-size: 26px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .top-bar .container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    /* لوگو - سرچ - دکمه منو */
    gap: 5px;
    padding: 0 25px 0 15px;
        max-width: 100%;
  }

  .search-bar-container {
    display: flex;
    align-items: center;
    width: 100%;
    /* اجباری برای جلوگیری از بیرون‌زدگی */
    max-width: 100%;
    /* امنیت بیشتر */
    padding: 0 10px;
    box-sizing: border-box;
    /* بسیار مهم: پدینگ عرض را زیاد نکند */
  }

  .search-bar-container input {
    flex: 1;
    /* اینپوت فضای باقی‌مانده را پر کند */
    min-width: 0;
    /* جلوگیری از کش آمدن بیش از حد اینپوت */
    width: 100%;
  }

  .search-bar-container .logo {
    flex-shrink: 0;
    /* لوگو نباید کوچک یا فشرده شود */
    margin-right: 10px;
  }

  .menu-toggle {
    display: block;
  }

  /* مخفی کردن دکمه‌های ورود/ثبت نام */
  .auth-buttons {
    display: none;
  }

  .auth-buttons {
    display: none;
    /* حذف ثبت نام و ورود در موبایل */
  }

  .search-bar-container {
    justify-content: center;
  }

  .search-bar {
    max-width: none;
  }

  #nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 250px;
    background: white;
    box-shadow: -3px 0 10px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    transition: transform 0.4s ease;
    padding-top: 80px;
    z-index: 1100;
  }

  #nav.show {
    transform: translateX(0);
  }

  #nav .container {
    flex-direction: column;
    align-items: flex-end;
    padding-right: 20px;
    max-width: 100%;
  }

  #nav ul {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  #nav ul li {
    width: 100%;
  }

  #nav ul li a {
    display: block;
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
  }

  /* حذف رفتار hover برای دراپ‌داون */
  .dropdown-content {
    display: none;
    position: static;
    box-shadow: none;
    transform: none;
    opacity: 1;
  }

  .dropdown.open .dropdown-content {
    display: block;
  }

  .menu-toggle {
    display: block;
  }
}

/* پایان هدر */