/**
 * Кастомные стили для мобильного меню
 * Скрываем все элементы кроме "Мой аккаунт" и "Корзина"
 * Добавляем переключатель языков Polylang
 */

/* ============================================
   СКРЫТИЕ НЕНУЖНЫХ ЭЛЕМЕНТОВ В МОБИЛЬНОМ МЕНЮ
   ============================================ */

/* Скрываем все элементы меню на мобильных устройствах по умолчанию */
@media (max-width: 921px) {
    .ast-mobile-header-wrap .main-header-menu .menu-item {
        display: none !important;
    }
    
    /* Показываем только элементы с "аккаунт" в URL или тексте */
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="my-account"],
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="аккаунт"],
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="менің-аккаунтым"] {
        display: flex !important;
    }
    
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="my-account"]),
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="аккаунт"]),
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="менің-аккаунтым"]) {
        display: block !important;
    }
    
    /* Показываем только элементы с "корзина" в URL или тексте */
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="cart"],
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="корзин"],
    .ast-mobile-header-wrap .main-header-menu .menu-item a[href*="себет"] {
        display: flex !important;
    }
    
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="cart"]),
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="корзин"]),
    .ast-mobile-header-wrap .main-header-menu .menu-item:has(a[href*="себет"]) {
        display: block !important;
    }
    
    /* Показываем переключатель языков */
    .ast-mobile-header-wrap .main-header-menu .menu-item-language-switcher {
        display: block !important;
    }
}

/* ============================================
   СТИЛИ ДЛЯ ПЕРЕКЛЮЧАТЕЛЯ ЯЗЫКОВ
   ============================================ */

.menu-item-language-switcher {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: 0 !important;
    margin-top: 0 !important;
    list-style: none;
    background: transparent !important;
}

.polylang-mobile-switcher {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    width: 100%;
    background: transparent !important;
}

.polylang-mobile-switcher .lang-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 15px 20px;
    border: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 0 !important;
    text-decoration: none;
    color: inherit !important;
    transition: background-color 0.3s ease;
    font-size: 16px;
    font-weight: 400;
    background-color: transparent !important;
    width: 100%;
    box-sizing: border-box;
    box-shadow: none !important;
}

.polylang-mobile-switcher .lang-item:last-child {
    border-bottom: none !important;
}

.polylang-mobile-switcher .lang-item:hover {
    background-color: rgba(0, 0, 0, 0.03) !important;
}

.polylang-mobile-switcher .lang-item.active {
    background-color: transparent !important;
    font-weight: 500;
    color: inherit !important;
}

.polylang-mobile-switcher .lang-item img {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* ============================================
   СТИЛИ ДЛЯ ИКОНОК В МЕНЮ
   ============================================ */

@media (max-width: 921px) {
    .ast-mobile-header-wrap .main-header-menu .menu-item a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 16px;
        padding: 15px 20px;
        text-align: center;
    }
    
    /* Увеличиваем размер эмодзи иконок */
    .ast-mobile-header-wrap .main-header-menu .menu-item a::before {
        font-size: 20px;
    }
}

/* ============================================
   АДАПТАЦИЯ ДЛЯ ТЕМНОЙ ТЕМЫ
   ============================================ */

@media (prefers-color-scheme: dark) {
    .menu-item-language-switcher {
        border-top-color: rgba(255, 255, 255, 0.1);
    }
    
    .polylang-mobile-switcher .lang-item {
        border-bottom-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    
    .polylang-mobile-switcher .lang-item:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .polylang-mobile-switcher .lang-item.active {
        background-color: rgba(0, 115, 170, 0.2);
    }
}

/* ============================================
   СКРЫТИЕ НА ДЕСКТОПЕ
   ============================================ */

@media (min-width: 922px) {
    .menu-item-language-switcher {
        display: none !important;
    }
}

/* ============================================
   ПОИСК FIBOSEARCH В МОБИЛЬНОМ МЕНЮ
   ============================================ */

@media (max-width: 921px) {
    /* Контейнер для поиска в мобильном меню */
    .mobile-menu-search-wrapper {
        display: block !important;
        padding: 15px 20px !important;
        border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
        background: transparent !important;
        list-style: none !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Стили для формы поиска FiboSearch */
    .mobile-menu-search-wrapper .dgwt-wcas-search-wrapp {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-search-form {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-sf-wrapp {
        width: 100% !important;
        position: relative !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-search-input {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 15px !important;
        font-size: 16px !important;
        border: 1px solid rgba(0, 0, 0, 0.15) !important;
        border-radius: 4px !important;
        background: #fff !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-search-input:focus {
        outline: none !important;
        border-color: #0073aa !important;
        box-shadow: 0 0 0 1px #0073aa !important;
        text-align: left !important;
    }
    
    /* Стили для выпадающего списка результатов поиска */
    .mobile-menu-search-wrapper .dgwt-wcas-suggestions-wrapp {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        z-index: 999999 !important;
        background: #fff !important;
        border-radius: 4px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        margin-top: 5px !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion {
        padding: 12px 15px !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion:last-child {
        border-bottom: none !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion:hover,
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion.dgwt-wcas-suggestion-selected {
        background-color: rgba(0, 115, 170, 0.05) !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion-product-image {
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion-product-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 4px !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion-content {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion-title {
        font-size: 14px !important;
        font-weight: 500 !important;
        margin-bottom: 4px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .mobile-menu-search-wrapper .dgwt-wcas-suggestion-price {
        font-size: 13px !important;
        color: #0073aa !important;
        font-weight: 600 !important;
    }
    
    /* Оптимизация для производительности */
    .mobile-menu-search-wrapper .dgwt-wcas-suggestions-wrapp {
        will-change: transform !important;
        transform: translateZ(0) !important;
    }
    
    /* Прелоадер */
    .mobile-menu-search-wrapper .dgwt-wcas-preloader {
        position: absolute !important;
        right: 15px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    
    /* Иконка лупы */
    .mobile-menu-search-wrapper .dgwt-wcas-ico-magnifier,
    .mobile-menu-search-wrapper .dgwt-wcas-ico-magnifier-handler {
        display: block !important;
    }
}

/* ============================================
   ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ
   ============================================ */

/* Центрирование элементов меню */
@media (max-width: 921px) {
    .ast-mobile-header-wrap .main-header-menu {
        text-align: center;
    }
    
    .ast-mobile-header-wrap .main-header-menu .menu-item {
        width: 100%;
    }
    
    /* Добавляем отступы между элементами */
    .ast-mobile-header-wrap .main-header-menu .menu-item + .menu-item {
        margin-top: 5px;
    }
}

/* Улучшение видимости активного языка */
.polylang-mobile-switcher .lang-item.active::after {
    content: " ✓";
    margin-left: auto;
    font-size: 18px;
    color: #0073aa;
    font-weight: bold;
}

/* Анимация при открытии меню */
@media (max-width: 921px) {
    .ast-mobile-header-wrap .main-header-menu .menu-item {
        animation: fadeInUp 0.3s ease-in-out;
    }
    
    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}
