/* Многоуровневое меню категорий */

/* 1 уровень - при наведении */
.tabs__item.has-dropdown {
  position: relative;
}

.tabs__item.has-dropdown .menu-item-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tabs__item.has-dropdown > a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.dropdown-arrow {
  transition: transform 0.3s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (width > 992px){
    .tabs__item.has-dropdown:hover .dropdown-arrow {
      transform: rotate(180deg);
    }
}

/* Выпадающее меню 2-го уровня */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 240px;
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  margin-top: 8px;
  border: 1px solid #f0f0f0;
}

.dropdown-menu:after{
    content: '';
    position: absolute;
    top: -7px;
    height: 40px;
    left: 0;
    width: 100%;
    z-index:-1;
}

.tabs__item.has-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  position: relative;
}

.dropdown-item > a {
  display: block;
  padding: 12px 20px;
  color: #424242;
  font-size: 13px;
  font-weight: 400;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 4px;
}

.dropdown-item > a:hover {
  background: #f8f9fa;
  color: #007bd4;
}

/* 2+ уровень - аккордеон с кнопкой */
.dropdown-item.has-submenu,
.submenu-item.has-submenu {
  position: relative;
}

.menu-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 4px;
}

.menu-item-link {
  flex: 1;
  display: block;
  padding: 12px 16px;
  color: #424242;
  font-size: 13px;
  font-weight: 400;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 4px;
}

.menu-item-link:hover {
  background: #f8f9fa;
  color: #007bd4;
}

.menu-item-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.menu-item-toggle:hover {
  background: #f0f0f0;
}

.menu-item-toggle svg {
  transition: transform 0.3s ease;
}

.dropdown-item.has-submenu.active .menu-item-toggle svg,
.submenu-item.has-submenu.active .menu-item-toggle svg {
  transform: rotate(90deg);
}

/* Submenu - аккордеон */
.submenu {
  background: #f8f9fa;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  margin-top: 4px;
}

.dropdown-item.has-submenu.active > .submenu,
.submenu-item.has-submenu.active > .submenu {
  max-height: 2000px;
}

.submenu-item {
  position: relative;
}

.submenu-item > a {
  display: block;
  padding: 12px 20px;
  color: #424242;
  font-size: 13px;
  font-weight: 400;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 4px;
}

.submenu-item > a:hover {
  background: #ebebeb;
  color: #007bd4;
}

/* Вложенные submenu */
.submenu .menu-item-link {
  font-size: 13px;
}

/* .submenu .submenu .menu-item-link {
  font-size: 12px;
} */

.submenu .submenu {
  background: #ebebeb;
}

.submenu .submenu .submenu {
  background: #e0e0e0;
}

/* Мобильная версия */
@media (max-width: 991px) {
  .tabs__item.has-dropdown {
    position: static;
  }

  .tabs__item.has-dropdown .menu-item-wrapper {
    width: 100%;
    justify-content: space-between;
    text-decoration: none;
  }

  .tabs__item.has-dropdown .menu-item-wrapper > a {
    flex: 0;
    text-align: left;
  }

  /* Стрелка на мобилке - кликабельная область */
  .tabs__item.has-dropdown .dropdown-arrow {
    padding: 10px;
    margin: -10px;
  }

  .tabs__item.has-dropdown .dropdown-arrow svg {
    transform: rotate(-90deg);
    transition: transform 0.3s ease;
  }

  .tabs__item.has-dropdown.active .dropdown-arrow svg {
    transform: rotate(0deg);
  }

  .tabs__item.has-dropdown > a {
    width: 100%;
    justify-content: space-between;
    text-decoration:none;
  }

  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    background: #f5f5f5;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    width:100%;
    margin-top:20px;
  }

  .tabs__item.has-dropdown.active .dropdown-menu {
    max-height: 2000px;
  }

  .dropdown-item {
    border-bottom: 1px solid #e8e8e8;
  }

  .dropdown-item > a {
  /*   padding: 14px 16px 14px 32px; */
    font-size: 13px;
    margin: 0;
    border-radius: 0;
  }

  /* Убираем hover эффекты на мобилке */
  .dropdown-item > a:hover,
  .menu-item-link:hover,
  .submenu-item > a:hover {
    background: transparent;
    color: #424242;
  }

  .menu-item-toggle:hover {
    background: transparent;
  }

/*   .menu-item-header {
  border-bottom: 1px solid #e8e8e8;
} */

  .menu-item-link {
   /*  padding: 14px 16px 14px 32px; */
    font-size: 13px;
  }

  .menu-item-toggle {
    width: 40px;
    height: 48px;
  }

/*   .submenu .menu-item-link {
  padding-left: 48px;
}

.submenu .submenu .menu-item-link {
  padding-left: 64px;
} */
}

/* "Мост" между элементами */
.tabs__item.has-dropdown::before {
  content: '';
  position: absolute;
  top: 0;
  right: -8px;
  width: 12px;
  height: 100%;
  background: transparent;
  z-index: 999;
}

.dropdown-menu,
.submenu {
  pointer-events: none;
}

.tabs__item.has-dropdown:hover .dropdown-menu {
  pointer-events: auto;
}

.dropdown-item.has-submenu.active > .submenu,
.submenu-item.has-submenu.active > .submenu {
  pointer-events: auto;
}

@media (max-width: 991px) {
  .dropdown-menu,
  .submenu {
    pointer-events: auto;
  }
}
