/* ── Two-column search layout ────────────────────────────────────── */

.search-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}

/* ── Left sidebar ────────────────────────────────────────────────── */

.filter-sidebar {
    flex: 0 0 210px;
    position: sticky;
    top: 1rem;
}

.filter-toggle-btn {
    display: none;
}

.sidebar-heading {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.filter-sidebar form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.filter-group:last-of-type {
    border-bottom: none;
}

.filter-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Fixed-height filter bar control — shape and chevron come from the
   global `select` rule in style.css */
.filter-select {
    width: 100%;
    height: 36px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 0.875rem;
}

.filter-select:focus {
    outline: none;
    border-color: #111;
}

.price-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-input {
    width: 72px;
    height: 34px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: #111;
    flex: 1;
    min-width: 0;
}

.filter-input:focus {
    outline: none;
    border-color: #111;
}

.price-dash {
    color: #9ca3af;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.price-apply {
    width: 100%;
    height: 34px;
    margin-top: 0.4rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.price-apply:hover {
    background: var(--primary-hover);
}

.filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-soft);
    cursor: pointer;
    line-height: 1.3;
}

.filter-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #111;
}

.filter-clear {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.filter-clear:hover {
    color: #111;
}

/* ── Right results column ─────────────────────────────────────────── */

.search-results {
    flex: 1;
    min-width: 0;
}

/* ── Toolbar ─────────────────────────────────────────────────────── */

.browse-toolbar {
    margin: 0 1.5rem 1rem;
}

.search-layout .browse-toolbar {
    margin: 0 0 1rem;
}

.browse-count {
    font-size: 0.9rem;
    font-weight: 400;   /* it is an <h1> now — cancel the browser's bold */
    color: #555;
}

.browse-count em {
    font-style: normal;
    font-weight: 600;
    color: #111;
}

/* ── Product grid ─────────────────────────────────────────────────── */

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.search-layout .product-grid {
    padding: 0;
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .product-grid                  { grid-template-columns: repeat(3, 1fr); }
    .search-layout .product-grid   { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .product-grid                  { grid-template-columns: repeat(2, 1fr); }
    .search-layout .product-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
    .product-grid                  { grid-template-columns: 1fr; }
    .search-layout .product-grid   { grid-template-columns: 1fr; }
}

/* ── Product card ────────────────────────────────────────────────── */

.product-card {
    text-decoration: none;
    color: inherit;
    display: block;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.product-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.card-photo {
    width: 100%;
    height: auto; /* beats the img height="400" attribute so aspect-ratio applies */
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.card-photo--empty {
    background: #efefef;
    aspect-ratio: 1;
}

.card-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.card-name {
    font-size: 0.9rem;
    color: #111;
    line-height: 1.35;
}

.card-price {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    margin-top: 0.15rem;
}

.card-seller {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.card-desc {
    font-size: 0.82rem;
    color: #666;
    margin-top: 0.3rem;
    line-height: 1.4;
}

.card-rating {
    font-size: 0.78rem;
    color: #f59e0b;
}

/* ── Filter chips ────────────────────────────────────────────────── */

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    background: #f3f4f6;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    color: var(--text-soft);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
}

.filter-chip:hover {
    background: var(--border);
    border-color: var(--border-strong);
    color: #111;
}

.chip-x {
    font-size: 1rem;
    color: #9ca3af;
    line-height: 1;
}

.filter-chip:hover .chip-x {
    color: var(--text-soft);
}

/* ── Shops strip ─────────────────────────────────────────────────────
   Shops whose vendor-chosen categories match the query or the category
   filter — one horizontally scrollable row above the product grid. */
.shops-strip {
    margin-bottom: 1.25rem;
}

.shops-strip-title {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-soft);
}

.shops-strip-row {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.shop-card {
    flex: 0 0 150px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    text-decoration: none;
    overflow: hidden;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.shop-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.shop-card-banner {
    display: block;
    width: 100%;
    height: 64px;
    object-fit: cover;
}

.shop-card-banner--empty {
    background: #f3f4f6;
}

.shop-card-name {
    display: block;
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── No results ──────────────────────────────────────────────────── */

.no-results {
    color: #888;
    padding: 2rem 0;
}

/* ── Infinite scroll ─────────────────────────────────────────────── */

#scroll-sentinel {
    height: 1px;
    margin-top: 2rem;
}

.scroll-spinner {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .search-layout {
        flex-direction: column;
        gap: 0;
    }

    .filter-sidebar {
        position: static;
        width: 100%;
        flex: none;
        margin-bottom: 1rem;
    }

    .filter-toggle-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.6rem 1rem;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-sm);
        background: #fff;
        font-size: 0.875rem;
        font-weight: 600;
        color: #111;
        cursor: pointer;
        text-align: left;
    }

    .filter-active-dot {
        display: inline-block;
        width: 7px;
        height: 7px;
        background: var(--primary);
        border-radius: 50%;
        margin-left: 2px;
        vertical-align: middle;
    }

    .sidebar-body {
        display: none;
        padding-top: 1rem;
    }

    .filter-sidebar.is-open .sidebar-body {
        display: block;
    }

    .sidebar-heading {
        display: none;
    }

    .search-results {
        width: 100%;
    }

}
