.x-mega {
    display: none;
}

.x-mega.is-open {
    display: block;
}

html.x-mega-open,
body.x-mega-open {
    overflow: hidden;
}
.x-mega__panel {
    position: fixed;
    left: 0;
    right: 0;
    top: 115px;
    height: 80vh;
    background: #fff;
    box-shadow: 0 60px 60px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    overflow: hidden; /* скрываем переполнение панели */
}

.x-mega__inner {
    height: 100%;
    display: flex; /* вместо grid */
    flex-direction: row;
    overflow: hidden;
}

.x-mega__left {
    flex: 0 0 320px; /* фиксированная ширина */
    border-right: 1px solid #eef2f7;
    padding: 28px 18px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}

.x-mega__main {
    flex: 1 1 auto; /* занимает оставшееся место */
    padding: 26px 30px 30px;
    overflow-y: auto;
    height: 80vh;
    box-sizing: border-box;
}

.x-mega__ttl {
    margin: 0 0 24px;
    font-size: 16px;
    font-weight: 500;
    color: #718096;
}

.x-mega__cats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.x-mega__cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #3f3f46;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    background: transparent;
    transition:
        color 0.2s ease,
        background 0.2s ease;
}

.x-mega__cat::after {
    content: "›";
    opacity: 0;
    color: #67c85f;
    font-size: 20px;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.x-mega__cat:hover {
    color: #67c85f;
    background: transparent;
}

.x-mega__cat.is-active {
    color: #67c85f;
    background: transparent;
}

.x-mega__cat.is-active::after {
    opacity: 1;
}

.x-mega__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.x-mega__prod {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    min-height: 100%;
    padding: 24px 22px 20px;
    border-radius: 18px;
    background: #f5f7fb;
    color: #0b1220;
    transition: transform 0.2s ease;
}

/* .x-mega__prod:hover {
    background: #f5f7fb;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
} */

.x-mega__img {
    width: 100%;
    height: 180px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.x-mega__img img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.x-mega__name {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    color: #3f3f46;
}

.x-mega__desc {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.35;
    color: #8b8b95;
}

.x-mega__btn {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 126px;
    min-height: 42px;
    padding: 0 22px;
    border-radius: 999px;
    background: #eceff5;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.x-mega__loading,
.x-mega__empty {
    padding: 16px 18px;
    border-radius: 16px;
    background: #f5f7fb;
    color: #6b7280;
    font-weight: 700;
}

/* Заголовок подкатегории */
.x-mega__subcat-title {
    margin: 20px 0 12px;
    font-size: 18px;
    font-weight: 700;
    color: #1a202c;
    padding-bottom: 6px;
}

/* Сетка товаров внутри подкатегории */
.x-mega__subcat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .x-mega__subcat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .x-mega__subcat-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1280px) {
    .x-mega__inner {
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .x-mega__main {
        padding: 24px;
    }

    .x-mega__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .x-mega__inner {
        grid-template-columns: 1fr;
    }

    .x-mega__left {
        border-right: 0;
        border-bottom: 1px solid #eef2f7;
        padding: 20px 18px;
    }

    .x-mega__main {
        padding: 20px 18px 24px;
    }
}

.x-mega {
    display: none;
}

.x-mega.is-open {
    display: block;
}

html.x-mega-open,
body.x-mega-open {
    overflow: hidden;
}
.x-mega__panel {
    position: fixed;
    left: 0;
    right: 0;
    top: 115px;
    height: 80vh;
    background: #fff;
    box-shadow: 0 60px 60px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    overflow: hidden; /* скрываем переполнение панели */
}

.x-mega__inner {
    height: 100%;
    display: flex; /* вместо grid */
    flex-direction: row;
    overflow: hidden;
}

.x-mega__left {
    flex: 0 0 320px; /* фиксированная ширина */
    border-right: 1px solid #eef2f7;
    padding: 28px 18px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}

.x-mega__main {
    flex: 1 1 auto; /* занимает оставшееся место */
    padding: 26px 30px 30px;
    overflow-y: auto;
    height: 80vh;
    box-sizing: border-box;
}

.x-mega__ttl {
    margin: 0 0 24px;
    font-size: 16px;
    font-weight: 500;
    color: #718096;
}

.x-mega__cats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.x-mega__cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #3f3f46;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    background: transparent;
    transition:
        color 0.2s ease,
        background 0.2s ease;
}

.x-mega__cat::after {
    content: "›";
    opacity: 0;
    color: #67c85f;
    font-size: 20px;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.x-mega__cat:hover {
    color: #67c85f;
    background: transparent;
}

.x-mega__cat.is-active {
    color: #67c85f;
    background: transparent;
}

.x-mega__cat.is-active::after {
    opacity: 1;
}

.x-mega__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.x-mega__prod {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    min-height: 100%;
    padding: 24px 22px 20px;
    border-radius: 18px;
    background: #f5f7fb;
    color: #0b1220;
    transition: transform 0.2s ease;
}

/* .x-mega__prod:hover {
    background: #f5f7fb;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
} */

.x-mega__img {
    width: 100%;
    height: 180px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.x-mega__img img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.x-mega__name {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    color: #3f3f46;
}

.x-mega__desc {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.35;
    color: #8b8b95;
}

.x-mega__btn {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 126px;
    min-height: 42px;
    padding: 0 22px;
    border-radius: 999px;
    background: #eceff5;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}

.x-mega__loading,
.x-mega__empty {
    padding: 16px 18px;
    border-radius: 16px;
    background: #f5f7fb;
    color: #6b7280;
    font-weight: 700;
}

/* Заголовок подкатегории */
.x-mega__subcat-title {
    margin: 20px 0 12px;
    font-size: 18px;
    font-weight: 700;
    color: #1a202c;
    padding-bottom: 6px;
}

/* Сетка товаров внутри подкатегории */
.x-mega__subcat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .x-mega__panel {
        top: 96px;
        height: calc(100vh - 96px);
        border-bottom-left-radius: 18px;
        border-bottom-right-radius: 18px;
        overflow-y: auto;
    }

    .x-mega__inner {
        display: block;
        height: auto;
    }

    .x-mega__left {
        flex: none;
        width: 100%;
        border-right: none;
        padding: 16px 18px;
        overflow-y: visible;
        height: auto;
        max-height: none;
    }

    .x-mega__main {
        display: none !important; /* скрываем правую колонку */
    }

    .x-mega__cat {
        padding: 14px 16px;
        font-size: 16px;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .x-mega__cat.is-active {
        background: #f5f7fb;
        border-radius: 12px;
    }

    .x-mega__mobile-products {
        padding: 8px 0 16px 16px;
        border-bottom: 1px solid #eef2f7;
        display: none;
    }

    .x-mega__mobile-products .x-mega__subcat-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-top: 8px;
    }

    .x-mega__mobile-products .x-mega__subcat-title {
        font-size: 15px;
        margin: 12px 0 6px;
        font-weight: 600;
    }

    .x-mega__mobile-products .x-mega__prod {
        padding: 16px 12px;
        background: #f5f7fb;
        border-radius: 12px;
    }

    .x-mega__mobile-products .x-mega__img {
        height: 120px;
    }

    .x-mega__mobile-products .x-mega__name {
        font-size: 15px;
    }

    .x-mega__mobile-products .x-mega__btn {
        font-size: 13px;
        min-height: 36px;
        min-width: 100px;
        padding: 0 16px;
    }

    /* Мобильный аккордеон */
    .x-mobile-accordion {
        display: none; /* управляется JS */
        background: #fff;
        border-top: 1px solid #eef2f7;
        padding: 16px 8px;
        max-height: 70vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .x-mobile-accordion.is-open {
        display: block;
    }

    .x-mobile-accordion__cats {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .x-mobile-accordion .x-mega__cat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 16px;
        font-weight: 700;
        color: #3f3f46;
        cursor: pointer;
    }

    .x-mobile-accordion .x-mega__cat.is-active {
        color: #67c85f;
    }

    .x-mobile-accordion__products .x-mega__subcat-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin: 8px 0 16px;
    }

    .x-mobile-accordion__products .x-mega__subcat-title {
        font-size: 15px;
        font-weight: 600;
        margin: 12px 0 6px;
    }

    .x-mobile-accordion__products .x-mega__prod {
        background: #f5f7fb;
        border-radius: 12px;
        padding: 16px 12px;
        text-align: center;
        text-decoration: none;
        color: #0b1220;
    }

    .x-mobile-accordion__products .x-mega__img {
        height: 120px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .x-mobile-accordion__products .x-mega__img img {
        max-height: 100%;
        max-width: 100%;
    }

    .x-mobile-accordion__products .x-mega__name {
        font-size: 15px;
        font-weight: 800;
        margin: 8px 0 4px;
    }

    .x-mobile-accordion__products .x-mega__btn {
        font-size: 13px;
        background: #eceff5;
        padding: 8px 16px;
        border-radius: 999px;
        display: inline-block;
    }
}

/* Кнопка-стрелка для мобильного меню */
.x-menu-arrow {
    display: none; /* скрыто на десктопе */
    width: 32px;
    height: 32px;
    background: #f4f4f4; /* фон квадратной кнопки */
    border-radius: 6px;
    margin-left: auto; /* прижать к правому краю */
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
}
.x-menu-arrow::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    border: solid #333;
    border-width: 0 2px 2px 0;
    padding: 4px;
}

.x-mobile-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f4f4f4;
    border-radius: 6px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
}
.x-mobile-arrow::after {
    content: "▼";
    font-size: 12px;
    color: #333;
}
/* Показываем стрелки только на мобильных */
@media (max-width: 768px) {
    .x-menu-arrow {
        display: flex; /* flex, чтобы центрировать иконку */
        align-items: center;
        justify-content: center;
    }
    .x-mega-trigger {
        display: flex;
        align-items: center;
    }
}
