/* =========================================
   1. GLOBAL BASE STYLES (Layout & Components)
   ========================================= */

/* Sidebar Layout Container */
.shop-layout-container {
    display: flex;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 50px;
}

.shop-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.shop-main-content {
    flex-grow: 1;
}

/* Sidebar Filters Styling */
.goodgeek-sidebar-filters {
    background: #fff;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #1a1a1a;
}

/* Search Input */
.search-input-wrapper {
    position: relative;
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.search-input-wrapper input {
    border: none;
    padding: 10px;
    width: 100%;
    outline: none;
}

.search-input-wrapper button {
    background: none;
    border: none;
    padding: 0 10px;
    cursor: pointer;
    color: #666;
}

/* Select Inputs */
.goodgeek-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

/* Checkboxes & Radios */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-check-item,
.checkbox-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
}

.radio-check-item input,
.checkbox-item input {
    margin-right: 10px;
    accent-color: #000;
    width: 16px;
    height: 16px;
}

.checkbox-item .count {
    margin-left: auto;
    color: #888;
    font-size: 0.85rem;
}

/* Filter Actions */
.filter-actions {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reset-filters-btn {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    text-decoration: underline;
}

/* Price Slider (Visual) */
.price-slider-wrapper {
    position: relative;
    width: 100%;
    height: 30px;
    margin-top: 10px;
}

.slider-track {
    width: 100%;
    height: 5px;
    position: absolute;
    margin: auto;
    top: 0;
    bottom: 0;
    border-radius: 5px;
    background: #d5d5d5;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    outline: none;
    position: absolute;
    margin: auto;
    top: 0;
    bottom: 0;
    background-color: transparent;
    pointer-events: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    background-color: #ffff00;
    border: 2px solid #000000;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    margin-top: -8px;
}

input[type="range"]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    background-color: #ffff00;
    border: 2px solid #000000;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
}

.price-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.clear-price-btn {
    background: #f0f0f0;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
}

/* =========================================
   2. MOBILE STYLES (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {

    /* Layout Container */
    .shop-layout-container {
        display: block;
        margin-top: 10px;
    }

    /* Header Grid Layout */
    .goodgeek-shop-header {
        display: grid;
        grid-template-columns: 1fr 1.5fr;
        grid-template-areas:
            "notices notices"
            "count sort"
            "filter filter";
        gap: 10px;
        margin-bottom: 20px;
        align-items: center;
    }

    /* Unwrap PHP Wrapper */
    .shop-loop-header {
        display: contents;
    }

    /* 1. Result Count (Row 2: Left) */
    .woocommerce-result-count {
        grid-area: count;
        margin: 0;
        text-align: left;
        font-size: 0.85rem;
    }

    /* 2. Sort Dropdown (Row 2: Right) */
    .woocommerce-ordering {
        grid-area: sort;
        margin: 0;
        text-align: right;
    }

    .woocommerce-ordering select {
        width: 100%;
        height: 40px;
        font-size: 11px;
        border: 2px solid #000;
        border-radius: 4px;
        background-color: #fff;
    }

    /* 3. Filter Button (Row 3: Full Width) */
    #mobile-filter-toggle {
        grid-area: filter;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        height: 40px;
        background-color: #ffff00;
        color: #000;
        border: 2px solid #000;
        border-radius: 4px;
        font-weight: bold;
        font-size: 13px;
    }

    /* Off-Canvas Sidebar */
    .shop-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 300px;
        height: 100vh;
        background: #fff;
        z-index: 99999;
        padding: 20px;
        overflow-y: auto;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        visibility: hidden;
    }

    .shop-sidebar.active {
        left: 0;
        visibility: visible;
    }

    .mobile-filter-close {
        position: absolute;
        top: 10px;
        right: 15px;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #333;
    }

    .goodgeek-filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99998;
        display: none;
    }

    .goodgeek-filter-overlay.active {
        display: block;
    }

    /* Mobile Product Grid (2 Columns) */
    ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    ul.products::before,
    ul.products::after {
        display: none !important;
    }

    ul.products li.product {
        width: auto !important;
        margin: 0 !important;
        float: none !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    ul.products li.product a img {
        margin-bottom: 5px !important;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }

    ul.products li.product .woocommerce-loop-product__title {
        font-size: 0.85rem !important;
        margin-bottom: 5px !important;
    }

    ul.products li.product .price {
        font-size: 0.9rem !important;
        margin-bottom: 5px !important;
    }

    ul.products li.product .button {
        width: 100%;
        text-align: center;
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
}

/* =========================================
   3. DESKTOP STYLES (min-width: 769px)
   ========================================= */
@media (min-width: 769px) {

    /* Hide Mobile Elements */
    #mobile-filter-toggle,
    .mobile-filter-close,
    .goodgeek-filter-overlay {
        display: none !important;
    }

    /* Force Sidebar Visibility */
    .shop-sidebar {
        position: static !important;
        width: 280px !important;
        height: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        visibility: visible !important;
        left: auto !important;
        z-index: 1 !important;
        display: block !important;
    }

    /* Reset Header Layout */
    .goodgeek-shop-header {
        display: block;
        margin-bottom: 20px;
    }

    .shop-loop-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .woocommerce-result-count {
        float: left;
        margin: 0;
        width: auto;
    }

    .woocommerce-ordering {
        float: right;
        margin: 0;
        width: auto;
    }

    /* Ensure Sort Select is Auto Width */
    .woocommerce-ordering select {
        width: auto;
    }

    /* Allow Theme Grid to Function (No Overrides) */
    ul.products li.product .woocommerce-loop-product__title {
        max-height: none;
        overflow: visible;
    }
}