﻿/* Основные стили */
.category-menu {
    position: relative;
}

.category-menu-compact {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: visible;
    border: 1px solid #e0e0e0;
    width: 280px;
    position: relative;
    min-height: auto;
    height: auto;
}

.category-menu-header {
    background: #f8f9fa;
    color: #2c3e50;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e0e0e0;
    height: 58px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 3;
}

    .category-menu-header h5 {
        font-weight: 600;
        margin: 0;
        font-size: 1rem;
    }

.category-menu-items {
    padding: 0.5rem 0;
    position: relative;
    height: auto;
}

.category-item {
    position: relative;
    border-bottom: 1px solid #f5f5f5;
}

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

.category-main {
    position: relative;
    z-index: 2;
}

.category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: white;
    position: relative;
    z-index: 2;
}

    .category-link:hover {
        background: #f0f7ff;
        color: #007bff;
    }

.category-name {
    font-weight: 500;
}

.arrow {
    font-size: 0.7rem;
    color: #7f8c8d;
}

/* Подменю - ТОЛЬКО ОБЩАЯ ПРОКРУТКА */
.category-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    width: 900px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 0 8px 8px 0;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    z-index: 1000;
    height: auto;
    max-height: 85vh; /* Ограничиваем максимальную высоту */
    overflow-y: auto; /* Включаем вертикальную прокрутку */
    overflow-x: hidden; /* Скрываем горизонтальную прокрутку */
}

/* Показываем подменю при наведении на ЛЮБУЮ категорию в этом меню */
.category-menu:hover .category-submenu {
    display: block;
    animation: slideInRight 0.2s ease;
}

.submenu-content {
    padding: 1.5rem;
    height: auto;
    box-sizing: border-box;
    min-height: 0;
}

.submenu-title {
    color: #007bff;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #007bff;
    font-size: 1.1rem;
    position: sticky;
    top: 0;
    background: white;
    z-index: 2;
    padding-top: 0.5rem;
    margin-top: -0.5rem;
}

.submenu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    height: auto;
}

.submenu-column {
    display: flex;
    flex-direction: column;
}

.submenu-main-link {
    display: block;
    font-weight: 600;
    color: #007bff;
    text-decoration: none;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

    .submenu-main-link:hover {
        color: #0056b3;
        padding-left: 0.5rem;
    }

.submenu-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* УБИРАЕМ прокрутку для подкатегорий 2 уровня */
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
}

.submenu-item {
    position: relative;
}

.submenu-link {
    display: block;
    color: #495057;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
    position: relative;
}

    .submenu-link:hover {
        background: #f8f9fa;
        color: #007bff;
        border-left-color: #007bff;
    }

/* Подкатегории 3 уровня - ОТКРЫВАЮТСЯ СНИЗУ */
.subsubmenu-popup {
    display: none;
    position: absolute;
    left: 0;
    top: 100%; /* Открывается снизу от подкатегории 2 уровня */
    width: 100%;
    background: white;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1001;
    border: 1px solid #e0e0e0;
    border-top: none;
    animation: slideInDown 0.15s ease;
    /* УБИРАЕМ прокрутку для подкатегорий 3 уровня */
    max-height: none;
    overflow-y: visible;
}

.submenu-item:hover .subsubmenu-popup {
    display: block;
}

.subsubmenu-content {
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.subsubmenu-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.8rem;
    border-radius: 3px;
    transition: all 0.15s ease;
    text-align: center;
}

    .subsubmenu-link:hover {
        background: #f8f9fa;
        color: #007bff;
    }

/* Анимации */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* СТИЛИ ДЛЯ ПОЛОС ПРОКРУТКИ - ТОЛЬКО ДЛЯ ОСНОВНОГО ПОДМЕНЮ */
.category-submenu::-webkit-scrollbar {
    width: 8px;
}

.category-submenu::-webkit-scrollbar-track {
    background: #f9f9f9;
    border-radius: 4px;
}

.category-submenu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

    .category-submenu::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

/* УБИРАЕМ стили скроллбаров для подкатегорий 2 и 3 уровня */
.submenu-list::-webkit-scrollbar,
.subsubmenu-popup::-webkit-scrollbar {
    display: none;
}

/* Для Firefox - ТОЛЬКО ДЛЯ ОСНОВНОГО ПОДМЕНЮ */
.category-submenu {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f9f9f9;
}

/* УБИРАЕМ для подкатегорий 2 и 3 уровня */
.submenu-list,
.subsubmenu-popup {
    scrollbar-width: none;
}

/* Адаптивность */
@media (max-width: 1400px) {
    .category-submenu {
        width: 800px;
    }

    .submenu-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 1200px) {
    .category-submenu {
        width: 700px;
        max-height: 80vh;
    }

    .submenu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .category-submenu {
        width: 600px;
        max-height: 75vh;
    }
}

@media (max-width: 768px) {
    .category-menu-compact {
        width: 100%;
    }

    .category-submenu {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        border-radius: 0;
        max-height: 100vh;
    }

    .submenu-grid {
        grid-template-columns: 1fr;
    }

    .subsubmenu-popup {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 300px;
        z-index: 10002;
    }
}

/* Улучшение UX для вложенных меню */
.submenu-item:has(.subsubmenu-popup) .submenu-link::after {
    content: "▾"; /* Меняем на стрелку вниз */
    margin-left: 0.5rem;
    font-size: 0.7rem;
    color: #7f8c8d;
}

.submenu-item:hover .submenu-link::after {
    color: #007bff;
}

/* Подсветка активной подкатегории 2 уровня при наведении на 3 уровень */
.submenu-item:hover .submenu-link {
    background: #f0f7ff;
    color: #007bff;
    border-left-color: #007bff;
}

/* Стили для placeholder */
.placeholder-text {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 2rem;
    grid-column: 1 / -1;
}

.no-subcategories {
    text-align: center;
    padding: 2rem;
    grid-column: 1 / -1;
}

    .no-subcategories p {
        margin-bottom: 1rem;
    }

/* Скрываем данные */
.category-data {
    display: none !important;
}

/* Обеспечиваем одинаковую высоту основного меню и подменю */
.category-menu-compact::after {
    content: '';
    display: table;
    clear: both;
}

/* Улучшаем отображение при прокрутке */
.submenu-column {
    min-height: 0;
}
