/**
 * TactiShop Algolia Search v0.3.1
 *
 * Cambios:
 *  - Marcas/Categorías como chips horizontales
 *  - Search input al 60% del contenedor en desktop
 *  - Oculta dropdowns nativos de Woodmart
 *  - Footer "Ver todos los resultados (N)" en una sola línea
 */

/* ---------- Search input narrower (desktop only) ---------------------- */
/* Woodmart estira la caja al 100% del wrapper. La acotamos al 60%. */

@media (min-width: 1025px) {
    .whb-main-header .whb-col-center .wd-header-search,
    .whb-main-header .whb-col-center .wd-header-search-form,
    .whb-main-header .wd-header-search,
    .whb-main-header .wd-header-search-form,
    .whb-main-header form.searchform.wd-header-search-form {
        max-width: 60%;
        width: 60%;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ---------- Hide ALL native Woodmart search dropdowns ----------------- */
/* Mata cualquier resultado de Woodmart en headerwide y mobile drawer.
   Si un día agregan otra clase, se agrega aquí. */

.wd-search-results,
.wd-dropdown-results-search,
.wd-header-search-results,
.searchform-results,
.search-results-popup,
form.searchform > .wd-dropdown-results,
.wd-search-full-screen .wd-dropdown-results-search,
.wd-search-full-screen .wd-search-results {
    display: none !important;
}

/* ---------- Panel ----------------------------------------------------- */

.ts-algolia-panel {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.10);
    z-index: 99999;
    max-height: 80vh;
    overflow-y: auto;
    font-size: 14px;
    color: #222;
    -webkit-overflow-scrolling: touch;
}

.ts-algolia-panel.ts-mobile {
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-height: none;
    overflow: visible;
}

/* ---------- Sections -------------------------------------------------- */

.ts-algolia-section {
    padding: 14px 18px 12px;
}

.ts-algolia-section + .ts-algolia-section {
    border-top: 1px solid #f0f0f0;
}

.ts-algolia-section[hidden] {
    display: none !important;
}

.ts-algolia-section-title {
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 700;
    color: #999;
    letter-spacing: 0.08em;
    margin: 0 0 9px;
    padding: 0;
    border: none;
    line-height: 1;
}

/* Compactar verticalmente las secciones de chips */
.ts-algolia-brands,
.ts-algolia-categories {
    padding: 10px 18px 10px;
}

/* ---------- InstantSearch wrappers ----------------------------------- */

.ts-algolia-panel .ais-Hits {
    margin: 0;
}

.ts-algolia-panel .ais-Hits-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ts-algolia-panel .ais-Hits-item {
    list-style: none;
    margin: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    border: none;
}

/* Productos: lista vertical (default) */
.ts-products-hits .ais-Hits-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Marcas y Categorías: chips horizontales con wrap */
.ts-brands-hits .ais-Hits-list,
.ts-categories-hits .ais-Hits-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ts-brands-hits .ais-Hits-item,
.ts-categories-hits .ais-Hits-item {
    flex: 0 0 auto;
}

/* ---------- Generic hit ---------------------------------------------- */

.ts-hit {
    text-decoration: none;
    color: inherit;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.ts-hit:hover,
.ts-hit:focus {
    text-decoration: none;
    color: inherit;
    outline: none;
}

.ts-hit em {
    font-style: normal;
    font-weight: 700;
    background: rgba(131, 183, 53, 0.18);
    padding: 0 1px;
    border-radius: 2px;
}

/* ---------- Chips: brands & categories ------------------------------- */

.ts-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #e8e8e8;
    background: #fff;
    font-size: 13px;
    line-height: 1.3;
    color: #333;
    white-space: nowrap;
    max-width: 100%;
}

.ts-chip:hover,
.ts-chip:focus {
    background: #f7f7f7;
    border-color: #ccc;
}

.ts-chip-brand {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
}

.ts-chip-category {
    font-weight: 500;
}

.ts-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Product hit ---------------------------------------------- */

.ts-hit-product {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border-radius: 4px;
}

.ts-hit-product:hover,
.ts-hit-product:focus {
    background: #f7f7f7;
}

.ts-hit-image {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    background: #fafafa;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f0f0f0;
}

.ts-hit-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.ts-hit-body {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.ts-hit-title {
    font-size: 13.5px;
    line-height: 1.35;
    color: #222;
    margin: 0 0 5px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ts-hit-brand-tag {
    display: inline;
    font-weight: 700;
    margin-right: 4px;
}

.ts-hit-name {
    font-weight: 400;
    color: #444;
}

.ts-hit-meta {
    font-size: 12px;
    line-height: 1;
}

.ts-hit-price {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 14px;
    color: #83b735;
    white-space: nowrap;
    margin-left: 8px;
    align-self: center;
}

/* ---------- Stock pills ---------------------------------------------- */

.ts-stock {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.ts-stock-high {
    color: #2d7d2d;
    background: rgba(45, 125, 45, 0.10);
}

.ts-stock-low {
    color: #b67800;
    background: rgba(182, 120, 0, 0.12);
}

.ts-stock-out {
    color: #888;
    background: #f0f0f0;
}

/* ---------- Footer CTA (single line, fixed) -------------------------- */

.ts-algolia-footer {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 13px 18px;
    background: #fafafa;
    color: #222;
    text-decoration: none;
    border-top: 1px solid #f0f0f0;
    transition: background-color 0.12s ease, color 0.12s ease;
    text-align: center;
    line-height: 1;
}

.ts-algolia-footer-text {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-algolia-footer:hover,
.ts-algolia-footer:focus {
    background: #f0f0f0;
    color: #000;
    text-decoration: none;
}

.ts-algolia-footer[hidden] {
    display: none !important;
}

/* ---------- Empty state ---------------------------------------------- */

.ts-algolia-empty {
    padding: 28px 18px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.ts-algolia-empty[hidden] {
    display: none !important;
}

.ts-algolia-empty-msg {
    margin: 0;
}

/* ---------- Mobile drawer tweaks ------------------------------------- */

.ts-algolia-panel.ts-mobile .ts-algolia-section {
    padding: 14px 16px 12px;
}

.ts-algolia-panel.ts-mobile .ts-algolia-brands,
.ts-algolia-panel.ts-mobile .ts-algolia-categories {
    padding: 10px 16px 10px;
}

.ts-algolia-panel.ts-mobile .ts-hit-product {
    padding: 12px 8px;
}

.ts-algolia-panel.ts-mobile .ts-hit-image {
    width: 60px;
    height: 60px;
}

.ts-algolia-panel.ts-mobile .ts-hit-title {
    font-size: 14px;
}

.ts-algolia-panel.ts-mobile .ts-hit-price {
    font-size: 15px;
}

.ts-algolia-panel.ts-mobile .ts-algolia-footer {
    padding: 16px;
}

.ts-algolia-panel.ts-mobile .ts-algolia-footer-text {
    font-size: 12px;
}
