/**
 * Мега-меню курсов для Impreza
 * Привязывается к пункту меню с CSS-классом: mega-menu-courses
 * Никаких внешних зависимостей — иконки из шрифтов темы (Font Awesome)
 */

/* ========== FA FALLBACK (если us-core не загрузил полный FA) ========== */
@font-face {
    font-family: 'fa-solid-mm';
    font-display: swap;
    font-style: normal;
    font-weight: 900;
    src: url(../fonts/fa-solid-900.woff2) format("woff2");
}

.mm-icon {
    font-family: 'fa-solid-mm', 'fontawesome', sans-serif;
    display: inline-block;
    line-height: 1;
    font-weight: 900;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
}

/* ========== ПУНКТ МЕНЮ — КОНТЕЙНЕР ========== */
.w-nav-item.mega-menu-courses {
    position: static !important;
}

/* Индикатор раскрытия — скрыт */
.w-nav-item.mega-menu-courses > .w-nav-anchor .w-nav-arrow {
    display: none !important;
}

.w-nav-item.mega-menu-courses > .w-nav-anchor:hover .w-nav-arrow,
.w-nav-item.mega-menu-courses.mm-open > .w-nav-anchor .w-nav-arrow {
    opacity: 1;
}

.w-nav-item.mega-menu-courses.mm-open > .w-nav-anchor .w-nav-arrow {
    transform: rotate(180deg);
}

/* ========== ОВЕРЛЕЙ ========== */
.mm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 90;
    pointer-events: none;
}

.mm-overlay.mm-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ========== ВЫПАДАЮЩЕЕ МЕГА-МЕНЮ ========== */
.mm-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 1100px;
    max-width: calc(100vw - 30px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border-radius: 14px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.04);
    padding: 16px 20px 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    will-change: opacity, transform;
    z-index: 100;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.mm-dropdown.mm-active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ========== ШАПКА МЕГА-МЕНЮ (скрыта) ========== */
.mm-header {
    display: none;
}

.mm-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.mm-search {
    position: relative;
    width: 240px;
}

.mm-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    background: #f8fafc;
    color: #334155;
    box-shadow: none;
    -webkit-appearance: none;
}

.mm-search input:focus {
    border-color: #e95095;
    background: #fff;
}

.mm-search input::placeholder {
    color: #94a3b8;
}

.mm-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
}

/* ========== СЕТКА КАТЕГОРИЙ ========== */
.mm-grid {
    columns: 4;
    column-gap: 4px;
}

/* ========== КАТЕГОРИЯ ========== */
.mm-cat {
    padding: 6px 8px 8px;
    border-radius: 10px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: 4px;
}

.mm-cat:hover {
    background: #f8fafc;
}

.mm-cat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid #f1f5f9;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.3;
}

.mm-cat-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.mm-cat-links {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mm-cat-links li {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.mm-cat-links li::before,
.mm-cat-links li::after {
    display: none !important;
    content: none !important;
}

.mm-cat-links > li > a {
    display: flex;
    align-items: center;
    padding: 4px 7px;
    color: #475569 !important;
    text-decoration: none !important;
    font-size: 15px;
    font-weight: 400;
    border-radius: 5px;
    transition: color 0.1s, background-color 0.1s;
    line-height: 1.35;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

.mm-cat-links > li > a:hover {
    background: #f0f7ff !important;
    color: #0071bc !important;
}

.mm-cat-links .mm-arrow {
    display: none;
}

.mm-cat-links > li > a:hover .mm-arrow {
    display: none;
}

/* ========== ПОДМЕНЮ ВНУТРИ КАТЕГОРИИ ========== */
.mm-has-sub > a {
    font-weight: 500 !important;
}

.mm-submenu {
    list-style: none !important;
    padding: 0 0 0 14px !important;
    margin: 2px 0 4px 9px !important;
    border-left: 2px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mm-submenu li {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.mm-submenu li::before,
.mm-submenu li::after {
    display: none !important;
    content: none !important;
}

.mm-submenu a {
    font-size: 12px !important;
    color: #64748b !important;
    padding: 3px 8px;
    display: block;
    text-decoration: none !important;
    border-radius: 4px;
    transition: all 0.15s ease;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    line-height: 1.4;
}

.mm-submenu a:hover {
    color: #0071bc !important;
    background: #fdf2f8 !important;
}

/* ========== ЦВЕТА КАТЕГОРИЙ ========== */
.mm-c-auto .mm-cat-icon     { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.mm-c-build .mm-cat-icon    { background: linear-gradient(135deg, #f59e0b, #d97706); }
.mm-c-metal .mm-cat-icon    { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.mm-c-weld .mm-cat-icon     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.mm-c-electro .mm-cat-icon  { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.mm-c-machine .mm-cat-icon  { background: linear-gradient(135deg, #10b981, #059669); }
.mm-c-warehouse .mm-cat-icon{ background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.mm-c-other .mm-cat-icon    { background: linear-gradient(135deg, #64748b, #475569); }

.mm-c-auto .mm-cat-head     { border-bottom-color: #dbeafe; }
.mm-c-build .mm-cat-head    { border-bottom-color: #fef3c7; }
.mm-c-metal .mm-cat-head    { border-bottom-color: #e0e7ff; }
.mm-c-weld .mm-cat-head     { border-bottom-color: #fee2e2; }
.mm-c-electro .mm-cat-head  { border-bottom-color: #ffedd5; }
.mm-c-machine .mm-cat-head  { border-bottom-color: #d1fae5; }
.mm-c-warehouse .mm-cat-head{ border-bottom-color: #ede9fe; }
.mm-c-other .mm-cat-head    { border-bottom-color: #f1f5f9; }

/* ========== НЕТ РЕЗУЛЬТАТОВ ========== */
.mm-no-results {
    display: none;
    column-span: all;
    text-align: center;
    padding: 24px 16px;
    color: #94a3b8;
}

.mm-no-results .mm-icon {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

.mm-no-results.mm-visible {
    display: block;
}

/* ========== СКРОЛЛБАР ========== */
.mm-dropdown::-webkit-scrollbar {
    width: 5px;
}

.mm-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.mm-dropdown::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.mm-dropdown {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* ========== АДАПТИВ ========== */
@media (max-width: 1140px) {
    .mm-grid {
        columns: 3;
    }
    .mm-dropdown {
        width: 860px;
    }
}

@media (max-width: 1024px) {
    .mm-dropdown {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 100px);
    }
    .mm-grid {
        columns: 3;
    }
}

@media (max-width: 900px) {
    /* Мобильный режим Impreza (breakpoint из темы) */
    .mm-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: none;
        z-index: 9999;
        padding: 16px;
    }

    .mm-dropdown.mm-active {
        transform: none;
    }

    .mm-grid {
        columns: 2;
        column-gap: 4px;
    }

    .mm-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .mm-search {
        width: 100%;
    }

    .mm-close-mobile {
        display: flex !important;
    }
}

@media (max-width: 600px) {
    .mm-grid {
        columns: 1;
    }

    .mm-cat {
        padding: 8px 10px 10px;
    }
}

/* Кнопка закрытия для мобильных */
.mm-close-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #64748b;
    transition: all 0.2s;
    z-index: 10;
    line-height: 1;
}

.mm-close-mobile:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* ========== СКРЫТЬ СТАНДАРТНЫЙ ДРОПДАУН IMPREZA ========== */
.w-nav-item.mega-menu-courses > .w-nav-list {
    display: none !important;
}
