/* ===== АвтосетьУАЗ Мега-Меню v2 ===== */

/* ====================================================================
   ОБЩЕЕ
   ==================================================================== */

/* --- Блокировка скролла body --- */
body.avto-mm-noscroll {
    overflow: hidden !important;
    touch-action: none;
}

:root {
    --avto-mm-icon-bg: #d8cf9b;
    --avto-mm-icon-fg-filter: brightness(0) saturate(100%) invert(8%) sepia(8%) saturate(1323%) hue-rotate(181deg) brightness(95%) contrast(96%);
}

/* --- Кнопка Каталог на десктопе: не трогаем .mobile-header-components,
      кнопка #mobile-menu-icon уже вставлена пользователем в шаблон --- */

/* ====================================================================
   МОБИЛЬНОЕ МЕНЮ (bottom-sheet, < 992px)
   ==================================================================== */

/* --- Оверлей --- */
.avto-mm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.avto-mm-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Контейнер меню --- */
.avto-mm {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 88vh;
    max-height: 88vh;
    z-index: 99999;
    background: #12131a;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
}

.avto-mm.is-open {
    transform: translateY(0);
}

/* --- Шапка --- */
.avto-mm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.avto-mm-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.avto-mm-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.avto-mm-title-count {
    display: inline-block;
    margin-left: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #9da4ae;
}

.avto-mm-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.avto-mm-close:hover,
.avto-mm-close:active {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Тело (скролл) --- */
.avto-mm-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 0 40px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .avto-mm-body {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* --- Категории --- */
.avto-mm-categories {
    padding: 0 12px;
}

.avto-mm-cat {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.avto-mm-cat:last-child {
    border-bottom: none;
}

/* --- Строка категории --- */
.avto-mm-cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 8px;
    min-height: 52px;
}

.avto-mm-icon {
    width: 34px;
    height: 34px;
    padding: 7px;
    border-radius: 50%;
    background: var(--avto-mm-icon-bg);
    box-sizing: border-box;
    flex-shrink: 0;
    opacity: 1;
}

.avto-mm-cat-name {
    flex: 1;
    color: #e8e8ec;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.3;
    transition: color 0.15s;
}

.avto-mm-cat-name:hover,
.avto-mm-cat-name:active {
    color: #f0c850;
}

/* --- Стрелка --- */
.avto-mm-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 0;
    border-radius: 8px;
    transition: transform 0.25s ease, color 0.15s, background 0.15s;
}

.avto-mm-arrow:hover,
.avto-mm-arrow:active {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}

.avto-mm-arrow.is-open {
    transform: rotate(180deg);
    color: #f0c850;
}

/* --- Подкатегории --- */
.avto-mm-subcats {
    display: none;
    padding: 0 8px 10px 42px;
}

.avto-mm-subcat {
    display: block;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13.5px;
    text-decoration: none;
    border-radius: 8px;
    line-height: 1.35;
    transition: background 0.15s, color 0.15s;
}

.avto-mm-subcat-count {
    color: #9da4ae;
    font-size: 12px;
    margin-left: 4px;
}

.avto-mm-subcat:hover,
.avto-mm-subcat:active {
    background: rgba(255, 255, 255, 0.06);
    color: #e8e8ec;
}

.avto-mm-viewall {
    color: #f0c850;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(240, 200, 80, 0.15);
    border-radius: 8px 8px 0 0;
}

.avto-mm-viewall:hover,
.avto-mm-viewall:active {
    color: #ffd866;
    background: rgba(240, 200, 80, 0.08);
}

/* --- Скрыть мобильное на десктопе --- */
@media (min-width: 992px) {
    .avto-mm,
    .avto-mm-overlay {
        display: none !important;
    }
}

/* --- Планшетный лейаут --- */
@media (min-width: 768px) and (max-width: 991px) {
    .avto-mm {
        height: 80vh;
        max-height: 80vh;
    }

    .avto-mm-categories {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 16px;
        padding: 0 20px;
    }

    .avto-mm-cat {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .avto-mm-subcats {
        padding-left: 42px;
    }
}

/* --- Мобильные тонкости --- */
@media (max-width: 767px) {
    .avto-mm-header {
        padding: 14px 16px 10px;
    }

    .avto-mm-title {
        font-size: 16px;
    }

    .avto-mm-cat-row {
        padding: 12px 6px;
        min-height: 48px;
        gap: 10px;
    }

    .avto-mm-cat-name {
        font-size: 14px;
    }

    .avto-mm-icon {
        width: 30px;
        height: 30px;
        padding: 6px;
    }

    .avto-mm-subcats {
        padding-left: 38px;
    }

    .avto-mm-subcat {
        padding: 7px 10px;
        font-size: 13px;
    }
}

/* ====================================================================
   ДЕСКТОПНОЕ МЕНЮ (bottom-sheet на всю ширину, >= 992px)
   ==================================================================== */

/* --- Скрыть на мобильных --- */
@media (max-width: 991px) {
    .avto-mm-desktop,
    .avto-mm-desktop-overlay {
        display: none !important;
    }
}

/* --- Оверлей десктоп (только затемнение, без blur) --- */
.avto-mm-desktop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.avto-mm-desktop-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Контейнер десктопного bottom-sheet --- */
.avto-mm-desktop {
    position: fixed;
    bottom: 0;
    left: 50%;
    width: 1470px;
    max-width: 100%;
    /* Высота: от низа экрана до main-nav, задаётся JS через --avto-mm-top */
    height: calc(100vh - var(--avto-mm-top, 120px));
    max-height: calc(100vh - var(--avto-mm-top, 120px));
    z-index: 99999;
    background: #12131a;
    border-radius: 20px 20px 0 0;
    transform: translateX(-50%) translateY(100%);
    transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
}

.avto-mm-desktop.is-open {
    transform: translateX(-50%) translateY(0);
}

/* --- Шапка десктоп --- */
.avto-mm-desktop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    position: relative;
    background: #111927;
}

.avto-mm-desktop-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.avto-mm-desktop-header .avto-mm-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.avto-mm-desktop-header .avto-mm-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.avto-mm-desktop-header .avto-mm-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Inner flex (две колонки) --- */
.avto-mm-desktop-inner {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Левая колонка --- */
.avto-mm-desktop-left {
    width: 350px;
    min-width: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: #111927;
}

/* --- Элемент категории (левая) --- */
.avto-mm-dcat {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 4px 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
    border: 1px solid transparent;
    border-radius: 12px;
}

.avto-mm-dcat:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.avto-mm-dcat.is-active {
    background: linear-gradient(90deg, rgba(240, 200, 80, 0.18) 0%, rgba(240, 200, 80, 0.08) 100%);
    border-color: rgba(240, 200, 80, 0.45);
}

.avto-mm-dcat-icon {
    width: 34px;
    height: 34px;
    padding: 7px;
    border-radius: 50%;
    background: var(--avto-mm-icon-bg);
    box-sizing: border-box;
    flex-shrink: 0;
    opacity: 1;
}

.avto-mm-dcat-name {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: #c8c8ce;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    transition: color 0.15s;
}

.avto-mm-dcat.is-active .avto-mm-dcat-name {
    color: #fff;
}

.avto-mm-dcat-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.25);
    transition: color 0.15s;
}

.avto-mm-dcat.is-active .avto-mm-dcat-arrow {
    transform: translateX(1px);
}

.avto-mm-dcat.is-active .avto-mm-dcat-arrow {
    color: #f0c850;
}

/* --- Правая колонка --- */
.avto-mm-desktop-right {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 22px 28px;
    position: relative;
    background: #111927;
}

/* --- Панель подкатегорий --- */
.avto-mm-dsub-panel {
    display: none;
}

.avto-mm-dsub-panel.is-active {
    display: block;
}

/* Заголовок */
.avto-mm-dsub-title {
    margin: 0 0 20px;
    font-weight: 700;
}

.avto-mm-dsub-title a {
    color: #fff;
    text-decoration: none;
    transition: color 0.15s;
}

/* Метка секции */
.avto-mm-dsub-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    margin: 10px 0 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.avto-mm-dsub-section-label:first-of-type {
    margin-top: 0;
}

/* Подкатегории (grid) */
.avto-mm-dsub-children {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2px 10px;
}

.avto-mm-dsub-child {
    display: block;
    padding: 5px 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    line-height: 1.3;
}

.avto-mm-dsub-child-count {
    color: #9da4ae;
    font-size: 12px;
    margin-left: 4px;
}

.avto-mm-dsub-child:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* Детали pa_part (три колонки) */
.avto-mm-dsub-parts {
    column-count: 3;
    column-gap: 12px;
    padding: 15px;
    background: #0b1019;
    border-radius: 20px;
}

.avto-mm-dsub-part {
    display: inline-flex;
    align-items: center;
    width: 100%;
    padding: 6px 4px;
    margin: 0 0 2px;
    font-size: 14px;
    color: #a3892c !important;
    text-decoration: none;
    white-space: normal;
    break-inside: avoid;
    transition: color 0.15s;
    line-height: 20px;
    border-bottom: 1px dashed #a3892c;
    
}

.avto-mm-dsub-part:hover {
    color: #ffdd00 !important;
}

.avto-mm-dsub-part .fas {
    color: #44442e;
    margin-right: 6px;
    font-size: 16px;
}

@media (max-width: 1260px) {
    .avto-mm-dsub-parts {
        column-count: 2;
    }
}

/* Пустая категория */
.avto-mm-dsub-empty {
    margin: 20px 0;
}

.avto-mm-dsub-empty a {
    color: #f0c850;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

.avto-mm-dsub-empty a:hover {
    color: #ffd866;
}
