/**
 * Стили для AJAX поиска товаров
 */

/* Обертка формы поиска */
.search-section__search-wrapper,
.footer-btn__search {
    position: relative;
}

/* Контейнер результатов */
.ajax-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Footer поиск - результаты вверх */
.footer-btn__search .ajax-search-results {
    top: auto;
    bottom: calc(100% + 8px);
}

.ajax-search-results.active {
    max-height: 600px;
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
}

/* Заголовок результатов */
.ajax-search-results__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #E0E0E0;
    font-weight: 600;
    font-size: 14px;
    color: #424242;
}

.ajax-search-results__close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #757575;
    transition: color 0.2s;
}

.ajax-search-results__close:hover {
    color: #424242;
}

/* Список товаров */
.search-results__list {
    padding: 8px 0;
}

.ajax-search-results__item {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s;
}

.ajax-search-results__item:hover {
    background-color: #F5F5F5;
}

.ajax-search-results__item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    background: #F5F5F5;
}

.ajax-search-results__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ajax-search-results__item-info {
    flex: 1;
    min-width: 0;
}

.ajax-search-results__item-title {
    font-weight: 500;
    font-size: 14px;
    color: #212121;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ajax-search-results__item-brand {
    font-size: 12px;
    color: #757575;
    margin-bottom: 2px;
}

.ajax-search-results__item-sku {
    font-size: 11px;
    color: #9E9E9E;
    margin-bottom: 6px;
}

.ajax-search-results__item-match {
    font-size: 12px;
    color: #616161;
    margin-bottom: 6px;
    line-height: 1.4;
}

.ajax-search-results__item-match mark {
    background: #FFF59D;
    color: inherit;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 500;
}

.ajax-search-results__item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ajax-search-results__item-price {
    font-weight: 600;
    font-size: 16px;
    color: #212121;
}

.ajax-search-results__item-stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.ajax-search-results__item-stock.in-stock {
    background: #E8F5E9;
    color: #2E7D32;
}

.ajax-search-results__item-stock.out-of-stock {
    background: #FFEBEE;
    color: #C62828;
}

/* Футер с кнопкой "Показать все" */
.ajax-search-results__footer {
    padding: 12px 20px;
    border-top: 1px solid #E0E0E0;
}

/* Блок "Другие варианты" */
.ajax-search-results__other-suggestions {
    padding: 12px 20px;
    background: #F9F9F9;
    border-top: 1px solid #E0E0E0;
}

.ajax-search-results__other-title {
    font-size: 12px;
    font-weight: 600;
    color: #757575;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.ajax-search-results__other-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ajax-search-results__other-item {
    padding: 4px 12px;
    background: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 16px;
    font-size: 13px;
    color: #616161;
    cursor: pointer;
    transition: all 0.2s;
}

.ajax-search-results__other-item:hover {
    background: #E3F2FD;
    border-color: #2196F3;
    color: #1976D2;
}

/* Футер с кнопкой "Показать все" */
.search-results__footer {
    padding: 12px 20px;
    border-top: 1px solid #E0E0E0;
}

.ajax-search-results__all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #F5F5F5;
    border-radius: 6px;
    text-decoration: none;
    color: #424242;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s;
}

.ajax-search-results__all:hover {
    background: #EEEEEE;
}

.ajax-search-results__all svg {
    width: 16px;
    height: 16px;
}

/* Подсказки (нечеткий поиск) */
.search-results__suggestions {
    padding: 20px;
}

.search-results__suggestions-title {
    font-weight: 600;
    font-size: 14px;
    color: #424242;
    margin-bottom: 12px;
}

.search-results__suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.search-results__suggestion {
    padding: 8px 16px;
    background: #F5F5F5;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    font-size: 14px;
    color: #424242;
    cursor: pointer;
    transition: all 0.2s;
}

.search-results__suggestion:hover {
    background: #EEEEEE;
    border-color: #BDBDBD;
}

/* Пустой результат */
.search-results__empty {
    padding: 40px 20px;
    text-align: center;
}

.search-results__empty svg {
    margin-bottom: 16px;
    margin-inline: auto;
}

.search-results__empty p {
    font-weight: 600;
    font-size: 16px;
    color: #424242;
    margin-bottom: 4px;
}

.search-results__empty span {
    font-size: 14px;
    color: #757575;
}

/* Ошибка */
.search-results__error {
    padding: 20px;
    text-align: center;
    color: #C62828;
}

/* Лоадер */
.search-results__loader {
    padding: 40px 20px;
    text-align: center;
}

.search-results__loader .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #F5F5F5;
    border-top-color: #424242;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-results__loader p {
    font-size: 14px;
    color: #757575;
}

/* Подсветка найденного текста */
.ajax-search-results__item mark {
    background: #FFF59D;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* Скроллбар для результатов */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #F5F5F5;
}

.search-results::-webkit-scrollbar-thumb {
    background: #BDBDBD;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #9E9E9E;
}

/* Адаптив */
@media (max-width: 768px) {
    /* Все поиски (header и footer) - fixed внизу */
    .ajax-search-results {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        max-height: 80vh;
    }

   .footer-btn__search .ajax-search-results {
        bottom: 0;
    }
    
    .ajax-search-results.active {
        max-height: 80vh;
    }
    
    .ajax-search-results__item-image {
        width: 50px;
        height: 50px;
    }
    
    .ajax-search-results__item-title {
        font-size: 13px;
    }
    
    .ajax-search-results__item-price {
        font-size: 14px;
    }
}


/* ========== СТРАНИЦА РЕЗУЛЬТАТОВ ПОИСКА ========== */

.search-results-page .page-header {
    margin-bottom: 24px;
}

.search-results-page .page-title {
    font-size: 32px;
    font-weight: 600;
    color: #212121;
    margin-bottom: 8px;
}

.search-results-count {
    font-size: 16px;
    color: #757575;
    margin: 0;
}

/* Блок "Ничего не найдено" */
.no-results {
    padding: 60px 20px;
    text-align: center;
    background: #FAFAFA;
    border-radius: 8px;
}

.no-results svg {
    margin-bottom: 24px;
}

.no-results h2 {
    font-size: 24px;
    font-weight: 600;
    color: #424242;
    margin-bottom: 12px;
}

.no-results p {
    font-size: 16px;
    color: #757575;
    margin-bottom: 8px;
}

.no-results a {
    color: #1976D2;
    text-decoration: underline;
}

.no-results a:hover {
    color: #1565C0;
}

/* Сортировка по релевантности */
.sort-item[data-orderby="relevance"] svg {
    width: 16px;
    height: 16px;
}
