/* 1. Основний контейнер шапки */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 5%;
  background-color: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* 2. Логотип */
.logo img {
  height: 50px;
  width: auto;
}

/* 3. Навігація (Список посилань) */
.nav-links {
  display: flex;
  list-style: none;
  gap: 20px;
  margin: 0;
  padding: 0;
}

.nav-links li a {
  text-decoration: none;
  color: #402e21;
  font-weight: 500;
  font-size: 15px;
  transition: 0.3s;
}

.nav-links li a:hover {
  color: #8c6a4a;
}

/* 4. Блок з іконками (Пошук, Юзер, Кошик) */
header div:last-child {
  align-items: center;
  gap: 15px;
}

header div:last-child img {
  width: 24px;
  height: 24px;
  cursor: pointer;
  transition: transform 0.2s;
}

header div:last-child img:hover {
  transform: scale(1.1);
}

/* 5. Бургер-меню (приховане на ПК) */
.burger-menu {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.burger-menu span {
  width: 25px;
  height: 3px;
  background-color: #402e21;
  transition: 0.3s;
}

.buttons {
  display: flex;
  gap: 10px;
}

button {
  background: none;
  border: none;
  outline: none;
}

/* --- МОБІЛЬНА АДАПТАЦІЯ (max-width: 992px) --- */
@media (max-width: 992px) {
  .nav-links {
    position: fixed;
    left: 0;
    top: -100%;
    /* Меню сховане зверху */
    width: 100%;
    height: auto;
    /* Висота підлаштовується під контент */
    background-color: #fdfaf7;
    flex-direction: column;
    align-items: center;
    padding: 80px 0 40px 0;
    /* Відступ зверху, щоб не перекривати лого */
    transition: all 0.5s ease-in-out;
    z-index: 999;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  }

  /* Коли меню активне — воно виїжджає на top: 0 */
  .nav-links.active {
    top: 0;
  }

  .burger-menu {
    display: flex;
    z-index: 1001;
    /* Бургер завжди має бути над меню */
  }

  /* Анімація бургера у хрестик (щоб було зрозуміло, як закрити) */
  .burger-menu.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
  }

  .burger-menu.open span:nth-child(2) {
    opacity: 0;
  }

  .burger-menu.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -7px);
  }
}

.search-wrapper {
  position: relative;
}

#profile-btn {
  cursor: pointer;
}

.search-input-box {
  position: absolute;
  right: 0;
  top: 45px;
  background: white;
  border: 2px solid #8c6a4a;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  /* Тримаємо flex для структури */
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2000;

  /* Стан "Сховано" */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

/* Стан "Активно" (коли JS додає клас) */
.search-input-box.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#search-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 5px;
  outline: none;
}

#search-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #8c6a4a;
  line-height: 1;
}

/* Примусові стилі для вікна пошуку */
#search-container {
  display: none;
  /* Керується через JS */
  position: fixed !important;
  /* Фіксація відносно екрана */
  top: 100px !important;
  /* Відступ зверху */
  right: 20px !important;
  /* Відступ справа */
  width: 300px !important;
  min-height: 100px !important;
  background-color: #ffffff !important;
  /* Білий фон обов'язково */
  border: 2px solid #8c6a4a !important;
  /* Коричнева рамка */
  border-radius: 12px !important;
  padding: 20px !important;
  z-index: 999999 !important;
  /* Поверх усіх елементів */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
}

/* Стиль для самого поля вводу всередині */
#search-input {
  margin-top: 20px;
  width: 100% !important;
  padding: 5px !important;
  margin-bottom: 10px !important;
  border: 1px solid #ccc !important;
  border-radius: 5px !important;
  display: block !important;
  color: #000 !important;
}

/* Кнопка закриття */
#search-close {
  position: absolute;
  top: 5px;
  right: 10px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #8c6a4a;
}

#cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #8c6a4a;
  /* Ваш фірмовий коричневий */
  color: white;
  font-size: 11px;
  font-weight: bold;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #fff;
  /* Біла обводка, щоб не зливалося */
  opacity: 0;
  /* Спочатку ховаємо */
  transition: opacity 0.3s ease;
}

/* Показуємо, якщо число більше 0 */
#cart-count.visible {
  opacity: 1;
}

#modal {
  text-align: center;
}

/* Стилізація самого діалогу */
#modal {
  border: none;
  border-radius: 20px;
  padding: 40px;
  width: 350px;
  background-color: #fdfaf7;
  /* Світло-бежевий фон під сайт */
  box-shadow: 0 10px 30px rgba(140, 106, 74, 0.2);
  font-family: inherit;
  color: #5a4033;
  /* Темно-коричневий текст */
}

/* Стилі заголовків */
#modal h2 {
  text-align: center;
  margin-bottom: 25px;
  font-weight: 600;
  color: #8c6a4a;
  /* Ваш основний коричневий колір */
}

/* Контейнери для полів вводу */
.form-row {
  margin-bottom: 15px;
}

#modal input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #efe5db;
  border-radius: 10px;
  background-color: #fff;
  outline: none;
  box-sizing: border-box;
  /* Щоб падінги не розтягували інпут */
  transition: border-color 0.3s ease;
}

#modal input:focus {
  border-color: #8c6a4a;
}

/* Посилання (Зареєструватися / Увійти) */
#modal p {
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 20px;
}

#modal a {
  color: #8c6a4a;
  font-weight: bold;
  text-decoration: none;
  transition: opacity 0.3s;
}

#modal a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* Задній фон при відкритому модальному вікні */
#modal::backdrop {
  background: rgba(82, 65, 52, 0.5);
  /* Напівпрозорий коричневий фон */
  backdrop-filter: blur(3px);
  /* Легке розмиття фону сайту */
}

/* Кнопка закриття (якщо захочете додати її в HTML) */
.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #8c6a4a;
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #8c6a4a;
  /* Ваш фірмовий коричневий */
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease;
  padding: 5px;
}

.close-modal:hover {
  transform: scale(1.2);
  color: #5a4033;
  /* Темніший при наведенні */
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  background-color: #8c6a4a;
  /* Ваш фірмовий коричневий */
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background-color 0.3s ease, transform 0.2s active;
}

.auth-submit-btn:hover {
  background-color: #70543a;
  /* Трохи темніший при наведенні */
}

.auth-submit-btn:active {
  transform: scale(0.98);
  /* Ефект натискання */
}

/* Додамо трохи марджину для тексту під кнопкою */
#modal p {
  margin-top: 20px;
  margin-bottom: 0;
}