/* ============================================
   МЕГА-МЕНЮ КАТАЛОГА - Выпадение вправо при наведении
   ============================================ */

/* Контейнер мега-меню */
.menu-item-catalog {
    position: static !important;
}

.mega-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-height: 400px;
    max-height: 80vh;
}

/* Показываем меню при наведении на пункт "Каталог" */
.menu-item-catalog:hover .mega-menu {
    display: flex;
}

/* Колонки меню */
.mega-menu-level1,
.mega-menu-level2,
.mega-menu-level3 {
    min-width: 280px;
    max-width: 320px;
    max-height: 80vh;
    overflow-y: auto;
    border-right: 1px solid #f0f0f0;
    background: #fff;
}

.mega-menu-level1 {
    border-radius: 0 0 0 8px;
}

/* Скрытые уровни 2 и 3 */
.mega-menu-level2,
.mega-menu-level3 {
    display: none;
}

/* Активные уровни */
.mega-menu-level2.active,
.mega-menu-level3.active {
    display: block;
}

/* Заголовки уровней */
.mega-menu-level2-header,
.mega-menu-level3-header {
    padding: 12px 20px;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
}

.mega-menu-level2-header a,
.mega-menu-level3-header a {
    font-weight: 600;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}

.mega-menu-level2-header a:hover,
.mega-menu-level3-header a:hover {
    color: #F1BE4C;
}

/* Пункты меню */
.mega-menu-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.mega-menu-item:last-child {
    border-bottom: none;
}

.mega-menu-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 15px 11px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s ease;
    gap: 10px;
}

.mega-menu-link:hover {
    background: rgba(241, 190, 76, 0.08);
    color: #333;
}

/* Активный пункт (при наведении показывающий подменю) */
.mega-menu-item.active > .mega-menu-link {
    background: rgba(241, 190, 76, 0.12);
    color: #d4a543;
}

.mega-menu-item.active > .mega-menu-link .mega-menu-arrow {
    color: #d4a543;
}

/* Название категории */
.mega-menu-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Правая часть (счетчик + стрелка) */
.mega-menu-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Счетчик товаров - желтый бейдж */
.mega-menu-count {
    background: #F1BE4C;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 28px;
    text-align: center;
    line-height: 1.4;
}

/* Стрелка вправо */
.mega-menu-arrow {
    color: #ccc;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    transition: color 0.15s ease;
}

.mega-menu-item.has-children:hover .mega-menu-arrow {
    color: #F1BE4C;
}

/* Скроллбар для длинных списков */
.mega-menu-level1::-webkit-scrollbar,
.mega-menu-level2::-webkit-scrollbar,
.mega-menu-level3::-webkit-scrollbar {
    width: 6px;
}

.mega-menu-level1::-webkit-scrollbar-track,
.mega-menu-level2::-webkit-scrollbar-track,
.mega-menu-level3::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.mega-menu-level1::-webkit-scrollbar-thumb,
.mega-menu-level2::-webkit-scrollbar-thumb,
.mega-menu-level3::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.mega-menu-level1::-webkit-scrollbar-thumb:hover,
.mega-menu-level2::-webkit-scrollbar-thumb:hover,
.mega-menu-level3::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* ============================================
   АДАПТИВ ДЛЯ МОБИЛЬНЫХ
   ============================================ */

@media (max-width: 800px) {
    /* Отключаем hover на мобильных */
    .menu-item-catalog:hover .mega-menu {
        display: none !important;
    }

    /* Мега-меню по умолчанию скрыто */
    .mega-menu {
        display: none !important;
        position: relative;
        top: 0;
        left: 0;
        flex-direction: column;
        min-height: auto;
        max-height: none;
        box-shadow: none;
        border-radius: 0;
        width: 100%;
        background: #fff;
    }

    /* Когда меню открыто по клику */
    .menu-item-catalog.mobile-open .mega-menu {
        display: block !important;
    }

    /* Уровень 1 - всегда видим когда меню открыто */
    .mega-menu-level1 {
        display: block !important;
        min-width: 100%;
        max-width: 100%;
        max-height: none;
        border-right: none;
        background: #fff;
    }

    /* Уровни 2 и 3 - скрыты по умолчанию, показываются по клику */
    .mega-menu-level2,
    .mega-menu-level3 {
        display: none !important;
        min-width: 100%;
        max-width: 100%;
        max-height: none;
        border-right: none;
        padding-left: 0;
        background: #f5f5f5;
        border-left: 3px solid #F1BE4C;
        margin-left: 10px;
    }

    .mega-menu-level3 {
        background: #efefef;
        margin-left: 20px;
    }

    /* Показываем активные подменю */
    .mega-menu-level2.active,
    .mega-menu-level3.active {
        display: block !important;
    }

    /* Стрелка на мобильных - больше область клика */
    .mega-menu-arrow {
        padding: 10px 15px;
        margin: -10px -15px -10px 0;
        font-size: 22px;
        color: #F1BE4C;
    }

    /* Поворот стрелки при раскрытии */
    .mega-menu-item.mobile-expanded > .mega-menu-link .mega-menu-arrow {
        transform: rotate(90deg);
    }

    /* Заголовки уровней на мобильных */
    .mega-menu-level2-header,
    .mega-menu-level3-header {
        padding: 10px 15px;
        background: #e8e8e8;
    }

    /* Ссылки на мобильных */
    .mega-menu-link {
        padding: 12px 15px;
    }

    /* Убираем ненужные стили */
    .mega-menu-item.active > .mega-menu-link {
        background: transparent;
        color: #333;
    }

    .mega-menu-item.mobile-expanded > .mega-menu-link {
        background: rgba(241, 190, 76, 0.15);
        color: #333;
    }
}

/* ============================================
   ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ
   ============================================ */

/* Плавное появление подменю */
.mega-menu-level2,
.mega-menu-level3 {
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Убираем outline при фокусе */
.mega-menu-link:focus {
    outline: none;
}

/* Подсветка всей строки при наведении */
.mega-menu-item:hover {
    background: rgba(241, 190, 76, 0.04);
}