/* search.css — движковые стили живого поиска. Базовый вид; тема может
   переопределить любой блок у себя (селекторы .cxs*).
   Мобильное первично: на телефоне колонки идут одна под другой, на широком
   экране раскладываются в три столбика, как в привычных больших магазинах. */

.cxs {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 70vh;
    overflow-y: auto;
    /* Вбок выпадашка не ездит никогда: длинные названия и цены переносятся */
    overflow-x: hidden;
    padding: 0.5rem;
    font-size: 0.92rem;
    color: var(--ink, #374151);
    background: var(--card, #fff);
    -webkit-overflow-scrolling: touch;
}

.cxs--empty {
    padding: 1rem;
    color: var(--muted, #9ca3af);
    text-align: center;
}

.cxs-corrected {
    padding: 0.35rem 0.6rem;
    color: var(--muted, #9ca3af);
    font-size: 0.85rem;
}

.cxs-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.25rem 0;
}

.cxs-col + .cxs-col {
    border-top: 1px solid var(--line, #e5e7eb);
}

.cxs-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.6rem 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted, #9ca3af);
}

.cxs-clear {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted, #9ca3af);
    cursor: pointer;
}

.cxs-clear:hover {
    color: var(--ink, #374151);
}

/* Запросы-подсказки */
.cxs-q {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 0;
    border-radius: var(--radius, 12px);
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.cxs-q b {
    font-weight: 700;
}

.cxs-q__text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Кружок-лупа перед запросом: рисуем стилями, чтобы не тащить иконочный
   шрифт темы — его в новой теме может не оказаться. */
.cxs-q__icon {
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    opacity: 0.45;
}

.cxs-q__icon::after {
    content: '';
    display: block;
    width: 0.45rem;
    height: 1.5px;
    margin: 0.75rem 0 0 0.55rem;
    background: currentColor;
    transform: rotate(45deg);
}

/* Стрелка «подставить запрос в строку» */
.cxs-q__fill {
    flex: 0 0 auto;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    opacity: 0.5;
    background:
        linear-gradient(currentColor, currentColor) center/0.7rem 1.5px no-repeat,
        linear-gradient(currentColor, currentColor) center/1.5px 0.7rem no-repeat;
    transform: rotate(-45deg);
}

.cxs-q__fill:hover {
    opacity: 1;
}

.cxs-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius, 12px);
    color: inherit;
    text-decoration: none;
}

.cxs-brand__go {
    width: 0.5rem;
    height: 0.5rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    opacity: 0.5;
    transform: rotate(-45deg);
}

/* Разделы со счётчиками */
.cxs-cat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius, 12px);
    color: inherit;
    text-decoration: none;
}

.cxs-cat span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cxs-cat b {
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--muted, #9ca3af);
}

.cxs-cat.is-matched span {
    font-weight: 600;
}

.cxs-cat--all {
    font-weight: 600;
}

/* Товары группами */
.cxs-group {
    display: block;
    padding: 0.7rem 0.6rem 0.35rem;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
}

.cxs-p {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius, 12px);
    color: inherit;
    text-decoration: none;
}

.cxs-p__img {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    overflow: hidden;
    border-radius: calc(var(--radius, 12px) / 2);
    background: var(--surface, #f8fafc);
}

.cxs-p__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cxs-p__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cxs-p__name {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    font-size: 0.9rem;
    line-height: 1.25;
}

.cxs-p__prices {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.45rem;
}

.cxs-p__old {
    color: var(--muted, #9ca3af);
    font-size: 0.85rem;
}

.cxs-p__price {
    font-weight: 700;
}

.cxs-more {
    display: block;
    margin: 0.4rem 0.6rem 0.6rem;
    padding: 0.6rem;
    border-radius: var(--radius, 12px);
    background: var(--dark, #1e293b);
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
}

.cxs a:hover,
.cxs button.cxs-q:hover,
.cxs a:focus-visible {
    background: var(--surface, #f8fafc);
    outline: none;
}

.cxs-more:hover {
    opacity: 0.9;
    background: var(--dark, #1e293b);
}

/* Широкий экран: столбики рядом, как в больших магазинах. Именно flex, а не
   сетка: если подсказок запросов нет, столбик не оставляет пустое место —
   остальные разъезжаются на всю ширину. */
@media (min-width: 900px) {
    .cxs {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0 1.25rem;
        align-items: flex-start;
        padding: 0.75rem;
    }

    .cxs--empty {
        display: block;
    }

    .cxs-corrected {
        flex: 1 1 100%;
    }

    .cxs-col {
        flex: 1 1 0;
    }

    .cxs-col--products {
        flex: 1.6 1 0;
        max-height: 60vh;
        overflow-y: auto;
    }

    .cxs-col + .cxs-col {
        border-top: 0;
    }
}
