/* Header desktop (Figma 1:13074 хедер-основной + 1:11082 список-навигация) */

/* Отступы шапки по макету (Figma 1:116): 27 сверху, полоса 71,
   13 до тёмной панели, панель 38, 38 до контента страницы. */
.header {
  padding-top: 28px;
  background: var(--bg-white);
}

/* ── Верхняя полоса: лого · поиск · язык · телефон · профиль · корзина
      (высота 71, контейнер 1180) ── */
.header__inner {
  position: relative; /* точка отсчёта для выпадающего меню каталога */
  display: flex;
  align-items: center;
  gap: 0; /* отступы задаются полям точечно: см. .header__search / .header__actions */
  width: 100%;
  max-width: 1180px; /* контейнер шапки по макету */
  height: 71px;
  padding: 0;
}

.header__logo {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 7px; /* лого по макету стоит на 35px от верха страницы */
}

.header__logo img {
  display: block;
  width: 240px;
  height: 53px;
  /* загруженный из админки логотип другой пропорции вписывается, а не растягивается */
  object-fit: contain;
  object-position: left center;
}

/* Поиск */
.header__search {
  display: flex;
  align-items: center;
  flex: 0 0 388px; /* ширина поля по макету; сжимается только ниже 1366 */
  max-width: 388px;
  min-width: 0;
  height: 43px;
  margin-left: 42px; /* лого → поиск по макету */
  margin-right: auto;
  border: 1px solid var(--yellow-500);
  border-radius: 8px;
  background: var(--bg-white);
  overflow: hidden;
}

.header__search-input {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  padding: 0 16px;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
}

.header__search-input::placeholder {
  color: var(--text-gray-300);
}

.header__search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 100%;
  flex-shrink: 0;
  background: var(--yellow-500);
}

/* Действия справа: язык | телефон | профиль | корзина.
   По макету правый край корзины отстоит от края контейнера на 16. */
.header__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  margin-left: 24px;
  margin-right: 16px; /* правый край корзины по макету — 16 от края контейнера */
}

.header__divider {
  width: 1px;
  height: 25px;
  flex-shrink: 0;
  background: var(--divider);
}

/* Телефон (Figma 1:2140: иконка 19, gap 8, Gotham Pro Bold 14/20, ls -0.14) */
.header__phone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header__phone-icon {
  width: 19px;
  height: 19px;
  object-fit: contain;
}

.header__phone-text {
  font-weight: var(--fw-bold);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: var(--ls-base);
  text-transform: uppercase;
  color: #000000;
  white-space: nowrap;
}

.header__user {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 21px;
}

.header__user img {
  width: 16px;
  height: 21px;
}

.header__cart {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 43px;
  padding: 0 11px 0 17px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
}

.header__cart img {
  width: 18px;
  height: 19px;
}

.header__cart-total {
  font-weight: var(--fw-bold);
  font-size: 15px;
  color: var(--text-dark-900);
}

/* Переключатель языка */
.lang {
  position: relative;
}

/* Пилюля языка по макету: 72×34, флаг 24×19, код 14, стрелка 4 */
.lang__toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  background: #f5f5f5;
}

.lang__flag {
  width: 24px;
  height: 19px;
  object-fit: cover;
}

.lang__code {
  font-weight: var(--fw-medium);
  font-size: 14px;
  color: #262626;
}

.lang__arrow {
  font-size: 7px;
  line-height: 1;
  color: #666666;
}

/* Выпадающий список языков (Figma 1:18132): RU Русский ✓ / KZ Қазақша / EN English */
.lang__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 140px;
  padding: 8px 0;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  background: var(--bg-white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  z-index: 50;
}

.lang__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: #666666;
  cursor: pointer;
  white-space: nowrap;
}

.lang__item b {
  font-weight: inherit;
}

.lang__item:hover {
  background: var(--bg-gray-100);
}

.lang__check {
  display: none;
  font-style: normal;
  font-size: 14px;
  color: #1a9933;
}

.lang__item[aria-selected='true'] {
  font-weight: var(--fw-medium);
  color: var(--text-dark-900);
  background: #fffae0;
}

.lang__item[aria-selected='true'] .lang__check {
  display: inline;
}

/* Навигация под шапкой */
/* ── Нижняя строка: жёлтая кнопка «Каталог» (134×38) + тёмная панель (1038×38),
      между ними зазор 8; обе со скруглением 8 (Figma 1:116) ── */
.nav {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  max-width: 1180px; /* контейнер шапки по макету */
  height: 38px;
  margin-top: 12px;
  margin-bottom: 38px;
  padding: 0;
  background: transparent;
}

/* Каталог — жёлтая кнопка слева от панели */
.nav__catalog {
  position: relative;
  flex: 0 0 134px;
}

.nav__catalog-btn {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 134px;
  height: 38px;
  padding: 0 0 0 16px;
  border-radius: 8px;
  background: var(--yellow-500);
  font-weight: var(--fw-bold);
  font-size: 14px;
  letter-spacing: var(--ls-base);
  text-transform: uppercase;
  color: var(--text-dark-900);
  white-space: nowrap;
}

.nav__catalog-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 18px;
  height: 14px;
  flex-shrink: 0;
}

.nav__catalog-icon i {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: var(--text-dark-900);
}

/* Пункты меню внутри тёмной панели: padding 27, между пунктами — разделители,
   свободное место распределяется поровну (по макету ~60 с каждой стороны) */
.nav__list {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 0 27px;
  border-radius: 8px;
  background: var(--nav-dark);
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0;
  font-weight: var(--fw-bold);
  font-size: 14px;
  line-height: 1;
  letter-spacing: var(--ls-base);
  text-transform: uppercase;
  color: #ffffff;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav__link:hover {
  color: var(--yellow-500);
}

.nav__link-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav__divider {
  width: 1px;
  height: 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.9);
}

/* Акции — тот же пункт, но с иконкой-биркой (без жёлтой пилюли) */
.nav__link--promo {
  color: #ffffff;
}

.nav__link--promo:hover {
  color: var(--yellow-500);
}

.header {
  position: relative;
  z-index: 120;
}

/* Проскроллили — шапка прилипает к верху и показывает только верхнюю полосу */
.header.is-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding-top: 10px;
}

.header.is-fixed .nav {
  display: none;
}

.header.is-fixed .header__inner {
  height: 64px;
}

.header.is-fixed .header__logo {
  margin-top: 5px;
}

/* Место шапки в потоке, пока она зафиксирована — иначе контент прыгает */
.header-spacer {
  height: 0;
}

/* Тень у прилипшей шапки (страница проскроллена) */
.header.is-stuck {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Меню «Каталог» в шапке: раскрывается при наведении
   ============================================================ */
.header__catalog {
  position: static; /* меню выравнивается по контейнеру шапки */
  flex-shrink: 0;
}

.catalog-menu {
  position: absolute;
  top: calc(100% + 6px); /* под жёлтой кнопкой панели */
  left: 0;
  z-index: 200;
  /* правый край меню — вровень с правым краем логотипа (240px по макету) */
  width: 240px;
  min-width: 240px;
  padding: 8px 0;
  border: 1px solid var(--border-200, #e5e7eb);
  border-radius: 12px;
  background: var(--bg-white, #fff);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.catalog-menu[hidden] {
  display: block; /* показываем анимацией, а не переключением display */
}

.header__catalog.is-open .catalog-menu,
.nav__catalog.is-open .catalog-menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.catalog-menu__list {
  display: flex;
  flex-direction: column;
}

.catalog-menu__item {
  position: relative;
}

.catalog-menu__item + .catalog-menu__item {
  border-top: 1px solid var(--border-200, #e5e7eb);
}

.catalog-menu__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-weight: var(--fw-medium);
  font-size: 13px;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--text-dark-800, #333e48);
  transition: background 0.15s ease, color 0.15s ease;
}

.catalog-menu__name {
  flex: 1 1 auto;
  min-width: 0;
}

.catalog-menu__arrow {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--text-gray-300, #94a3b8);
}

.catalog-menu__item:hover > .catalog-menu__link {
  background: var(--bg-gray-100, #f8fafc);
  color: var(--text-dark-900, #1a1a1a);
}

.catalog-menu__item:hover > .catalog-menu__link .catalog-menu__arrow {
  color: var(--yellow-500, #ffe400);
}

/* Вложенный уровень — вбок от родителя */
.catalog-menu__sub {
  position: absolute;
  top: -8px;
  left: 100%;
  min-width: 320px;
  padding: 8px 0;
  border: 1px solid var(--border-200, #e5e7eb);
  border-radius: 12px;
  background: var(--bg-white, #fff);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.catalog-menu__item--has-children:hover > .catalog-menu__sub {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Если места справа не хватает — раскрываем влево */
.catalog-menu__sub--left {
  left: auto;
  right: 100%;
  transform: translateX(6px);
}

@media (max-width: 1023px) {
  .catalog-menu {
    display: none;
  }
}

/* Между 1024 и 1440 контейнер уже 1180 — шапка ужимается, а не вылезает за экран */
@media (max-width: 1365px) {
  .header__search {
    flex: 0 1 388px;
    margin-left: 24px;
  }

  .header__actions {
    gap: 12px;
    margin-left: 16px;
    margin-right: 0;
  }

  .header__phone {
    gap: 8px;
  }

  .header__phone-text {
    font-size: 15px;
  }

  .header__cart {
    gap: 10px;
    padding: 0 12px;
  }

  .nav__list {
    padding: 0 16px;
  }

  .nav__link {
    font-size: 13px;
  }
}
