/* ==========================================================================
   1. МОБИЛЬНОЕ OFF-CANVAS МЕНЮ (ПОЛНЫЙ КОМПЛЕКС ФИКСОВ С ЖЕСТКИМ ЦЕНТРОМ СТРЕЛОК)
   ========================================================================== */
@media (max-width: 768px) {
    .offcanvas-menu .offcanvas-inner .sp-module ul > li {
        margin-bottom: 8px !important;
        position: relative !important;
        display: block !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul > li > a,
    .offcanvas-menu .offcanvas-inner .sp-module ul > li > span:not(.menu-toggler):not(.offcanvas-menu-toggler) {
        padding: 12px 50px 12px 15px !important; /* Справа 50px под стрелку */
        border-radius: 8px !important;
        line-height: 1.5 !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul ul li {
        margin-bottom: 12px !important;
        margin-top: 4px !important;
        position: relative !important;
        display: block !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul ul li a {
        padding: 12px 50px 12px 40px !important;
        font-size: 15px !important;
        border-radius: 8px !important;
        line-height: 1.5 !important;
    }
    .offcanvas-menu {
        overflow-y: auto !important;
        overscroll-behavior: contain;
    }
    .offcanvas-menu .offcanvas-inner {
        padding-top: 10px !important;
        padding-bottom: 30px !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module li a,
    .offcanvas-menu .offcanvas-inner .sp-module li span:not(.menu-toggler):not(.offcanvas-menu-toggler) {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* ФИКС СТРЕЛОК: Центрирование относительно всей высоты кнопки, а не текста */
    .offcanvas-menu .offcanvas-inner .sp-module ul li .menu-toggler {
        position: absolute !important;
        right: 5px !important;         /* Отступ от правого края плашки */
        top: 50% !important;           /* Спускаем ровно на середину кнопки */
        transform: translateY(-50%) !important; /* Ювелирный сдвиг вверх на половину своего размера */
        height: 38px !important;       /* Фиксированная высота кликабельной зоны */
        width: 44px !important;        
        display: flex !important;
        align-items: center !important;     
        justify-content: center !important;    
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        z-index: 10 !important;
        transition: transform 0.2s ease-in-out, top 0s !important;
    }
    
    /* Сохраняем поворот при раскрытии, добавляя учет центрирования */
    .offcanvas-menu .offcanvas-inner .sp-module ul li.open > .menu-toggler {
        transform: translateY(-50%) rotate(90deg) !important; 
    }

    .offcanvas-menu .offcanvas-inner .sp-module ul li .menu-toggler i,
    .offcanvas-menu .offcanvas-inner .sp-module ul li .menu-toggler span {
        display: inline-block !important;
        line-height: 1 !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul > li > a {
        background-color: #f8f9fa !important;
        color: #111111 !important;
        border: 1px solid #cccccc !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04) !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul > li.open > a {
        background-color: #222222 !important;
        color: #ffffff !important;
        border-color: #222222 !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul ul {
        background-color: #e9ecef !important;
        padding: 12px 10px !important;
        border-radius: 8px !important;
        margin-top: 8px !important;
        border: 1px solid #ced4da !important;
    }
    .offcanvas-menu .offcanvas-inner .sp-module ul ul li a {
        background-color: #ffffff !important;
        color: #212529 !important;
        border: 1px solid #adb5bd !important;
    }
}
.offcanvas-overlay {
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
}

/* ==========================================================================
   2. ОБЩИЕ ФИКСЫ ЭЛЕМЕНТОВ
   ========================================================================== */
#scroll-top, .scroll-top, .sp-scroll-up, #back-to-top {
    right: auto !important;
    left: 25px !important;
    bottom: 25px !important;
}

/* ==========================================================================
   3. ДЕСКТОПНОЕ МЕНЮ (ИЗОЛИРОВАНО ОТ РЕДАКТОРА SP PAGE BUILDER)
   ========================================================================== */
@media (min-width: 769px) {

    /* Принудительное выравнивание по левому краю ТОЛЬКО внутри шапки сайта */
    #sp-menu, 
    #sp-menu .sp-megamenu-wrapper, 
    #sp-header .sp-column, 
    #sp-header .navigation {
        display: flex !important;
        justify-content: flex-start !important; 
        align-items: center !important;
        margin-left: 0 !important;
        margin-right: auto !important;
        width: auto !important;
    }

    /* Главный список UL меню */
    .sp-megamenu-parent, 
    .navbar-nav, 
    ul.menu {
        display: flex !important;
        justify-content: flex-start !important; 
        align-items: center !important;
        margin-left: 0 !important;
        margin-right: auto !important;
        padding-left: 0 !important;
    }

    /* Контейнеры пунктов верхнего уровня (li) */
    .sp-megamenu-parent > li {
        position: relative !important;
        margin-right: 22px !important; 
        margin-left: 0 !important;
        float: none !important;
        
        /* Невидимая подушка: делает так, чтобы при ведении мышки вниз меню не закрывалось */
        padding-bottom: 20px !important; 
        margin-bottom: -20px !important;
    }

    /* Главные ссылки верхнего уровня */
    .sp-megamenu-parent > li > a, 
    .sp-megamenu-parent > li > span {
        font-size: 16px !important;    
        font-weight: 600 !important;   
        white-space: nowrap !important;
        padding: 0 !important; 
        transition: color 0.2s ease-in-out !important;
        
        /* [ЦВЕТ]: Текст на светлом фоне */
        color: #4A3A31 !important; 
    }

    /* Состояние ХОВЕР (при наведении мыши) */
    .sp-megamenu-parent > li:hover > a,
    .sp-megamenu-parent > li:hover > span {
        color: #C17B3E !important; 
    }

    /* АКТИВНЫЙ пункт */
    .sp-megamenu-parent > li.active > a,
    .sp-megamenu-parent > li.active > span {
        color: #8B4A1B !important; 
    }

    /* ЖЕСТКОЕ УДАЛЕНИЕ СТРЕЛОК ИЗ ШАБЛОНА */
    .sp-megamenu-parent > li .sp-caret,
    .sp-megamenu-parent > li > a::after,
    .sp-megamenu-parent > li > span::after,
    .sp-caret {
        display: none !important;
        content: none !important;
    }

    /* ВЫПАДАЮЩЕЕ БЛОК-ПОДМЕНЮ (ПОЛНЫЙ КОНТРОЛЬ НАД ВЫСОТОЙ И СДВИГОМ ВЛЕВО) */
    .sp-megamenu-parent .sp-dropdown,
    .sp-megamenu-parent .sp-dropdown.sp-dropdown-main,
    .sp-dropdown,
    .mega-sub-menu {
        /* Нейтрализуем top: 100%, который сбрасывал меню на дно шапки */
        top: auto !important; 
        
        /* Выставляем ручной отступ от букв */
        margin-top: 5px !important; 
        
        /* СДВИГ ВЛЕВО */
        margin-left: -15px !important; 
        
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        border-radius: 8px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
        background-color: #ffffff !important;
        padding: 15px !important;
        
        width: auto !important; 
        min-width: 260px !important;
        max-width: none !important;
        z-index: 99999 !important;
    }

    /* Внутренние ссылки выпадающего Мега-меню */
    .sp-megamenu-parent .sp-dropdown li a,
    .mega-sub-menu li a {
        font-size: 15px !important;
        font-weight: 400 !important;
        padding: 6px 10px !important;
        border-radius: 4px !important;
        display: block !important;
        transition: all 0.15s ease !important;
        color: #4A3A31 !important; 
    }

    /* Наведение на пункт внутри выпадающего подменю */
    .sp-megamenu-parent .sp-dropdown li a:hover,
    .mega-sub-menu li a:hover {
        background-color: #f8f6f4 !important; 
        padding-left: 14px !important;         
        color: #C17B3E !important; 
    }
}

/* ==========================================================================
   2. СЕТКА ОТЗЫВОВ
   ========================================================================== */

/* Контейнер сетки отзывов */
.yandex-static-reviews {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 24px !important;
    padding: 10px 0 !important;
}

/* Сетка для планшетов */
@media (max-width: 991.98px) {
    .yandex-static-reviews {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Сетка для мобильных */
@media (max-width: 767.98px) {
    .yandex-static-reviews {
        grid-template-columns: 1fr !important;
    }
}

/* Карточка отзыва */
.ya-review-card {
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 20px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    border: 1px solid #f0f0f0 !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    box-sizing: border-box !important;
}

.ya-review-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08) !important;
}


/* ==========================================================================
   3. ЖЕСТКИЙ ФИКС ШАПКИ КАРТОЧКИ (АВАТАРКИ ЛЮДЕЙ)
   ========================================================================== */

/* Контейнер шапки отзыва */
.ya-review-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important; /* Строго влево */
    width: 100% !important;
    margin-bottom: 14px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Круглые аватарки-картинки пользователей */
.ya-review-header img.ya-avatar-img {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    margin: 0 12px 0 0 !important; /* Отступ только справа */
    padding: 0 !important;
    flex-shrink: 0 !important; /* Запрет сжатия */
    flex-grow: 0 !important;
    display: block !important;
}

/* Круглые аватарки-заглушки с буквами (для 2GIS) */
.ya-review-header .ya-avatar-initials {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    margin: 0 12px 0 0 !important; /* Отступ только справа */
    padding: 0 !important;
    flex-shrink: 0 !important; /* Запрет сжатия */
    flex-grow: 0 !important;
    box-sizing: border-box !important;
}

/* Контейнер с именем и звездами (справа от аватарки) */
.ya-review-header .ya-user-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    flex-grow: 1 !important; 
    flex-shrink: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
}

/* Имя пользователя */
.ya-user-name {
    font-weight: 600 !important;
    font-size: 15px !important;
    color: #222222 !important;
    margin: 0 0 2px 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    text-align: left !important;
}

/* Контейнер для звезд и даты */
.ya-meta {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Звезды */
.ya-stars {
    color: #ffc107 !important;
    font-size: 14px !important;
    letter-spacing: 1px !important;
    line-height: 1 !important;
    display: inline-block !important;
}

/* Дата */
.ya-date {
    font-size: 12px !important;
    color: #999999 !important;
    line-height: 1 !important;
    display: inline-block !important;
}


/* ==========================================================================
   4. ТЕКСТ ОТЗЫВА
   ========================================================================== */

.ya-review-text {
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: #444 !important;
    margin-bottom: 16px !important;
    flex-grow: 1 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 5 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-align: left !important;
}


/* ==========================================================================
   5. ПОДВАЛ КАРТОЧКИ (ФИКС ССЫЛКИ И ИКОНКИ КАРТ)
   ========================================================================== */

/* Контейнер источника внизу карточки */
.ya-review-source {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important; /* Текст уходит влево, иконка вправо */
    border-top: 1px solid #f5f5f5 !important;
    padding-top: 12px !important;
    margin-top: auto !important; /* Прижимает строго к низу */
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Стиль для текста ссылки */
.ya-review-link {
    font-size: 13px !important;
    color: #0066ff !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    transition: color 0.2s ease !important;
    text-align: left !important;
    display: inline-block !important;
}

.ya-review-link:hover {
    color: #0044cc !important;
    text-decoration: underline !important;
}

/* Маленькая иконка Яндекса/2Гис строго в подвале карточки */
.ya-review-source img {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    margin: 0 0 0 10px !important; /* Отступ слева от ссылки */
    padding: 0 !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
    display: block !important;
    border-radius: 0 !important; /* Защита от скруглений */
}


/* ==========================================================================
   6. БЛОК ПЕРЕКЛЮЧЕНИЯ ВКЛАДОК (КНОПКИ ФИЛЬТРОВ)
   ========================================================================== */

/* Контейнер вкладок */
.ya-custom-tabs {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Кнопки-вкладки */
.ya-custom-tabs .sw-review-box-tab {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    color: #333333 !important;
    border: 1px solid #e4e4e4 !important;
    padding: 0 16px !important; 
    height: 44px !important;
    width: auto !important;
    max-width: max-content !important;
    border-radius: 100px !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
}

.ya-custom-tabs .sw-review-box-tab:hover {
    background: #f8f9fa !important;
    border-color: #b5b5b5 !important;
}

.ya-custom-tabs .sw-review-box-tab.active {
    background: #f1f3f5 !important;
    color: #000000 !important;
    border: 2px solid #333333 !important;
    font-weight: 600 !important;
}

.ya-custom-tabs .sw-review-box-tab-name {
    display: inline !important;
    font-size: 14px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.ya-custom-tabs .sw-review-box-tab-rating {
    display: inline !important;
    font-weight: 700 !important;
    margin-left: 5px !important;
    opacity: 0.8 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    font-size: 14px !important;
}

.ya-custom-tabs .sw-review-box-tab.active .sw-review-box-tab-rating {
    color: #ff9800 !important;
    opacity: 1 !important;
}

/* Логотипы внутри самих кнопок переключения (Яндекс/2гис) */
.ya-custom-tabs .sw-review-box-tab img.sw-review-box-tab-logo {
    display: inline-block !important;
    vertical-align: middle !important;
    width: 24px !important; /* Возвращен корректный компактный размер вместо 75px */
    height: 75px !important;
    min-width: 75px !important;
    min-height: 75px !important;
    max-width: 75px !important;
    max-height: 75px !important;
    object-fit: contain !important; 
    aspect-ratio: 1 / 1 !important;
    margin: 0 6px 0 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;    
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: none !important; 
}

/* Прячем иконку во вкладке "Все отзывы" */
.ya-custom-tabs .sw-review-box-tab[data-type=""] img.sw-review-box-tab-logo,
.ya-custom-tabs .sw-review-box-tab[data-type="all"] img.sw-review-box-tab-logo {
    display: none !important;
}


/* ==========================================================================
   7. ЛОГИКА ФИЛЬТРАЦИИ И СКРЫТИЯ КАРТОЧЕК
   ========================================================================== */

/* Если выбрана вкладка Яндекс, принудительно скрываем 2gis и показываем yandex */
body:has(.ya-custom-tabs .sw-review-box-tab[data-type="review_yandex_map"].active) .ya-review-card.filter-2gis {
    display: none !important;
}
body:has(.ya-custom-tabs .sw-review-box-tab[data-type="review_yandex_map"].active) .ya-review-card.filter-yandex {
    display: flex !important;
}

/* Если выбрана вкладка 2GIS, принудительно скрываем yandex и показываем 2gis */
body:has(.ya-custom-tabs .sw-review-box-tab[data-type="review_2gis"].active) .ya-review-card.filter-yandex {
    display: none !important;
}
body:has(.ya-custom-tabs .sw-review-box-tab[data-type="review_2gis"].active) .ya-review-card.filter-2gis {
    display: flex !important;
}

/* Если выбрана вкладка "Все отзывы", показываем абсолютно все карточки */
body:has(.ya-custom-tabs .sw-review-box-tab[data-type=""].active) .ya-review-card {
    display: flex !important;
}

/* ============================================================
       ОСНОВНОЙ БЛОК СЛОВАРЯ
       ============================================================ */
    .glossary-module {
        font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
        max-width: 100%;
        margin: 0 auto;
        padding: 24px 20px;
        background: #f8f9fa;            /* ваш цвет фона */
        border-radius: 16px;             /* как у карточек отзывов */
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
        border: 1px solid #f0f0f0;
        transition: box-shadow 0.2s ease;
    }
    .glossary-module:hover {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    }

    /* Заголовок */
    .glossary-module .glossary-title {
        font-size: 24px;
        font-weight: 600;
        color: #4A3A31;                /* основной цвет текста */
        text-align: center;
        letter-spacing: -0.3px;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 2px solid #e4e4e4; /* как границы вкладок */
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }
    .glossary-module .glossary-title span {
        background: #C17B3E;            /* акцентный цвет */
        color: #ffffff;
        font-size: 18px;
        border-radius: 100px;            /* как вкладки */
        padding: 0 18px;
        line-height: 36px;
        font-weight: 500;
    }

    /* ============================================================
       АЛФАВИТНАЯ НАВИГАЦИЯ (стилизована под ваши табы)
       ============================================================ */
    .glossary-alphabet {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px 8px;
        margin-bottom: 28px;
        padding: 0 4px;
    }
    .glossary-alphabet a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        font-weight: 500;
        color: #4A3A31;                /* основной цвет */
        text-decoration: none;
        padding: 0 6px;
        height: 36px;
        min-width: 32px;
        border-radius: 100px;           /* как вкладки */
        border: 1px solid transparent;
        transition: all 0.2s ease;
        background: transparent;
        line-height: 1;
    }
    .glossary-alphabet a:hover {
        background: #C17B3E;            /* акцент при ховере */
        color: #ffffff;
        border-color: #C17B3E;
        text-decoration: none;
    }
    .glossary-alphabet a.active {
        background: #4A3A31;            /* активный — тёмный, как в меню */
        color: #ffffff;
        border-color: #4A3A31;
        pointer-events: none;
    }

    /* ============================================================
       ГРУППЫ ТЕРМИНОВ ПО БУКВАМ
       ============================================================ */
    .glossary-letter-group {
        margin-bottom: 28px;
        padding: 0 4px;
    }
    .glossary-letter-group .letter-header {
        font-size: 28px;
        font-weight: 700;
        color: #4A3A31;
        border-bottom: 3px solid #C17B3E;
        padding-bottom: 6px;
        margin-bottom: 14px;
        letter-spacing: 0.5px;
        display: inline-block;
    }

    /* Список терминов — сетка, как у отзывов, но адаптивная */
    .glossary-list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 6px 20px;
    }
    .glossary-list li {
        margin: 0;
        padding: 4px 0;
        border-bottom: 1px dashed #eaeaea;
    }
    .glossary-list li a {
        font-size: 16px;
        color: #4A3A31;
        text-decoration: none;
        font-weight: 450;
        display: inline-block;
        transition: all 0.2s ease;
        position: relative;
        padding-left: 0;
    }
    .glossary-list li a::before {
        content: "→";
        color: #C17B3E;
        font-weight: 300;
        margin-right: 8px;
        opacity: 0.6;
        transition: opacity 0.2s;
    }
    .glossary-list li a:hover {
        color: #C17B3E;                /* как в меню при ховере */
        padding-left: 6px;             /* сдвиг, как в выпадающем меню */
        text-decoration: none;
    }
    .glossary-list li a:hover::before {
        opacity: 1;
    }

    /* Дополнительная линия под ссылкой (как в меню) – опционально */
    .glossary-list li a::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 0;
        width: 0;
        height: 2px;
        background: #C17B3E;
        transition: width 0.3s ease;
    }
    .glossary-list li a:hover::after {
        width: 100%;
    }

    /* ============================================================
       АДАПТИВНОСТЬ (как в ваших медиа-запросах)
       ============================================================ */
    @media (max-width: 768px) {
        .glossary-module {
            padding: 16px 12px;
            border-radius: 12px;
        }
        .glossary-list {
            grid-template-columns: 1fr;  /* на мобильных одна колонка */
        }
        .glossary-alphabet a {
            font-size: 14px;
            height: 32px;
            min-width: 28px;
            padding: 0 4px;
        }
        .glossary-letter-group .letter-header {
            font-size: 24px;
        }
        .glossary-module .glossary-title {
            font-size: 20px;
        }
        .glossary-module .glossary-title span {
            font-size: 16px;
            line-height: 32px;
            padding: 0 14px;
        }
    }
    @media (max-width: 480px) {
        .glossary-alphabet {
            gap: 4px 6px;
        }
        .glossary-alphabet a {
            font-size: 13px;
            height: 28px;
            min-width: 24px;
        }
    }