/**
 * bs-algolia-facets.css
 *
 * Shared styles for the BSFacets core across all three page types:
 *   - Product search results  (bootstrap shim: bs-product-search-facets-shim.js)
 *   - Seller store pages      (bootstrap shim: bs-dokan-algolia-store-search-integration.php)
 *   - Product category pages  (bootstrap shim: future Phase 6)
 *
 * Covers:
 *   1. Toolbar (filter toggle, active tags, sort dropdown)
 *   2. Sliding sidebar overlay
 *   3. Facet groups (refinement checkboxes, price slider, toggles)
 *   4. Hit grid + default hit card
 *   5. Pagination
 *   6. Mobile tweaks
 *
 * ID-prefixed selectors (#bs-facets-toolbar, #bs-facets-sidebar) are used
 * wherever WoodMart's high-specificity styles need to be beaten.
 *
 * Colour palette (gold accent):
 *   Gold:      #b0743e   Hover gold: #8c5d31
 *   Warm tint: #f7eee5   Dark:       #1a1a1a
 *
 * @package BlackSpace
 */


/* ═══════════════════════════════════════════════════════════
   1. TOOLBAR
   ═══════════════════════════════════════════════════════════ */

.bs-facets-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 1700px;
    margin: 0 auto 16px;
    padding: 10px 0;
}

.bs-facets-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.bs-facets-toolbar-right {
    flex-shrink: 0;
}

/* Filter toggle button
   Uses parent ID (specificity 0,1,1,0) to beat WoodMart's button styles. */
#bs-facets-toolbar .bs-facets-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    line-height: 1.2 !important;
    transition: background 0.15s;
}

#bs-facets-toolbar .bs-facets-toggle:hover {
    background: #333;
}

#bs-facets-toolbar .bs-facets-toggle svg {
    flex-shrink: 0;
}

/* Active filter tags strip */
.bs-facets-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.bs-facets-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f7eee5;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    color: #8c5d31;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    font-family: inherit;
}

.bs-facets-tag:hover {
    background: #eeddd0;
    color: #6b4828;
}

.bs-facets-tag-x {
    font-size: 14px;
    line-height: 1;
    color: #b0743e;
}

.bs-facets-clear-all {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: #666;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.bs-facets-clear-all:hover {
    color: #000;
}

/* Sort dropdown — Etsy-style pill */
.bs-facets-sort-select {
    padding: 8px 28px 8px 12px !important;
    border: none !important;
    border-radius: 50px !important;
    background: transparent url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") right 10px center no-repeat !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #333 !important;
    cursor: pointer !important;
    outline: none !important;
    box-shadow: none !important;
    transition: background-color 0.15s;
}

.bs-facets-sort-select:hover,
.bs-facets-sort-select:focus {
    background-color: #eeeeee !important;
    outline: none !important;
}


/* ═══════════════════════════════════════════════════════════
   2. SLIDING SIDEBAR OVERLAY
   ═══════════════════════════════════════════════════════════ */

.bs-facets-sidebar {
    position: fixed;
    top: 0;
    left: -360px;
    width: 320px;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    padding: 20px 24px;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: none;
}

.bs-facets-sidebar.bs-facets-sidebar-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

/* Close button
   !important needed throughout to override WoodMart's global button styles. */
.bs-facets-sidebar-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 22px !important;
    color: #666 !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    z-index: 1;
}

.bs-facets-sidebar-close:hover {
    color: #000 !important;
    background: none !important;
    background-color: transparent !important;
}

/* Sidebar heading */
#bs-facets-sidebar .bs-facets-sidebar-heading {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 40px 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #1a1a1a;
    color: #1a1a1a;
}

/* Backdrop */
.bs-facets-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9998;
    cursor: pointer;
}

.bs-facets-backdrop.bs-visible {
    display: block;
}

/* Prevent body scroll when sidebar is open */
body.bs-facets-active {
    overflow: hidden !important;
}


/* ═══════════════════════════════════════════════════════════
   3. FACET GROUPS (inside sidebar)
   ═══════════════════════════════════════════════════════════ */

.bs-facets-group {
    margin-bottom: 20px;
}

#bs-facets-sidebar .bs-facets-group-heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    color: #1a1a1a;
}

.bs-facets-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
}

/* Facet item row */
#bs-facets-sidebar .bs-facets-item a,
#bs-facets-sidebar .bs-facets-toggle-link,
#bs-facets-sidebar .bs-facets-refinement-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    line-height: 1.4;
}

#bs-facets-sidebar .bs-facets-item a:hover,
#bs-facets-sidebar .bs-facets-toggle-link:hover,
#bs-facets-sidebar .bs-facets-refinement-link:hover {
    color: #000;
}

/* Active item */
#bs-facets-sidebar .bs-facets-active a,
#bs-facets-sidebar .bs-facets-active .bs-facets-toggle-link,
#bs-facets-sidebar .bs-facets-active .bs-facets-refinement-link {
    font-weight: 600;
    color: #b0743e;
}

/* Custom checkbox */
#bs-facets-sidebar .bs-facets-checkbox {
    display: inline-block;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 1.5px solid #bbb;
    border-radius: 3px;
    background: #fff;
    position: relative;
    transition: all 0.15s;
    flex-shrink: 0;
}

#bs-facets-sidebar .bs-facets-checkbox.bs-checked {
    background: #b0743e;
    border-color: #b0743e;
}

#bs-facets-sidebar .bs-facets-checkbox.bs-checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#bs-facets-sidebar .bs-facets-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#bs-facets-sidebar .bs-facets-count {
    color: #999;
    font-size: 12px;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════
   4. PRICE DUAL-RANGE SLIDER
   ═══════════════════════════════════════════════════════════ */

#bs-facets-sidebar .bs-facets-price-slider {
    padding: 8px 0 4px;
}

#bs-facets-sidebar .bs-facets-price-track {
    position: relative;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 10px 0;
}

#bs-facets-sidebar .bs-facets-price-range {
    position: absolute;
    height: 100%;
    background: #b0743e;
    border-radius: 3px;
    top: 0;
    left: 0;
    right: 0;
}

#bs-facets-sidebar .bs-facets-price-handle {
    position: absolute;
    top: -7px;
    left: 0;
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

#bs-facets-sidebar .bs-facets-price-handle::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #b0743e;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#bs-facets-sidebar .bs-facets-price-handle::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #b0743e;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

#bs-facets-sidebar .bs-facets-price-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

#bs-facets-sidebar .bs-facets-price-labels span {
    font-size: 13px;
    font-weight: 600;
    color: #b0743e;
}

#bs-facets-sidebar .bs-facets-price-apply {
    margin-top: 10px;
    padding: 8px 16px;
    width: 100%;
    background: #b0743e;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    line-height: 1.2 !important;
    transition: background 0.15s;
    font-family: inherit;
}

#bs-facets-sidebar .bs-facets-price-apply:hover {
    background: #8c5d31;
}


/* ═══════════════════════════════════════════════════════════
   5. HIT GRID + DEFAULT CARD
   Bootstrap shims may override .bs-hit-* for page-specific markup.
   ═══════════════════════════════════════════════════════════ */

.bs-facets-hits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Default hit card — used when no renderHit override is provided */
.bs-hit-item {
    display: flex;
    flex-direction: column;
}

.bs-hit-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.bs-hit-link:hover .bs-hit-title {
    color: #b0743e;
}

.bs-hit-image {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 10px;
}

.bs-hit-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.bs-hit-link:hover .bs-hit-image img {
    transform: scale(1.04);
}

.bs-hit-image-placeholder {
    width: 100%;
    height: 100%;
    background: #eee;
}

.bs-hit-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bs-hit-title {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.4;
    transition: color 0.15s;
    /* Two-line clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bs-hit-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    margin-top: auto;
    padding-top: 4px;
}

.bs-hit-price-regular {
    font-weight: 600;
    color: #1a1a1a;
}

.bs-hit-price-sale {
    font-weight: 600;
    color: #b0743e;
}

.bs-hit-price-reg {
    color: #999;
    font-size: 12px;
    text-decoration: line-through;
}

/* No results */
.bs-facets-no-results {
    text-align: center;
    padding: 48px 24px;
    color: #666;
    font-size: 14px;
}


/* ═══════════════════════════════════════════════════════════
   6. PAGINATION
   ═══════════════════════════════════════════════════════════ */

.bs-facets-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    padding-bottom: 16px;
}

.bs-facets-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.bs-facets-page-btn:hover {
    border-color: #b0743e;
    color: #b0743e;
}

.bs-facets-page-btn.active {
    background: #b0743e;
    border-color: #b0743e;
    color: #fff;
    font-weight: 700;
}


/* ═══════════════════════════════════════════════════════════
   7. MOBILE TWEAKS
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .bs-facets-toolbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }

    .bs-facets-toolbar-left {
        width: 100%;
        justify-content: space-between;
    }

    .bs-facets-toolbar-right {
        width: 100%;
    }

    .bs-facets-sort-select {
        width: 100% !important;
    }

    /* Hide tag strip on narrow screens — tags are inside the sidebar */
    .bs-facets-tags {
        display: none;
    }

    .bs-facets-sidebar {
        width: 280px;
        left: -320px;
        padding: 16px 20px;
    }

    .bs-facets-hits-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
}
