/*
 * ajax-search.css
 * Стили для выпадающего поиска товаров
 *
 * Разместить в: /wp-content/themes/ВАШ-ШАБЛОН/css/ajax-search.css
 *
 * Если используете Elementor — вставьте этот CSS в:
 * Elementor → Настройки сайта → Собственный CSS
 * или в Внешний вид → Редактор → style.css вашей дочерней темы
 */

/* ─── Обёртка ─────────────────────────────────── */
.custom-search-wrapper {
    position: relative;
    width: 100%;
}

/* ─── Инпут (подтяжка стандартного Elementor-поиска) ── */
.custom-search-wrapper .custom-search-input,
.custom-search-wrapper input[type="search"],
.custom-search-wrapper input[type="text"] {
    width: 100%;
    box-sizing: border-box;
}

/* ─── Выпадающий контейнер ───────────────────── */
.custom-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 9999;
    background: #f5f1eb;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 7px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10);
    overflow: hidden;
    max-height: 480px;
    overflow-y: auto;
    /* Плавное появление */
    animation: cs-fade-in 0.15s ease;
}
input.custom-search-input {
    background: transparent !important;
    border-radius: 7px !important;
    border: 1px solid #fff !important;
    color: #dddd !important;
    font-size: 14px !important;
    padding: 15px !important;
}
.custom-search-results.is-open {
    display: block;
}

@keyframes cs-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Строка результата ──────────────────────── */
.cs-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.cs-result-item:last-child {
    border-bottom: none;
}

.cs-result-item:hover,
.cs-result-item.is-active {
    background: #f5f5f5;
}

/* ─── Миниатюра ──────────────────────────────── */
.cs-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 7px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cs-img-placeholder {
    color: #bbb;
}

/* ─── Текстовая часть ────────────────────────── */
.cs-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cs-title {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.cs-title mark {
    background: #fff3a3;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.cs-price {
    font-size: 13px;
    color: #555;
    font-weight: 400;
}

.cs-price strong {
    color: #1a1a1a;
    font-weight: 600;
}

/* ─── Кнопка «Посмотреть» ────────────────────── */
.cs-btn {
    flex-shrink: 0;
    display: inline-block;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 7px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
    cursor: pointer;
}

.cs-btn:hover {
    background: #520707;
    border-color: #520707;
    color: #fff;
}

/* ─── «Не найдено» / ошибка ──────────────────── */
.cs-no-results {
    padding: 16px 18px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* ─── Loader ─────────────────────────────────── */
.cs-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    font-size: 14px;
    color: #888;
}

.cs-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #555;
    border-radius: 50%;
    animation: cs-spin 0.6s linear infinite;
    flex-shrink: 0;
}

@keyframes cs-spin {
    to { transform: rotate(360deg); }
}

/* ─── Скролл внутри дропдауна ────────────────── */
.custom-search-results::-webkit-scrollbar {
    width: 4px;
}
.custom-search-results::-webkit-scrollbar-track {
    background: transparent;
}
.custom-search-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* ─── Адаптив ────────────────────────────────── */
@media (max-width: 480px) {
    .cs-btn {
        display: none; /* на очень маленьких экранах убираем кнопку, клик идёт по строке */
    }

    .cs-title {
        white-space: normal;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
