/* ==========================================================================
   BOWY USA LLC — SHOP STYLESHEET (FACETED FILTER)
   Copyright (c) 2026 BOWY USA LLC. All rights reserved. Confidential and Proprietary.
   ==========================================================================
   Loaded on the shop and product taxonomy pages.
   ========================================================================== */

/* --------------------------------------------------------------------------
   SHOP FILTER LAYOUT & MOBILE DRAWER
   -------------------------------------------------------------------------- */

@media (max-width: 991px) {
  .bowy-mobile-filter-bar {
    position: -webkit-sticky !important;
  }

  #secondary.primary-sidebar {
    height: 100vh !important;
  }
}

/* --------------------------------------------------------------------------
   1. FACETED FILTER
   -------------------------------------------------------------------------- */
.bowy-faceted-filter-widget {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 25px;
    box-sizing: border-box;
    font-family: inherit;
}
.bowy-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 2px solid #0b1626;
}
.bowy-filter-header-title {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0b1626;
}
.bowy-filter-reset-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: #b91c1c;
    text-decoration: underline;
    cursor: pointer;
}
.bowy-filter-reset-link:hover {
    color: #dc2626;
}
.bowy-facet-section {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}
.bowy-facet-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.bowy-facet-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #0b1626;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
}
.bowy-slider-wrap {
    position: relative;
    height: 24px;
    margin: 12px 0 10px 0;
    display: flex;
    align-items: center;
}
.bowy-slider-track {
    position: absolute;
    width: 100%;
    height: 5px;
    background: #e2e8f0;
    border-radius: 4px;
    z-index: 1;
}
.bowy-slider-range {
    position: absolute;
    height: 5px;
    background: #0b1626;
    border-radius: 4px;
    z-index: 2;
}
.bowy-range-input {
    position: absolute;
    width: 100%;
    height: 5px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 0;
    background: none !important;
    border: none !important;
    pointer-events: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    z-index: 3;
    outline: none;
}
.bowy-range-input::-webkit-slider-runnable-track {
    background: transparent;
    border: none;
}
.bowy-range-input::-moz-range-track {
    background: transparent;
    border: none;
}
.bowy-range-input::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0b1626;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.15s ease;
}
.bowy-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.18);
    background: #1e293b;
}
.bowy-range-input::-moz-range-thumb {
    pointer-events: auto;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0b1626;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.15s ease;
}
.bowy-range-input::-moz-range-thumb:hover {
    transform: scale(1.18);
    background: #1e293b;
}
.bowy-price-values-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}
.bowy-price-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 8px;
    flex: 1;
}
.bowy-price-pill-lbl {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
}
.bowy-price-pill-val {
    font-size: 0.84rem;
    font-weight: 700;
    color: #0b1626;
}
.bowy-price-pill-sep {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}
.bowy-price-active-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.76rem;
    color: #0b1626;
    font-weight: 600;
}
.bowy-price-clear-btn {
    background: none;
    border: none;
    color: #b91c1c;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0 4px;
    text-decoration: underline;
}
.bowy-price-clear-btn:hover {
    color: #dc2626;
}
.bowy-facet-search-wrap {
    margin-bottom: 8px;
}
.bowy-facet-search-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.82rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
    background: #f8fafc;
    transition: border-color 0.2s ease;
}
.bowy-facet-search-input:focus {
    border-color: #0b1626;
    background: #ffffff;
}
.bowy-facet-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.bowy-scrollable-facet {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}
.bowy-scrollable-facet::-webkit-scrollbar {
    width: 4px;
}
.bowy-scrollable-facet::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.bowy-facet-item {
    display: flex;
    align-items: center;
    font-size: 0.86rem;
    color: #334155;
    cursor: pointer;
    user-select: none;
    line-height: 1.3;
}
.bowy-facet-item:hover .bowy-facet-label {
    color: #0b1626;
}
.bowy-checkbox {
    margin: 0 8px 0 0 !important;
    cursor: pointer !important;
    accent-color: #0b1626 !important;
    width: 15px !important;
    height: 15px !important;
}
.bowy-facet-label {
    flex-grow: 1;
}
.bowy-facet-count {
    font-size: 0.78rem;
    color: #64748b;
    margin-left: 6px;
}
/* AJAX Loading State (Smooth in-place fade, zero jumping) */
ul.products.bowy-filtering-active {
    opacity: 0.55 !important;
    pointer-events: none !important;
    transition: opacity 0.15s ease !important;
}
.bowy-faceted-filter-widget.bowy-filter-loading {
    pointer-events: none !important;
}

/* Desktop Inviolability Defaults (>= 992px) */
@media (min-width: 992px) {
    .bowy-mobile-filter-bar {
        display: none !important;
    }
    .bowy-drawer-close-btn,
    .bowy-drawer-footer,
    .bowy-filter-backdrop {
        display: none !important;
    }
    .bowy-facet-title::after {
        display: none !important;
    }
    .bowy-facet-active-dot {
        display: none !important;
    }
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-list,
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-search-wrap,
    .bowy-facet-section.bowy-facet-collapsed .bowy-slider-wrap,
    .bowy-facet-section.bowy-facet-collapsed .bowy-price-values-display,
    .bowy-facet-section.bowy-facet-collapsed .bowy-price-active-tag {
        display: flex !important;
    }
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-search-wrap,
    .bowy-facet-section.bowy-facet-collapsed .bowy-slider-wrap {
        display: block !important;
    }
}

/* Mobile & Tablet Off-Canvas Drawer Chassis (<= 991px) */
@media (max-width: 991px) {
    .bowy-mobile-filter-bar {
        display: block !important;
        position: -webkit-sticky !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 900 !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        padding: 10px 0 !important;
        margin: 0 0 16px 0 !important;
        box-shadow: 0 4px 14px rgba(11, 22, 38, 0.08) !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .bowy-mobile-filter-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 10px !important;
        width: 100% !important;
        background: #0b1626 !important;
        color: #ffffff !important;
        border: 1px solid #1e293b !important;
        border-radius: 6px !important;
        padding: 12px 20px !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        text-transform: uppercase !important;
        cursor: pointer !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
        transition: background-color 0.2s ease, transform 0.1s ease !important;
    }
    .bowy-mobile-filter-btn:active {
        transform: scale(0.98) !important;
        background: #1e293b !important;
    }
    .bowy-mobile-filter-badge {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #d4af37 !important;
        color: #0b1626 !important;
        font-size: 0.75rem !important;
        font-weight: 800 !important;
        min-width: 20px !important;
        height: 20px !important;
        border-radius: 10px !important;
        padding: 0 6px !important;
        line-height: 1 !important;
    }

    #secondary.primary-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 86vw !important;
        max-width: 360px !important;
        height: 100vh !important;
        height: 100dvh !important;
        background: #ffffff !important;
        z-index: 999999 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.35) !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        touch-action: auto !important;
    }
    #secondary.primary-sidebar.bowy-drawer-open {
        transform: translateX(0) !important;
    }
    #secondary.primary-sidebar .sidebar-inner-wrap,
    #secondary.primary-sidebar .widget_bowy_faceted_filter_widget {
        padding: 0 !important;
        margin: 0 !important;
        min-height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
    }

    body.bowy-drawer-active {
        overflow: hidden !important;
        touch-action: none !important;
    }

    .bowy-filter-backdrop {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(11, 22, 38, 0.65) !important;
        z-index: 999998 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.25s ease !important;
        backdrop-filter: blur(2px) !important;
        -webkit-backdrop-filter: blur(2px) !important;
    }
    .bowy-filter-backdrop.bowy-backdrop-active {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .bowy-faceted-filter-widget {
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
        background: #ffffff !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 100% !important;
    }
    .bowy-filter-header {
        position: sticky !important;
        top: 0 !important;
        background: #ffffff !important;
        z-index: 20 !important;
        padding: 16px 18px 14px 18px !important;
        margin-bottom: 0 !important;
        border-bottom: 2px solid #0b1626 !important;
    }
    .bowy-filter-header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }
    .bowy-drawer-close-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #f1f5f9 !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 50% !important;
        width: 32px !important;
        height: 32px !important;
        font-size: 15px !important;
        font-weight: 700 !important;
        color: #0b1626 !important;
        cursor: pointer !important;
        padding: 0 !important;
        line-height: 1 !important;
    }
    .bowy-drawer-close-btn:active {
        background: #e2e8f0 !important;
    }

    .bowy-facet-section {
        padding: 14px 18px !important;
        margin-bottom: 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }
    .bowy-facet-title {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        cursor: pointer !important;
        padding: 4px 0 !important;
        margin-bottom: 0 !important;
        user-select: none !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        color: #0b1626 !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    .bowy-facet-item {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    .bowy-checkbox {
        touch-action: manipulation !important;
    }
    .bowy-facet-title::after {
        content: '' !important;
        display: inline-block !important;
        width: 8px !important;
        height: 8px !important;
        border-right: 2px solid #64748b !important;
        border-bottom: 2px solid #64748b !important;
        transform: rotate(45deg) !important;
        transition: transform 0.2s ease !important;
        margin-right: 4px !important;
        flex-shrink: 0 !important;
    }
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-title::after {
        transform: rotate(-45deg) !important;
    }
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-list,
    .bowy-facet-section.bowy-facet-collapsed .bowy-facet-search-wrap,
    .bowy-facet-section.bowy-facet-collapsed .bowy-slider-wrap,
    .bowy-facet-section.bowy-facet-collapsed .bowy-price-values-display,
    .bowy-facet-section.bowy-facet-collapsed .bowy-price-active-tag {
        display: none !important;
    }
    .bowy-facet-section:not(.bowy-facet-collapsed) .bowy-facet-title {
        margin-bottom: 12px !important;
    }
    .bowy-facet-active-dot {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #0b1626 !important;
        color: #ffffff !important;
        font-size: 0.7rem !important;
        font-weight: 700 !important;
        min-width: 18px !important;
        height: 18px !important;
        border-radius: 9px !important;
        padding: 0 4px !important;
        margin-left: auto !important;
        margin-right: 10px !important;
        line-height: 1 !important;
    }

    .bowy-drawer-footer {
        display: block !important;
        position: sticky !important;
        bottom: 0 !important;
        background: #ffffff !important;
        padding: 14px 18px !important;
        border-top: 1px solid #e2e8f0 !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05) !important;
        z-index: 25 !important;
        margin-top: auto !important;
    }
    .bowy-drawer-apply-btn {
        display: block !important;
        width: 100% !important;
        background: #0b1626 !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 6px !important;
        padding: 13px 18px !important;
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        cursor: pointer !important;
        text-align: center !important;
        transition: background-color 0.15s ease !important;
    }
    .bowy-drawer-apply-btn:active {
        background: #1e293b !important;
    }
}
