/* Отступ для контента под фиксированным хедером */
body {
  padding-top: 226px; /* 40px отступ + высота header-top + header-bottom */
}

/* ===== HEADER GENERAL ===== */
header#masthead {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: calc(100% - clamp(2rem, -2.2696rem + 17.5164vw, 18.75rem));
  max-width: 1920px;
  z-index: 100;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              top 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.4s ease;
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Скролл вниз — прячем весь хедер */
header#masthead.hide-all {
  transform: translateX(-50%) translateY(-120%);
  opacity: 0;
}

/* Скролл вверх — показываем только нижнюю часть */
header#masthead.hide-top {
  top: 15px;
  border-radius: 12px;
}

header#masthead.hide-top .header-top {
  height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  border-bottom: none;
}

header#masthead.hide-top .header-bottom {
  border-radius: 12px;
}

/* ===== HEADER TOP ===== */
.header-top {
  background-color: #fff;
  border-bottom: 1px solid #E6E6E6;
  height: 80px;
  border-radius: 16px 16px 0 0;
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.4s ease,
              visibility 0.4s ease,
              border 0.3s ease;
}

.header-top__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  gap: 30px;
  height: 100%;
}

.site-branding {
  flex-shrink: 0;
}

.site-branding img {
  max-height: 50px;
  width: auto;
}

a.custom-logo-link {
  display: flex;
}

/* Search */
.header-search {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.header-search form {
  display: flex;
  align-items: center;
  border: 1px solid #E6E6E6;
  border-radius: 4px;
  overflow: hidden;
}

.header-search input {
  flex: 1;
  border: none;
  padding: 10px 15px;
  font-size: 14px;
  outline: none;
}

.header-search button {
  background: none;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-search button svg {
  width: 20px;
  height: 20px;
  fill: #0C1E13;
}

/* Live search results */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 200;
  display: none;
  max-height: 400px;
  overflow-y: auto;
}

.search-results.active {
  display: block;
}

.search-results__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  text-decoration: none;
  color: #0C1E13;
  transition: background 0.2s ease;
}

.search-results__item:hover {
  background: #f5f5f5;
}

.search-results__item img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.search-results__item span {
  font-size: 14px;
  line-height: 1.3;
}

.search-results__empty {
  padding: 15px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.search-results__loading {
  padding: 20px;
  text-align: center;
}

.search-results__loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #E6E6E6;
  border-top-color: #0F6037;
  border-radius: 50%;
  animation: search-spin 0.6s linear infinite;
}

@keyframes search-spin {
  to { transform: rotate(360deg); }
}

/* Header top right */
.header-top__right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.header-phone {
  font-weight: 600;
  color: #0C1E13;
  text-decoration: none;
  white-space: nowrap;
}

.header-phone:hover {
  color: #0F6037;
}

.header-socials {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-socials a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: #0C1E13;
  transition: color 0.3s ease;
}

.header-socials a:hover {
  color: #0F6037;
}

.header-socials svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Cart */
.cart {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.cart svg {
  width: 24px;
  height: 24px;
  fill: #0C1E13;
}

span.badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #0F6037;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 3px;
  box-sizing: border-box;
}

/* ===== HEADER BOTTOM ===== */
.header-bottom {
  background-color: #0C5331;
  height: 80px;
  border-radius: 0 0 16px 16px;
  transition: border-radius 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s ease;
}

.header-bottom__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 0;
  height: 100%;
}

/* Catalog button */
.catalog-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2C7351;
  color: #fff;
  padding: 0 15px;
  height: 100%;
  font-size: 20px;
  font-weight: 500;
  text-transform: uppercase;
  text-decoration: none;
  margin-left: 40px;
  letter-spacing: 0.5px;
  transition: background-color 0.3s ease;
}

.catalog-btn:hover {
  background-color: #0a4a2a;
  color: #fff;
}

/* Navigation */
.main-navigation ul {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 0.0305rem + 2.4390vw, 2.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

#primary-menu .menu-item a {
  font-size: 20px;
  font-weight: 500;
  line-height: 20зч;
  color: var(--White, #fff);
  transition: color 0.3s ease;
  text-transform: uppercase;
  position: relative;
  text-decoration: none;
  display: inline-block;
}

#primary-menu .menu-item a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: currentColor;
  transition: width 0.3s ease;
}

#primary-menu .menu-item a:hover::after {
  width: 100%;
}

/* Submenu */
#primary-menu .menu-item-has-children {
  position: relative;
}

#primary-menu .menu-item-has-children > a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 1px;
  bottom: 12px;
  left: 0;
  background-color: currentColor;
  transition: width 0.3s ease;
}

#primary-menu .menu-item-has-children:hover > a::after {
  width: 100%;
}

/* Language Switcher */
.lang-switcher {
  position: relative;
  display: inline-block;
  z-index: 100;
}

.lang-switcher__btn {
  background: none;
  border: none;
  color: #0C1E13;
  font-size: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.lang-switcher__btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.lang-switcher__icon {
  display: flex;
  align-items: center;
}

.lang-switcher__icon svg {
  width: 16px;
  height: 16px;
}

.lang-switcher__dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 70px;
  padding: 6px 0;
  display: none;
}

.lang-switcher__option {
  display: block;
  color: #0C1E13;
  text-decoration: none;
  padding: 8px 18px;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.lang-switcher__option:hover {
  background: #f5f5f5;
  color: #0F6037;
}

.lang-switcher__dropdown.active {
  display: block;
}

/* Currency Switcher */
.currency-switcher {
  position: relative;
  display: inline-block;
  z-index: 100;
}

.currency-switcher__btn {
  background: none;
  border: none;
  color: #0C1E13;
  font-size: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.currency-switcher__btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.currency-switcher__current {
  font-weight: 600;
}

.currency-switcher__icon {
  display: flex;
  align-items: center;
}

.currency-switcher__icon svg {
  width: 16px;
  height: 16px;
}

.currency-switcher__dropdown {
  position: absolute;
  right: 0;
  top: 110%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 90px;
  padding: 6px 0;
  display: none;
}

.currency-switcher__option {
  display: block;
  color: #0C1E13;
  text-decoration: none;
  padding: 8px 18px;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.currency-switcher__option:hover {
  background: #f5f5f5;
  color: #0F6037;
}

.currency-switcher__option.active {
  color: #0F6037;
  font-weight: 600;
}

.currency-switcher__dropdown.active {
  display: block;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
}

/* Мобильные элементы скрыты на десктопе */
.mobile-logo,
.mobile-icons {
  display: none;
}

/* Popup cart */
div#popup-cart {
  right: 0;
  height: 100%;
  border-radius: inherit;
  max-width: 400px;
  overflow-x: auto;
}

.popup-content.cart-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .header-search {
    max-width: 300px;
  }

  .header-top__right {
    gap: 15px;
  }

  .header-phone {
    display: none;
  }
}

@media (max-width: 768px) {
  body {
    padding-top: 70px;
  }

  /* Мобильный хедер на всю ширину */
  header#masthead {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    border: 1px solid #E6E6E6;
    border-top: none;
    z-index: 100;
  }

  header#masthead.hide-all {
    transform: translateY(-100%);
  }

  header#masthead.hide-top {
    top: 0;
    border-radius: 0;
  }

  /* Прячем верхнюю часть на мобильном */
  .header-top {
    display: none;
  }

  /* Нижняя часть становится основной */
  .header-bottom {
    background-color: #fff;
    height: 60px;
    border-radius: 0;
  }

  .header-bottom__container {
    padding: 0 15px;
    justify-content: space-between;
  }

  /* Прячем каталог и основное меню */
  .catalog-btn {
    display: none;
  }

  #primary-menu {
    display: none;
  }

  /* Мобильная навигация */
  .main-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    justify-content: space-between;
  }

  /* Мобильный лого */
  .mobile-logo {
    display: flex;
    align-items: center;
  }

  .mobile-logo img {
    max-height: 35px;
    width: auto;
  }

  /* Мобильные иконки */
  .mobile-icons {
    display: flex;
    align-items: center;
    gap: 15px;
  }

  .mobile-phone-icon,
  .mobile-cart-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #0C1E13;
  }

  .mobile-phone-icon svg,
  .mobile-cart-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .mobile-cart-icon {
    position: relative;
  }

  .mobile-cart-icon .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #0F6037;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Бургер меню */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    border: 1px solid #E6E6E6;
    border-radius: 8px;
    background: #fff;
  }

  .menu-toggle svg {
    width: 20px;
    height: 20px;
    fill: #0C1E13;
  }
}
