/* Основные стили меню */
.main-menu ul li .subcategories-list{
    background-color: unset;
    border-top: unset;
    left: unset;
    padding: unset;
    position: unset;
    box-shadow: unset;
    opacity: unset;
    top: unset;
    transition: unset;
    width: unset;
    min-width: unset;
    visibility: unset;
    z-index: unset;
    text-align: unset;
}

.main-menu-kurs > nav > ul > li {
    position: relative;
    margin: 0;
}

/* Мега-меню (с подкатегориями) */
.mega-menu-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 1000px;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-top: 3px solid #99A7B6;
    z-index: 1000;
    padding: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    /* Высота определяется содержимым */
    height: auto;
    max-height: none;
    overflow: visible;
}

.main-menu-kurs > nav > ul > li:hover .mega-menu-panel {
    display: flex;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Простое выпадающее меню (без подкатегорий) */
.dropdown-menu.simple-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 300px;
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    border-top: 3px solid #1e5aa7;
    z-index: 1000;
    padding: 10px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    list-style: none;
    margin: 0;
}

.main-menu-kurs > nav > ul > li:hover .dropdown-menu.simple-dropdown {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu.simple-dropdown .dropdown-item {
    margin: 0;
    padding: 0;
}

.dropdown-menu.simple-dropdown .dropdown-item a {
    display: block;
    padding: 8px 20px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    line-height: 1.5;
    transition: all 0.2s ease;
}

.dropdown-menu.simple-dropdown .dropdown-item a:hover {
    background-color: #f8f9fa;
    color: #1e5aa7;
}

.dropdown-menu.simple-dropdown .new-badge {
    display: inline-block;
    background-color: #ff4444;
    color: white;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 8px;
    font-weight: 600;
}

.dropdown-menu.simple-dropdown .course-date {
    display: block;
    color: #1e5aa7;
    font-size: 12px;
    margin-bottom: 2px;
    font-weight: 500;
}

/* Столбец с подкатегориями в мега-меню */
.main-menu .subcategories-column {
    width: 230px;
    min-width: 230px;
    background-color: #f8f9fa;
    padding: 15px 0;
    border-radius: 4px 0 0 4px;
    flex-shrink: 0;
	height: 100%;
}

.main-menu .subcategories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.main-menu .subcategories-list li {
    margin: 0;
    display: block;
}

.main-menu .subcategories-list a {
    display: block;
    padding: 6px 15px;
    text-decoration: none;
    color: #495057;
    font-size: 13px;
    border-left: 3px solid transparent;
	border-right: 3px solid transparent;
    transition: all 0.2s ease;
}

.main-menu .subcategories-list a:hover,
.main-menu .subcategories-list a.active {
    background-color: #fff;
    color: #1e5aa7;
    border-left-color: #1e5aa7;
	border-right-color: #1e5aa7;
}

/* Столбец с контентом в мега-меню - полностью переделано */
.main-menu .content-column {
    flex: 1;
    padding: 0 0 0 20px;
    position: relative;
    min-height: 300px;
    height: auto;
	border-left: 1px solid #e9ecef;
}

.main-menu .products-container {
    position: relative;
    height: auto;
    min-height: 300px;
    width: 100%;
}

/* Исправлено: убрано position: absolute, используем display: none/block */
.main-menu .products-group {
    display: none;
    width: 100%;
    height: auto;
    overflow-y: visible;
    padding-right: 10px;
    /* Убрано абсолютное позиционирование */
    position: static;
}

.main-menu .products-group.active {
    display: block;
}

/* Элементы курсов в мега-меню */
.main-menu .content-item {
    margin-bottom: 5px;
    border-bottom: 1px solid #f0f0f0;
    padding: 4px 0;
}

.main-menu .content-item:last-child {
    border-bottom: none;
}

.main-menu .content-item a {
    display: block;
    text-decoration: none;
    color: #333;
    line-height: 1.5;
    font-size: 13px;
    padding: 2px 0;
}

.main-menu .content-item a:hover {
    color: #99A7B6;
    text-decoration: underline;
}

/* Бейджи в мега-меню */
.main-menu .content-item .label {
    display: inline-block;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    margin: 2px;
    line-height: 1.4;
}

.main-menu .content-item .label-danger {
    background-color: #ff4444;
    color: white;
}

.main-menu .content-item .label-primary {
    background-color: #1e5aa7;
    color: white;
}

.main-menu .content-item .course-date {
    display: block;
    color: #1e5aa7;
    font-size: 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

/* Положение меню для последних элементов */
.main-menu-kurs > nav > ul > li:last-child .mega-menu-panel,
.main-menu-kurs > nav > ul > li:last-child .dropdown-menu.simple-dropdown {
    right: 0;
    left: auto;
}

/* Адаптивность */
@media (min-width: 1200px) {
    .mega-menu-panel {
        max-width: 700px;
        height: auto;
        max-height: none;
    }
}

@media (max-width: 1024px) {
    /* Стили для мобильной версии остаются прежними */
    .main-menu-kurs > nav > ul {
        flex-direction: column;
    }
    
    .main-menu-kurs > nav > ul > li > a {
        border-bottom: none;
    }
    
    .mega-menu-panel,
    .dropdown-menu.simple-dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        padding: 10px;
        display: none;
    }
    
    .main-menu-kurs > nav > ul > li.active .mega-menu-panel,
    .main-menu-kurs > nav > ul > li.active .dropdown-menu.simple-dropdown {
        display: flex;
    }
}

.main-menu-kurs > nav > ul > li:nth-last-child(2) .mega-menu-panel, 
.main-menu-kurs > nav > ul > li:nth-last-child(2) .dropdown-menu.simple-dropdown{
    left: inherit;
    right: 0;
}

.main-menu-kurs > nav > ul > li:nth-last-child(3) .mega-menu-panel, 
.main-menu-kurs > nav > ul > li:nth-last-child(3) .dropdown-menu.simple-dropdown{
    left: inherit;
    right: 0;
}

.main-menu-kurs > nav > ul > li:nth-last-child(4) .mega-menu-panel, 
.main-menu-kurs > nav > ul > li:nth-last-child(4) .dropdown-menu.simple-dropdown{
    left: inherit;
    right: -130px;
}

.main-menu-kurs > nav > ul > li:nth-last-child(5) .mega-menu-panel, 
.main-menu-kurs > nav > ul > li:nth-last-child(5) .dropdown-menu.simple-dropdown{
        left: -90px;
}

/* ЛОГИКА КОЛОНОК В ЗАВИСИМОСТИ ОТ КОЛИЧЕСТВА КУРСОВ */

/* По умолчанию (менее 8 курсов) - 1 колонка */
.products-group {
    /* Можно разделить на 2 колонки для очень длинных списков */
    column-count: 1;
    column-gap: 20px;
}

/* От 8 до 20 курсов - 2 колонки */
@media (min-width: 1200px) {
    .products-group.has-8-to-20-items {
        column-count: 2;
    }
}

/* Более 20 курсов - 3 колонки */
@media (min-width: 1200px) {
    .products-group.has-more-than-20-items {
        column-count: 3;
    }
}

/* Мобильная версия - всегда 1 колонка */
@media (max-width: 1199px) {
    .products-group,
    .products-group.has-8-to-20-items,
    .products-group.has-more-than-20-items {
        column-count: 1 !important;
    }
}

.products-group .content-item {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Дополнительные исправления для предотвращения выхода за границы */
.mega-menu-panel {
    /* Гарантируем, что контент не выходит за границы */
    overflow: hidden;
}

.content-column {
    /* Гарантируем, что контент не выходит за границы */
    overflow: visible;
}

/* Убедимся, что высота меню достаточна для контента */
.mega-menu-panel {
    /* Минимальная высота, но может увеличиваться */
    min-height: 300px;
}

/* Для очень длинных списков - ограничиваем максимальную высоту с прокруткой */
@media (min-height: 800px) {
    .mega-menu-panel {
        max-height: 600px;
        overflow-y: auto;
    }
}

.content-column.full-width{
	    padding: 0 0 0 3px;
		border-left: none;
}

.mega-menu-panel {
	display: block;
}


.has-mega-menu > .mega-menu-panel {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(6px);
	transition:
		opacity 140ms ease 120ms,
		transform 140ms ease 120ms,
		visibility 0s linear 260ms;
}

.has-mega-menu:hover > .mega-menu-panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition-delay: 180ms, 180ms, 180ms;
}