/* ==========================================================================
   Duplex Menu — Frontend Styles
   ========================================================================== */

/* --- Полоска с кнопкой Каталог (автовставка) --- */
.bcm-bar {
  background: #ffffff;
  border-bottom: 1px solid #e8e8e8;
  position: relative;
  z-index: 999;
}

.bcm-bar-inner {
  display: flex;
  align-items: center;
  padding: 8px 0;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 15px;
  padding-right: 15px;
  box-sizing: border-box;
}

/* --- Кнопка «Каталог» --- */
.bcm-catalog-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  position: relative;
  z-index: 1001;
}

.bcm-catalog-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.bcm-catalog-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.bcm-catalog-btn.bcm-active {
  border-radius: 6px 6px 0 0;
}

/* Иконка «бургер» на кнопке */
.bcm-btn-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 18px;
}

.bcm-btn-icon span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  transition: all 0.3s ease;
}

/* Анимация иконки при открытии */
.bcm-catalog-btn.bcm-active .bcm-btn-icon span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.bcm-catalog-btn.bcm-active .bcm-btn-icon span:nth-child(2) {
  opacity: 0;
}

.bcm-catalog-btn.bcm-active .bcm-btn-icon span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

/* --- Оверлей (затемнение фона) --- */
.bcm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bcm-overlay.bcm-visible {
  opacity: 1;
}

/* --- Выпадающий дропдаун --- */
.bcm-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  border-radius: 0 0 12px 12px;
  max-height: 80vh;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.bcm-dropdown.bcm-visible {
  opacity: 1;
  transform: translateY(0);
}

.bcm-dropdown-inner {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 450px;
  max-height: 80vh;
  position: relative;
}

/* --- Левая панель (категории) --- */
.bcm-left {
  width: 280px;
  min-width: 280px;
  background: #f7f7f7;
  border-right: 1px solid #e8e8e8;
  overflow-y: auto;
  border-radius: 0 0 0 12px;
}

.bcm-cat-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.bcm-cat-list li {
  margin: 0;
}

.bcm-cat-list li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.bcm-cat-list li a:hover,
.bcm-cat-list li.bcm-cat-active a {
  background: #ffffff;
  color: #000;
  border-left-color: #e4922e;
}

.bcm-cat-list li a .bcm-cat-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.bcm-cat-list li a .bcm-cat-icon-placeholder {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #bbb;
  font-size: 16px;
}

.bcm-cat-list li a .bcm-cat-name {
  flex: 1;
}

.bcm-cat-list li a .bcm-cat-arrow {
  color: #bbb;
  font-size: 14px;
  transition: color 0.15s;
  margin-left: auto;
}

.bcm-cat-list li.bcm-cat-active a .bcm-cat-arrow,
.bcm-cat-list li a:hover .bcm-cat-arrow {
  color: #e4922e;
}

/* --- Правая панель (подкатегории) --- */
.bcm-right {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px;
  background: #fff;
  border-radius: 0 0 12px 0;
}

.bcm-subcat-panel {
  display: grid;
  gap: 24px 30px;
  grid-template-columns: repeat(3, 1fr);
}

.bcm-subcat-panel[data-columns="1"] {
  grid-template-columns: 1fr;
}
.bcm-subcat-panel[data-columns="2"] {
  grid-template-columns: repeat(2, 1fr);
}
.bcm-subcat-panel[data-columns="3"] {
  grid-template-columns: repeat(3, 1fr);
}
.bcm-subcat-panel[data-columns="4"] {
  grid-template-columns: repeat(4, 1fr);
}
.bcm-subcat-panel[data-columns="5"] {
  grid-template-columns: repeat(5, 1fr);
}
.bcm-subcat-panel[data-columns="6"] {
  grid-template-columns: repeat(6, 1fr);
}

/* Группа подкатегорий */
.bcm-subcat-group {
  margin-bottom: 8px;
}

.bcm-subcat-group-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.bcm-subcat-group-title a {
  color: #222;
  text-decoration: none;
  transition: color 0.15s;
}

.bcm-subcat-group-title a:hover {
  color: #e4922e;
}

.bcm-subcat-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bcm-subcat-group ul li {
  margin: 0 0 4px 0;
}

.bcm-subcat-group ul li a {
  color: #666;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.5;
  transition: color 0.15s;
}

.bcm-subcat-group ul li a:hover {
  color: #e4922e;
}

/* Ссылка "Смотреть все" */
.bcm-view-all {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

.bcm-view-all a {
  color: #e4922e;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s;
}

.bcm-view-all a:hover {
  opacity: 0.8;
}

.bcm-view-all a::after {
  content: "→";
}

/* Пустое состояние правой панели */
.bcm-subcat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  font-size: 15px;
  grid-column: 1 / -1;
}

/* --- Кнопка закрытия --- */
.bcm-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
  padding: 0;
}

.bcm-close:hover {
  background: #f0f0f0;
  color: #333;
}

/* --- Скроллбар --- */
.bcm-left::-webkit-scrollbar,
.bcm-right::-webkit-scrollbar {
  width: 6px;
}

.bcm-left::-webkit-scrollbar-track,
.bcm-right::-webkit-scrollbar-track {
  background: transparent;
}

.bcm-left::-webkit-scrollbar-thumb,
.bcm-right::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.bcm-left::-webkit-scrollbar-thumb:hover,
.bcm-right::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

/* ==========================================================================
   Мобильная кнопка «Назад»
   ========================================================================== */
.bcm-mobile-back {
  display: none; /* Показывается только на мобильном */
}

/* ==========================================================================
   МОБИЛЬНАЯ АДАПТИВНОСТЬ (≤ 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  /* Дропдаун — полноэкранный */
  .bcm-dropdown {
    border-radius: 0;
    max-height: 100vh;
    max-height: 100dvh;
    top: 0 !important;
    bottom: 0;
    position: fixed !important;
  }

  .bcm-dropdown-inner {
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
  }

  /* --- Левая панель: полная ширина --- */
  .bcm-left {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-radius: 0;
    flex: 1;
    overflow-y: auto;
  }

  /* --- Правая панель: скрыта по умолчанию --- */
  .bcm-right {
    display: none;
    border-radius: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
  }

  /* Когда открыты подкатегории */
  .bcm-dropdown.bcm-mobile-subcat-open .bcm-left {
    display: none;
  }

  .bcm-dropdown.bcm-mobile-subcat-open .bcm-right {
    display: flex;
    flex-direction: column;
  }

  .bcm-dropdown.bcm-mobile-subcat-open .bcm-right .bcm-subcat-panel {
    padding: 16px;
    flex: 1;
  }

  /* Стрелка на мобильном */
  .bcm-cat-list li a .bcm-cat-arrow {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: #bbb;
  }

  /* Чуть больше отступы для тач */
  .bcm-cat-list li a {
    padding: 14px 20px;
    font-size: 15px;
  }

  /* Подкатегории — одна колонка */
  .bcm-subcat-panel {
    grid-template-columns: 1fr !important;
  }

  /* --- Кнопка «Назад» --- */
  .bcm-mobile-back {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-bottom: 1px solid #e8e8e8;
    background: #f7f7f7;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: left;
    flex-shrink: 0;
    transition: background 0.15s;
  }

  .bcm-mobile-back:hover,
  .bcm-mobile-back:active {
    background: #eee;
  }

  .bcm-mobile-back-arrow {
    font-size: 22px;
    line-height: 1;
    color: #e4922e;
    font-weight: bold;
  }

  .bcm-mobile-back-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Кнопка закрытия на мобильном */
  .bcm-close {
    top: 8px;
    right: 8px;
    z-index: 10;
  }

  /* Кнопка каталог на мобильном */
  .bcm-catalog-btn.bcm-active {
    border-radius: 6px;
  }
}

/* ==========================================================================
   Маленькие экраны (≤ 600px)
   ========================================================================== */
@media (max-width: 600px) {
  .bcm-catalog-btn {
    padding: 8px 16px;
    font-size: 14px;
  }

  .bcm-cat-list li a {
    padding: 12px 16px;
    font-size: 14px;
  }

  .bcm-mobile-back {
    padding: 12px 16px;
    font-size: 14px;
  }

  .bcm-dropdown.bcm-mobile-subcat-open .bcm-right .bcm-subcat-panel {
    padding: 12px;
  }
}
