/* Master Layout */
.cwf-master-wrapper { 
    display: flex; gap: 40px; font-family: 'Outfit', sans-serif !important; 
    color: #212529; width: 100%; box-sizing: border-box; 
}

/* Centered Layout */
.cwf-master-wrapper.cwf-centered-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Sidebar Wrapper */
.cwf-sidebar-container { width: 300px; flex-shrink: 0; transition: 0.3s ease; position: relative; }
.is-collapsed .cwf-sidebar-container { width: 0; margin-right: -40px; }
.is-collapsed .cwf-filter-sidebar { opacity: 0; visibility: hidden; pointer-events: none; }

/* Filter Open Button */
#cwf-open-sidebar { 
    display: none; background: #7b865d!important; color: #fff !important; 
    border: none !important; padding: 10px 20px !important; border-radius: 4px; 
    cursor: pointer; font-weight: 700 !important; font-family: 'Outfit', sans-serif !important; 
    font-size: 14px; align-items: center; gap: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.is-collapsed #cwf-open-sidebar { display: flex !important; position: absolute; left: 0; top: 0; z-index: 99; }

button:hover { background-color: #4e4a49 !important; color: #fff; text-decoration: none; }

/* Sidebar Internal Styling */
.cwf-filter-sidebar { width: 100%; background: #fff; }
.cwf-sidebar-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 10px; }
.cwf-sidebar-header h3 { font-size: 18px !important; font-weight: 700 !important; color: #212529 !important; margin: 0 !important; }
.cwf-arrow-back { font-size: 16px; color: #868e96; cursor: pointer; }

.cwf-sidebar-section { border-bottom: 1px solid #f1f3f5; padding: 20px 0; }
.cwf-section-title { font-size: 14px !important; font-weight: 700 !important; display: flex; justify-content: space-between; cursor: pointer; color: #212529 !important; }

/* Radios & Counts */
.cwf-radio-list { display: flex; flex-direction: column; gap: 12px; }
.cwf-radio-container { display: flex !important; align-items: center; position: relative; padding-left: 28px; cursor: pointer; font-size: 13px; color: #495057; }
.cwf-checkmark { position: absolute; left: 0; height: 16px; width: 16px; border: 1px solid #ced4da; border-radius: 50%; }
.cwf-radio-container input { position: absolute; opacity: 0; }
.cwf-radio-container input:checked ~ .cwf-checkmark::after { content: ""; position: absolute; top: 3px; left: 3px; width: 8px; height: 8px; border-radius: 50%; background: #2d5a27; }
.cwf-count { margin-left: auto; font-size: 10px; color: #868e96; background: #f8f9fa; padding: 2px 7px; border-radius: 12px; }

/* Price Slider */
.cwf-price-labels { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 15px; font-size: 14px; color: #212529; }
#cwf-price-slider { height: 4px; background: #eee !important; border: none; margin: 10px 0; position: relative; border-radius: 10px; }
#cwf-price-slider .ui-slider-range { background: #7b865d!important; position: absolute; height: 100%; border-radius: 10px; }
#cwf-price-slider .ui-slider-handle { height: 18px; width: 18px; background: #2d5a27; border: 2px solid #fff; border-radius: 50%; position: absolute; top: -7px; cursor: pointer; margin-left: -9px; outline: none; }

.cwf-clear-all-btn { width: 100%; background: #7b865d!important; color: #fff !important; border: none; border-radius: 4px; padding: 14px; margin-top: 25px; font-weight: 700; cursor: pointer; font-size: 14px; }

/* Products Header */
.cwf-products-container { flex: 1; min-width: 0; }
.cwf-top-bar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 25px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.cwf-results-count { font-size: 14px; color: #868e96; }

.cwf-top-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cwf-sort-box { border: 1.5px solid #212529; border-radius: 6px; padding: 6px 15px; display: flex; flex-direction: column; }
.cwf-sort-box label { font-size: 11px; color: #868e96; margin-bottom: 2px; }
#cwf-ajax-sort { border: none !important; font-weight: 700; color: #212529; font-family: 'Outfit'; background: transparent; cursor: pointer; outline: none; font-size: 18px; padding: 0; }

.cwf-view-toggle { display: flex; gap: 8px; }
.cwf-view-btn { width: 36px; height: 36px; border: 1px solid #eee; border-radius: 6px; background: #fff; cursor: pointer; color: #868e96; display: flex; align-items: center; justify-content: center; }
.cwf-view-btn.active { color: #fff !important; border-color: #7b865d!important; background: #7b865d!important; }

/* Product Cards */
.cwf-loop-wrapper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; width: 100%; margin-top: 30px;}

.cwf-item { 
    background: #fff; 
    border-radius: 12px; 
    overflow: hidden; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cwf-item:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

.cwf-img-container { 
    height: 240px; 
    overflow: hidden; 
    background: #fff;
    flex-shrink: 0;
    position: relative;
    width: 100%;
}

.cwf-img-container img { 
    max-width: 90% !important;
    max-height: 90% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    transition: transform 0.3s ease;
    display: block;
}

.cwf-item:hover .cwf-img-container img {
    transform: scale(1.05);
}

.cwf-product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: center;
    text-align: center;
}

/* Let the anchor tag fill the container and center the image */
.cwf-img-container a {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 100%;
    height: 100%;
}

.cwf-title { 
    font-size: 15px; 
    font-weight: 600; 
    margin: 0 0 8px 0;
    line-height: 1.4;
    color: #212529;
    flex-grow: 1;
    text-align: center;
    width: 100%;
}

.cwf-title a { 
    color: #212529 !important; 
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.cwf-title a:hover {
    color: #7b865d!important;
}

.cwf-meta-action { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    margin-top: auto;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap;
}

.cwf-price-txt { 
    font-size: 18px; 
    font-weight: 700; 
    color: #2d5a27;
    white-space: nowrap;
}

/* Native WooCommerce Add to Cart button styling */
.cwf-meta-action .add_to_cart_button,
.cwf-meta-action .button {
    background: #7b865d!important;
    color: #fff !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    font-family: 'Outfit', sans-serif !important;
    line-height: 1.5 !important;
    display: inline-block !important;
}

.cwf-meta-action .add_to_cart_button:hover,
.cwf-meta-action .button:hover {
    background: #1e3f1c !important;
    box-shadow: 0 4px 12px rgba(45, 90, 39, 0.3) !important;
    color: #fff !important;
}

/* List View Logic */
.cwf-list-layout .cwf-loop-wrapper { grid-template-columns: 1fr; }
.cwf-list-layout .cwf-item { 
    display: flex; 
    align-items: center; 
    width: 100%; 
    border-bottom: 1px solid #eee; 
    padding: 20px 0;
    box-shadow: none;
}
.cwf-list-layout .cwf-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: none;
}
.cwf-list-layout .cwf-img-container { 
    width: 160px; 
    height: 160px;
    flex-shrink: 0; 
    margin-right: 30px;
}
.cwf-list-layout .cwf-product-info { 
    flex: 1; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 0;
}
.cwf-list-layout .cwf-title { 
    margin: 0; 
    flex: 1;
    font-size: 19px; 
}
.cwf-list-layout .cwf-meta-action { 
    min-width: 250px; 
    justify-content: flex-end; 
    gap: 30px; 
}

/* Pagination */
.cwf-pagination { 
    text-align: center; 
    margin-top: 50px; 
    padding-top: 40px; 
    border-top: 1px solid #eee; 
}

.cwf-load-more { 
    background: linear-gradient(135deg, #7b865d 0%, #1e3f1c 100%) !important; 
    color: #fff !important; 
    padding: 14px 48px; 
    border: none; 
    border-radius: 8px; 
    font-weight: 700; 
    cursor: pointer; 
    font-size: 14px; 
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(45, 90, 39, 0.2);
    letter-spacing: 0.5px;
}

.cwf-load-more:hover { 
    background: linear-gradient(135deg, #1e3f1c 0%, #0f2510 100%) !important;
    box-shadow: 0 6px 20px rgba(45, 90, 39, 0.3);
    transform: translateY(-2px);
}

.cwf-load-more:active {
    transform: translateY(0);
}

/* ======================================================
   RESPONSIVE DESIGN
   ====================================================== */

/* 1. Desktop Scaling */
@media (max-width: 1200px) {
    .cwf-grid-layout .cwf-loop-wrapper { grid-template-columns: repeat(3, 1fr); gap: 28px; }
    .cwf-master-wrapper { gap: 20px; }
    .cwf-img-container { height: 220px; }
}

/* 2. Tablets */
@media (max-width: 991px) {
    .cwf-master-wrapper { flex-direction: column; }
    .cwf-sidebar-container { width: 100%; margin-bottom: 20px; }
    .is-collapsed .cwf-sidebar-container { margin-bottom: 60px; }
    .cwf-grid-layout .cwf-loop-wrapper { grid-template-columns: repeat(2, 1fr); gap: 24px; }
    .cwf-img-container { height: 200px; }
    .is-collapsed #cwf-open-sidebar { 
        position: static; 
        width: fit-content; 
        margin: 0 auto 20px auto; 
    }
}

/* 3. Small Mobile */
@media (max-width: 580px) {
    .cwf-top-bar { flex-direction: column; align-items: center; gap: 15px; }
    .cwf-top-controls { align-items: center; width: 100%; }
    .cwf-sort-box { width: 100%; text-align: center; }
    .cwf-grid-layout .cwf-loop-wrapper { grid-template-columns: 1fr; gap: 20px; }
    .cwf-img-container { height: 180px; }

    .cwf-list-layout .cwf-item { flex-direction: column; text-align: center; padding: 16px 0; border-bottom: 1px solid #eee; }
    .cwf-list-layout .cwf-img-container { 
        width: 100%; 
        height: 200px;
        margin-bottom: 16px;
        margin-right: 0;
    }
    .cwf-list-layout .cwf-product-info { 
        flex-direction: column; 
        padding: 0; 
        width: 100%; 
        align-items: center;
    }
    .cwf-list-layout .cwf-title { 
        margin: 0 0 12px 0;
        flex: 1;
        font-size: 15px;
    }
    .cwf-list-layout .cwf-meta-action { 
        min-width: 100%; 
        justify-content: center; 
        margin-top: 12px;
        flex-direction: column;
        gap: 10px;
    }
    .cwf-list-layout .cwf-price-txt { order: 2; }
    .cwf-list-layout .cwf-meta-action .add_to_cart_button,
    .cwf-list-layout .cwf-meta-action .button {
        order: 1;
        width: 100% !important;
        text-align: center !important;
    }

    .cwf-meta-action { justify-content: space-around; width: 100%; }
    .cwf-title { font-size: 16px; }
    .cwf-product-info { padding: 14px; }
}

/* Loader */
#cwf-ajax-loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

a.button.product_type_simple.add_to_cart_button.ajax_add_to_cart {
    border-radius: 7px;
    background: #7b865d!important;
    color: #fff;
}

/* Hierarchical Categories Accordion & Indentation */
.cwf-category-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.cwf-parent-category-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cwf-cat-toggle {
    background: transparent !important;
    border: none !important;
    color: #495057 !important;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: none !important;
    line-height: 1;
}

.cwf-cat-toggle-spacer {
    width: 20px;
    flex-shrink: 0;
}

.cwf-sub-categories {
    margin-top: 6px;
    padding-left: 26px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cwf-child-radio {
    font-size: 12px !important;
    color: #6c757d;
}

/* Out of Stock Badge and Button */
.cwf-out-of-stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #e03131;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 4px;
    z-index: 5;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.cwf-meta-action .cwf-out-of-stock-btn,
a.button.cwf-out-of-stock-btn {
    background: #495057 !important;
    color: #ffffff !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    font-family: 'Outfit', sans-serif !important;
    line-height: 1.5 !important;
    display: inline-block !important;
}

.cwf-meta-action .cwf-out-of-stock-btn:hover,
a.button.cwf-out-of-stock-btn:hover {
    background: #212529 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}