/*
 * =====================================================
 * Улучшенный поиск OpenCart 3 — с адаптивом под мобайл
 * Файл: catalog/view/theme/default/stylesheet/search-autocomplete.css
 * =====================================================
 */

/* ── DESKTOP: Обёртка поля поиска ─────────────────── */
.search-autocomplete-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* ── DESKTOP: Выпадающий список ───────────────────── */
.search-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 440px;
    overflow-y: auto;
    display: none;
}

.search-autocomplete-list.active {
    display: block;
}

/* ── Элемент списка ───────────────────────────────── */
.search-autocomplete-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    text-decoration: none !important;
    transition: background 0.15s ease;
    gap: 12px;
}

.search-autocomplete-item:last-child {
    border-bottom: none;
}

.search-autocomplete-item:hover,
.search-autocomplete-item.highlighted {
    background: #f4f7ff;
    text-decoration: none !important;
}

/* Картинка товара */
.search-autocomplete-item__img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #ebebeb;
    flex-shrink: 0;
    background: #fafafa;
}

/* Текстовая часть */
.search-autocomplete-item__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Название товара */
.search-autocomplete-item__name {
    font-size: 14px;
    color: #2c2c2c;
    line-height: 1.4;
    font-weight: 500;
    word-break: break-word;
}

/* Подсветка совпадающего текста */
.search-autocomplete-item__name mark {
    background: transparent;
    color: inherit;
    font-weight: 700;
    padding: 0;
}

/* Цена — синий бейдж */
.search-autocomplete-item__price {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    background: #3b5fe2;
    padding: 2px 8px;
    border-radius: 4px;
    align-self: flex-start;
    white-space: nowrap;
}

/* Ссылка «Всі результати» */
.search-autocomplete-all {
    display: block;
    padding: 10px 14px;
    text-align: center;
    font-size: 13px;
    color: #3b5fe2;
    font-weight: 600;
    border-top: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none !important;
}

.search-autocomplete-all:hover {
    background: #f0f4ff;
    color: #2a4acc;
}

/* Лоадер */
.search-autocomplete-loading {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* Скроллбар */
.search-autocomplete-list::-webkit-scrollbar { width: 5px; }
.search-autocomplete-list::-webkit-scrollbar-track { background: #f5f5f5; }
.search-autocomplete-list::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }


/* ══════════════════════════════════════════════════════
   МОБАЙЛ: Полноэкранный модал поиска (≤ 768px)
   ══════════════════════════════════════════════════════ */

/* Оверлей на весь экран */
.search-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;                /* top/right/bottom/left = 0 */
    z-index: 99999;
    background: #ffffff;
    flex-direction: column;
    overflow: hidden;
}

.search-mobile-overlay.active {
    display: flex;
}

/* Шапка модала: поле + крестик */
.search-mobile-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e8e8e8;
    gap: 10px;
    flex-shrink: 0;
    background: #fff;
}

.search-mobile-header__title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    flex: 1;
    margin: 0;
}

/* Поле ввода внутри модала */
.search-mobile-input-wrap {
    display: flex;
    flex: 1;
    position: relative;
}

.search-mobile-input {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 14px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    color: #1a1a1a;
    background: #f7f8fa;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.search-mobile-input:focus {
    border-color: #3b5fe2;
    background: #fff;
}

/* Иконка лоадера/поиска внутри поля */
.search-mobile-input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    color: #999;
}

/* Кнопка закрыть (×) */
.search-mobile-close {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    padding: 0;
    color: #555;
    font-size: 24px;
    line-height: 1;
    transition: background 0.15s;
}

.search-mobile-close:hover {
    background: #f0f0f0;
}

/* Прокручиваемые результаты */
.search-mobile-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Элемент списка в мобайл-модале */
.search-mobile-results .search-autocomplete-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.search-mobile-results .search-autocomplete-item__img {
    width: 46px;
    height: 46px;
}

.search-mobile-results .search-autocomplete-item__name {
    font-size: 14px;
    line-height: 1.35;
    white-space: normal;
}

.search-mobile-results .search-autocomplete-item__price {
    font-size: 13px;
}

/* «Всі результати» в мобайле */
.search-mobile-results .search-autocomplete-all {
    padding: 14px 16px;
    font-size: 14px;
}

/* Скроллбар мобайл */
.search-mobile-results::-webkit-scrollbar { width: 4px; }
.search-mobile-results::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 2px; }

/* Спиннер */
@keyframes sa-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}
.search-mobile-input-icon.spinning {
    animation: sa-spin 0.7s linear infinite;
}

/* ── Скрываем кнопку-триггер поиска на десктопе ───── */
/* (триггер добавляется JS только на мобайле) */
.search-mobile-trigger {
    display: none;
}

@media (max-width: 768px) {
    /* Скрываем оригинальный инпут поиска на мобайле */
    /* Если у вас поисковая форма обёрнута в .search-autocomplete-wrapper */
    /* Раскомментируйте следующую строку ТОЛЬКО если нужно скрыть оригинальный поиск */
    /* .search-autocomplete-wrapper { display: none; } */

    /* Показываем мобильный триггер */
    .search-mobile-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* На мобайле десктопный дропдаун не нужен */
    .search-autocomplete-list {
        display: none !important;
    }
}
