/* ==========================================================================
   Celeste Shop Layout & Product Filters
   ========================================================================== */

body .cel-page.cel-shop-page {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body .cel-page.cel-shop-page > .wp-block-group {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

body .cel-shop-page .wp-block-columns.cel-shop-layout,
body .cel-shop-page .cel-shop-layout,
.cel-shop-layout {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: row-reverse;
    column-gap: 32px;
    row-gap: 0;
    gap: 32px;
    max-width: 1440px;
    margin: 0 auto;
    width: calc(100% - (var(--cel-container-padding, 20px) * 2));
    box-sizing: border-box;
    padding: 0;
    position: relative;
}

body.celeste-sidebar-left .cel-shop-page .wp-block-columns.cel-shop-layout,
body.celeste-sidebar-left .cel-shop-layout {
    flex-direction: row;
}

body.celeste-sidebar-right .cel-shop-page .wp-block-columns.cel-shop-layout,
body.celeste-sidebar-right .cel-shop-layout {
    flex-direction: row-reverse;
}

body .cel-shop-page .wp-block-columns.cel-shop-layout > .wp-block-column,
body .cel-shop-page .wp-block-columns.cel-shop-layout > .wp-block-column:not(:first-child),
.cel-shop-layout > .wp-block-column,
.cel-shop-layout > .wp-block-column:not(:first-child) {
    margin: 0;
    margin-left: 0;
    margin-inline-start: 0;
}

.cel-shop-layout-fallback {
    display: flex;
    align-items: flex-start;
}

.cel-shop-layout.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   Filters Sidebar Component
   ========================================================================== */

.cel-filters-sidebar {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 20px;
    overflow: hidden;
}

.cel-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.cel-toggle-icon {
    transition: transform 0.3s ease;
    color: #666;
    display: flex;
}

.cel-filters-sidebar.is-active .cel-toggle-icon {
    transform: rotate(180deg);
}

.cel-filters-sidebar h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #111;
}

.cel-filters-form {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 10px 25px 25px;
    transition: all 0.3s ease-in-out;
    margin-bottom: 0;
}

.cel-filters-form label {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 5px 0 0;
    line-height: 1.2;
}

.cel-filters-form .cel-filter-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    min-height: 24px;
    line-height: 1.2;
}

.cel-filter-checkboxes-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.cel-filters-form .cel-filter-check input[type="checkbox"] {
    margin: 0;
    position: relative;
    top: 0;
    flex: 0 0 auto;
}

.cel-filters-form .cel-filter-check span,
.cel-filters-form .cel-filter-check .cel-filter-check__text {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin: 0;
}

.cel-filters-form select,
.cel-filters-form input[type="number"] {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 7px 9px;
    background: #fff;
    box-sizing: border-box;
    max-width: 100%;
}

.cel-filters-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    padding-bottom: 5px;
}

.cel-filters-actions button {
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--celeste-button_bg, #111);
    color: var(--celeste-button_text, #fff);
}

.cel-filters-actions a {
    text-decoration: none;
    color: var(--celeste-link_color, #2563eb);
    font-weight: 600;
}

/* ==========================================================================
   Price Range Slider
   ========================================================================== */

.cel-price-range {
    width: 100%;
}

.cel-price-range__values {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.cel-price-range__sliders {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.cel-price-range__sliders::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    transform: translateY(-50%);
    z-index: 1;
}

.cel-price-range__track-highlight {
    position: absolute;
    top: 50%;
    height: 4px;
    background: var(--celeste-link_color, #2563eb);
    transform: translateY(-50%);
    z-index: 2;
    border-radius: 2px;
}

.cel-price-range__input {
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    margin: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    transform: translateY(-50%);
    z-index: 3;
}

.cel-price-range__input::-webkit-slider-runnable-track {
    background: transparent;
    border: 0;
}

.cel-price-range__input::-moz-range-track {
    background: transparent;
    border: 0;
}

.cel-price-range__input--min,
.cel-price-range__input--max {
    z-index: 3;
}

.cel-price-range__input.is-active {
    z-index: 5;
}

.cel-price-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--celeste-link_color, #2563eb);
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    cursor: pointer;
    margin-top: 0;
}

.cel-price-range__input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--celeste-link_color, #2563eb);
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    cursor: pointer;
}

.cel-shop-filters-fallback {
    margin-bottom: 18px;
}

.cel-shop-layout:not(.cel-shop-layout-fallback) .cel-shop-filters-fallback {
    display: none;
}

.cel-filters-form input[type="hidden"] {
    display: none;
    visibility: hidden;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.cel-shop-sidebar-wrap.is-layout-constrained > *,
.cel-shop-sidebar-wrap.wp-block-group-is-layout-constrained > *,
.cel-filters-sidebar.is-layout-constrained > *,
.cel-filters-sidebar.wp-block-group-is-layout-constrained > *,
.cel-filters-form > * {
    margin-block-start: 0;
    margin-block-end: 0;
    margin-top: 0;
    margin-bottom: 0;
}

/* ==========================================================================
   Desktop Layout (>= 981px)
   ========================================================================== */

@media (min-width: 981px) {
    /* Specificity 0, 6, 1 > WordPress Core 0, 3, 0 (.wp-block-columns:not(.is-not-stacked-on-mobile) > .wp-block-column) */
    body .cel-shop-page .wp-block-columns.cel-shop-layout:not(.is-not-stacked-on-mobile) > .wp-block-column.cel-shop-sidebar-col,
    body .cel-shop-layout .cel-shop-sidebar-col {
        flex: 0 0 var(--cel-sidebar-width, 280px);
        flex-basis: var(--cel-sidebar-width, 280px);
        flex-grow: 0;
        flex-shrink: 0;
        max-width: var(--cel-sidebar-width, 280px);
        min-width: var(--cel-sidebar-width, 280px);
        margin-left: 0;
        margin-right: 0;
    }

    body .cel-shop-page .wp-block-columns.cel-shop-layout:not(.is-not-stacked-on-mobile) > .wp-block-column.cel-shop-results-col,
    body .cel-shop-layout .cel-shop-results-col {
        flex: 1 1 auto;
        flex-basis: auto;
        flex-grow: 1;
        max-width: none;
        min-width: 0;
        padding-left: 12px;
        padding-right: 0;
    }

    body.celeste-sidebar-left .cel-shop-page .wp-block-columns.cel-shop-layout:not(.is-not-stacked-on-mobile) > .wp-block-column.cel-shop-results-col,
    body.celeste-sidebar-left .cel-shop-layout .cel-shop-results-col {
        padding-left: 0;
        padding-right: 12px;
    }

    .cel-filters-header {
        cursor: default;
        padding: 20px 25px;
        margin-bottom: 0;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-sizing: border-box;
    }

    .cel-toggle-icon {
        display: none;
    }

    .cel-filters-sidebar h3 {
        margin: 0;
        flex: 1 1 auto;
    }

    .cel-filters-form {
        display: grid;
        opacity: 1;
        padding: 0 25px 25px;
        pointer-events: auto;
        width: 100%;
        box-sizing: border-box;
    }

    .cel-filters-actions {
        padding-bottom: 0;
    }

    /* Base Product Grid in Results Column (Specificity 0, 5, 1 > WooCommerce 0, 3, 0) */
    body .cel-shop-results-col ul.products,
    body .cel-shop-results-col .wc-block-grid__products,
    body .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col .wc-block-product-template.is-flex-container.is-flex-container {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 30px;
        justify-content: stretch;
        justify-items: stretch;
        align-items: stretch;
        width: 100%;
        max-width: 100%;
    }

    /* Column Variants (Specificity 0, 6, 1) */
    body .cel-shop-results-col .cel-columns-1 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-1 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-1,
    body .cel-shop-results-col .cel-products-grid.cel-columns-1 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    body .cel-shop-results-col .cel-columns-2 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-2 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-2,
    body .cel-shop-results-col .cel-products-grid.cel-columns-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body .cel-shop-results-col .cel-columns-3 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-3 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-3,
    body .cel-shop-results-col .cel-products-grid.cel-columns-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body .cel-shop-results-col .cel-columns-4 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-4 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-4,
    body .cel-shop-results-col .cel-products-grid.cel-columns-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body .cel-shop-results-col .cel-columns-5 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-5 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-5,
    body .cel-shop-results-col .cel-products-grid.cel-columns-5 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    body .cel-shop-results-col .cel-columns-6 .wc-block-product-template.wc-block-product-template,
    body.celeste-shop-cols-6 .cel-shop-results-col .wc-block-product-template.wc-block-product-template,
    body .cel-shop-results-col ul.products.cel-columns-6,
    body .cel-shop-results-col .cel-products-grid.cel-columns-6 {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    /* Product Items inside Grid (Specificity 0, 6, 2 > WooCommerce .wc-block-product-template.is-flex-container.is-flex-container.columns-4 > li at 0, 4, 1) */
    body .cel-shop-results-col ul.products li.product,
    body .cel-shop-results-col .wc-block-grid__product,
    body .cel-shop-results-col .wc-block-product-template.wc-block-product-template > li,
    body .cel-shop-results-col .wc-block-product-template.is-flex-container.is-flex-container > li,
    body .cel-shop-results-col .wc-block-product-template.is-flex-container.is-flex-container[class*="columns-"] > li,
    body .cel-shop-results-col .wc-block-product-template__responsive.wc-block-product-template__responsive[class*="columns-"] > li {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 0 0 100%;
        flex-basis: 100%;
        margin: 0;
        box-sizing: border-box;
    }
}

/* ==========================================================================
   Mobile & Tablet Layout (<= 980px)
   ========================================================================== */

@media (max-width: 980px) {
    body .cel-shop-page .wp-block-columns.cel-shop-layout,
    body.celeste-sidebar-left .cel-shop-page .wp-block-columns.cel-shop-layout,
    body.celeste-sidebar-right .cel-shop-page .wp-block-columns.cel-shop-layout,
    body.celeste-sidebar-left .cel-shop-layout,
    body.celeste-sidebar-right .cel-shop-layout,
    .cel-shop-layout {
        flex-direction: column;
    }

    body .cel-shop-page .wp-block-columns.cel-shop-layout:not(.is-not-stacked-on-mobile) > .wp-block-column.cel-shop-sidebar-col,
    body .cel-shop-page .wp-block-columns.cel-shop-layout:not(.is-not-stacked-on-mobile) > .wp-block-column.cel-shop-results-col,
    body.woocommerce-page .cel-shop-sidebar-col,
    body.woocommerce-page .cel-shop-results-col,
    .cel-shop-layout-fallback .cel-shop-sidebar-col,
    .cel-shop-layout-fallback .cel-shop-results-col,
    .cel-shop-layout .cel-shop-sidebar-col,
    .cel-shop-layout .cel-shop-results-col {
        flex: 0 0 100%;
        flex-basis: 100%;
        max-width: 100%;
        min-width: 0;
        width: 100%;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .cel-filters-header {
        cursor: pointer;
        padding: 15px 20px;
    }

    .cel-filters-sidebar .cel-filters-form {
        display: none;
        opacity: 0;
        visibility: hidden;
        height: 0;
        overflow: hidden;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .cel-filters-sidebar.is-active .cel-filters-form {
        display: grid;
        opacity: 1;
        visibility: visible;
        height: auto;
        pointer-events: auto;
        border-top: 1px solid #eee;
        margin-top: 10px;
        padding: 20px;
    }

    .cel-filters-sidebar.is-active .cel-filters-header {
        margin-bottom: 0;
    }

    /* 2-Column Product Grid on Mobile */
    body.woocommerce ul.products,
    body.woocommerce-page ul.products,
    body .cel-products-grid .wc-block-product-template.wc-block-product-template,
    body .cel-products-grid .wc-block-product-template.is-flex-container.is-flex-container,
    body .wp-block-woocommerce-product-collection .wc-block-product-template.wc-block-product-template {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
        padding-left: 10px;
        padding-right: 10px;
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    body.woocommerce ul.products li.product,
    body.woocommerce-page ul.products li.product,
    body .wc-block-product-template.wc-block-product-template > li,
    body .wc-block-product-template.is-flex-container.is-flex-container > li,
    body .wc-block-product-template.is-flex-container.is-flex-container[class*="columns-"] > li,
    body .wc-block-product-template__responsive.wc-block-product-template__responsive[class*="columns-"] > li,
    body .cel-products-grid .wc-block-product-template > li,
    .cel-product {
        width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
        flex-basis: 100%;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        float: none;
    }

    body.woocommerce ul.products li.product .button,
    body.woocommerce-page ul.products li.product .button {
        width: 100%;
        text-align: center;
        white-space: normal;
        line-height: 1.2;
        padding: 10px 12px;
        box-sizing: border-box;
    }

    body.woocommerce ul.products li.product .price,
    body.woocommerce-page ul.products li.product .price,
    body.woocommerce ul.products li.product .woocommerce-loop-product__title,
    body.woocommerce-page ul.products li.product .woocommerce-loop-product__title {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}
