/* =========================================================
   BOTTOM HEADER (иконки + подписи, фон #1947C4)
   ========================================================= */

/* --- СТИЛИЗАЦИЯ СКРОЛЛА (WEBKIT) --- */
/* (Оставляем, так как влияет только на 3-й уровень) */
.bw-sub-submenu::-webkit-scrollbar {
  width: 8px;
}
.bw-sub-submenu::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}
.bw-sub-submenu::-webkit-scrollbar-thumb {
  background-color: #1947c4;
  border-radius: 10px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
  transition: background-color 0.2s ease;
}
.bw-sub-submenu::-webkit-scrollbar-thumb:hover {
  background-color: #1a51e6;
}
/* ---------------------------------- */

.bw-bottom-header {
  position: relative;
  z-index: 1 !important;
}

.bw-bottom-header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: flex;
  justify-content: center;
}

.bw-bottom-menu {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: nowrap;
  gap: var(--bw-gap, 80px);
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
  overflow: visible; /* Должно быть visible */
}

/* 1-й уровень: Зона захвата для hover */
.bw-bottom-menu__item {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  text-align: center;
  padding-bottom: 5px; /* Расширяем зону hover */
  overflow: visible; /* КРИТИЧНО: Подменю должно быть видно */
}

.bw-bottom-menu__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 6px 4px 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.bw-bottom-menu__item:hover > .bw-bottom-menu__link {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* !!! ИСПРАВЛЕНИЕ РАЗМЕРА ИКОНКИ БУРГЕРА (И ВСЕХ ИКОНОК) !!! */
.bw-bottom-menu__icon-wrap {
  /* Возвращаем оригинальный размер контейнера иконок,
     чтобы иконка бургер-меню (если она использует этот класс) выглядела правильно */
  width: var(--bw-icon-size, 48px);
  height: var(--bw-icon-size, 48px);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Если иконка — это SVG, которая масштабируется от контейнера: */
.bw-bottom-menu__icon-wrap svg {
  width: 100%;
  height: 100%;
  max-width: 30px; /* Ограничиваем саму SVG, чтобы не была гигантской */
  max-height: 30px;
}
/* -------------------------------------------------------- */

.bw-bottom-menu__icon {
  display: block;
  max-width: 80%;
  max-height: 80%;
}

.bw-bottom-menu__label {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}

/* =========================
   2-й уровень: .bw-submenu (Центрированный дропдаун)
   ========================== */
.bw-submenu {
  position: absolute;
  left: 50%;
  top: 100%;

  /* Исправление быстрого закрытия */
  margin-top: -5px;

  transform: translate(-50%, 12px);

  /* Стилизация */
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 12px;
  padding: 8px 0;
  min-width: 200px;
  max-width: 260px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.03);

  /* *** ОТКЛЮЧАЕМ СКРОЛЛ НА 2-М УРОВНЕ *** */
  max-height: none;
  overflow: visible;
  /* ************************************* */

  /* Скрытие */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 99999;
}

/* Показываем 2-й уровень */
.bw-bottom-menu__item.has-children:hover > .bw-submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 8px);
}

.bw-submenu__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Родитель для каскада (требуется position: relative) */
.bw-submenu__item {
  margin: 0;
  padding: 0;
  position: relative;
}

.bw-submenu__item + .bw-submenu__item {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.bw-submenu__link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 500;
  color: inherit;
  line-height: 1.4;
  padding: 10px 18px;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  text-align: left;
  text-decoration: none;
}

.bw-submenu__link:hover {
  text-decoration: none;
  background-color: #f5f5f5;
  color: #1947c4;
}

/* Стиль стрелки для указания на следующий уровень */
.bw-submenu-arrow {
  font-size: 16px;
  line-height: 1;
  transition: transform 0.2s ease;
  color: #999;
  flex-shrink: 0;
}

/* Поворот стрелки при наведении */
.bw-submenu__item.has-sub-children:hover
  > .bw-submenu__link
  > .bw-submenu-arrow {
  transform: rotate(90deg);
  color: #1947c4;
}

/* =========================
   3-й и последующие уровни: .bw-sub-submenu (Каскадный дропдаун)
   ========================== */

.bw-sub-submenu {
  position: absolute;
  left: 100%;
  top: -8px;
  margin-top: 0;
  min-width: 200px;

  /* Стилизация контейнера */
  background: #ffffff;
  color: #1a1a1a;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  padding: 8px 0;

  /* *** СКРОЛЛ ТОЛЬКО ДЛЯ 3-ГО УРОВНЯ *** */
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  /* *********************************** */

  /* Скрытие по умолчанию */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 100000;
}

/* Показываем 3+ уровень при наведении на его родительский li */
.bw-submenu__item.has-sub-children:hover > .bw-sub-submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

/* =========================
   MOBILE
   ========================== */
@media (max-width: 1023px) {
  .bw-bottom-header__inner {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .bw-bottom-menu {
    gap: 32px;
  }

  /* Сброс стилей для мобильного аккордеона (все уровни) */
  .bw-submenu,
  .bw-sub-submenu {
    position: static;
    transform: none !important;
    margin-top: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 12px 0 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
    z-index: auto;

    /* Сброс скролла на мобильных */
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
  }

  /* Сброс лишних отступов/отрицательных маргинов для мобильной версии */
  .bw-bottom-menu__item {
    padding-bottom: 0;
  }

  /* Для мобильного аккордеона, управляемого JS */
  .bw-bottom-menu__item.is-open > .bw-submenu,
  .bw-submenu__item.is-open > .bw-sub-submenu {
    display: block;
  }
}
