/* =====================================================
   CUSTOM PRODUCT FILTER — v3.0
   Layout: top category tabs, left sidebar filters,
   toolbar (active pills + sort + view toggle), product grid
   ===================================================== */

.cpf-shortcode-wrapper {
    margin: 20px 0;
    --cpf-black: #1a1a1a;
    --cpf-border: #e3e3e3;
    --cpf-gray-text: #767676;
    --cpf-gray-light: #f7f7f7;
    --cpf-accent: #1a1a1a;
    --cpf-sale: #c8763a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: #222;
}

.cpf-filters-wrapper * {
    box-sizing: border-box;
}

/* ===== TOP BAR / CATEGORY TABS ===== */
.cpf-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 2px solid var(--cpf-black);
    border-bottom: 1px solid var(--cpf-border);
    padding: 14px 0;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}

.cpf-top-tabs {
    display: flex;
    align-items: center;
    gap: 26px;
    flex-wrap: wrap;
}

.cpf-tab {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--cpf-gray-text);
    text-decoration: none;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.cpf-tab:hover {
    color: var(--cpf-black);
}

.cpf-tab-active {
    color: var(--cpf-black);
    border-bottom: 2px solid var(--cpf-black);
}

.cpf-top-count {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--cpf-gray-text);
    white-space: nowrap;
}

.cpf-total-count {
    color: var(--cpf-black);
}

/* ===== LAYOUT: SIDEBAR + MAIN ===== */
.cpf-layout {
    display: flex;
    align-items: flex-start;
    gap: 36px;
}

/* ===== SIDEBAR ===== */
.cpf-sidebar {
    flex: 0 0 240px;
    max-width: 240px;
}

.cpf-sidebar-header {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.cpf-clear-all {
    margin-bottom: 18px;
}

.cpf-clear-filters {
    color: #4a90d9;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.2s;
}

.cpf-clear-filters:hover {
    color: #2a6cb5;
    text-decoration: underline;
}

.cpf-filter-section {
    border: 1px solid var(--cpf-border);
    border-radius: 4px;
    margin-bottom: 14px;
    background: #fff;
}

.cpf-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cpf-black);
    cursor: pointer;
    user-select: none;
}

.cpf-toggle-icon {
    font-size: 15px;
    font-weight: 400;
    color: #999;
    line-height: 1;
}

.cpf-section-body {
    padding: 0 14px 14px;
}

.cpf-filter-section.cpf-collapsed .cpf-section-body {
    display: none;
}

/* ===== CATEGORY / SIZE / USE CASE LISTS ===== */
.cpf-categories label,
.cpf-sizes label,
.cpf-use-cases label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13.5px;
    cursor: pointer;
    color: #444;
    user-select: none;
    gap: 6px;
}

.cpf-categories label:hover,
.cpf-sizes label:hover,
.cpf-use-cases label:hover {
    color: #000;
}

.cpf-label-text {
    flex: 1;
}

.cpf-count {
    color: #aaa;
    font-size: 12px;
    font-weight: 400;
}

.cpf-filter-section input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--cpf-black);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.cpf-category-group {
    margin-bottom: 2px;
}

.cpf-parent-category {
    font-weight: 500;
    color: #222;
}

.cpf-sub-categories {
    margin-left: 22px;
    border-left: 1px solid #eee;
    padding-left: 10px;
}

.cpf-sub-category {
    font-weight: 400;
    color: #666;
    font-size: 13px;
}

/* ===== PRICE SLIDER ===== */
.cpf-price-slider {
    position: relative;
    height: 20px;
    margin: 12px 2px 6px;
}

.cpf-price-track {
    position: absolute;
    top: 9px;
    left: 0;
    right: 0;
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
}

.cpf-price-fill {
    position: absolute;
    top: 0;
    left: 0%;
    right: 0%;
    height: 100%;
    background: var(--cpf-black);
    border-radius: 2px;
}

.cpf-price-range {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
}

.cpf-price-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--cpf-black);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    position: relative;
    z-index: 3;
}

.cpf-price-range::-moz-range-thumb {
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--cpf-black);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.cpf-price-range::-webkit-slider-runnable-track {
    background: transparent;
    height: 20px;
}

.cpf-price-range::-moz-range-track {
    background: transparent;
    height: 20px;
}

.cpf-price-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.cpf-price-current {
    font-size: 12px;
    font-weight: 600;
    color: var(--cpf-black);
}

/* ===== MAIN CONTENT ===== */
.cpf-main {
    flex: 1;
    min-width: 0;
}

.cpf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.cpf-active-pills {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.cpf-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--cpf-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #333;
    background: #fff;
}

.cpf-pill-remove {
    cursor: pointer;
    color: #999;
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s;
}

.cpf-pill-remove:hover {
    color: #000;
}

.cpf-toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.cpf-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--cpf-border);
    border-radius: 4px;
    padding: 8px 12px;
}

.cpf-sort-wrap label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #666;
    margin: 0;
    white-space: nowrap;
}

.cpf-sort-select {
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--cpf-black);
    cursor: pointer;
    padding: 0;
}

.cpf-sort-select:focus {
    outline: none;
}

.cpf-view-toggle {
    display: flex;
    border: 1px solid var(--cpf-border);
    border-radius: 4px;
    overflow: hidden;
}

.cpf-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #fff;
    border: none;
    color: #999;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.cpf-view-btn + .cpf-view-btn {
    border-left: 1px solid var(--cpf-border);
}

.cpf-view-btn:hover {
    color: #333;
}

.cpf-view-btn.cpf-view-active {
    background: var(--cpf-black);
    color: #fff;
}

/* ===== RESULTS META ===== */
.cpf-results-meta {
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #999;
}

/* ===== PRODUCTS GRID ===== */
.cpf-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#cpf-products-container.cpf-view-mode-list .cpf-products-grid {
    grid-template-columns: 1fr;
}

#cpf-products-container.cpf-view-mode-list .cpf-product-card {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    align-items: start;
}

#cpf-products-container.cpf-view-mode-list .cpf-product-image {
    aspect-ratio: 1;
}

/* ===== PRODUCT CARD ===== */
.cpf-product-card {
    position: relative;
}

.cpf-product-image {
    position: relative;
    display: block;
    aspect-ratio: 1;
    background: #eef2f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.cpf-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cpf-badge-wrap {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
}

.cpf-badge {
    display: inline-block;
    padding: 4px 9px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 3px;
    color: #fff;
}

.cpf-badge-dark {
    background: var(--cpf-black);
}

.cpf-badge-sale {
    background: var(--cpf-sale);
}

.cpf-product-subtitle {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 4px;
}

.cpf-product-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 6px;
}

.cpf-product-title a {
    color: var(--cpf-black);
    text-decoration: none;
}

.cpf-product-title a:hover {
    text-decoration: underline;
}

.cpf-product-desc {
    font-size: 13px;
    color: #767676;
    line-height: 1.45;
    margin-bottom: 10px;
}

.cpf-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    margin-bottom: 6px;
}

.cpf-product-price ins {
    text-decoration: none;
    background: none;
}

.cpf-product-price del {
    color: #aaa;
    font-weight: 400;
    font-size: 13px;
    margin-right: 6px;
}

.cpf-product-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #999;
}

.cpf-stars {
    position: relative;
    display: inline-block;
    font-size: 13px;
    letter-spacing: 1px;
    color: #e0e0e0;
}

.cpf-stars::before {
    content: "★★★★★";
    position: absolute;
    top: 0;
    left: 0;
    width: calc(var(--rating, 0) / 5 * 100%);
    overflow: hidden;
    white-space: nowrap;
    color: #e8a838;
}

.cpf-product-cart .button,
.cpf-product-cart a.add_to_cart_button,
.cpf-product-cart a.button {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px 14px;
    border: 1px solid var(--cpf-black);
    border-radius: 4px;
    background: #fff;
    color: var(--cpf-black);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.cpf-product-cart .button:hover,
.cpf-product-cart a.add_to_cart_button:hover,
.cpf-product-cart a.button:hover {
    background: var(--cpf-black);
    color: #fff;
}

/* ===== LOADING / EMPTY / ERROR STATES ===== */
.cpf-loading {
    text-align: center;
    padding: 60px 20px;
    font-size: 15px;
    color: #999;
    grid-column: 1 / -1;
}

.cpf-loading span {
    display: inline-block;
    position: relative;
}

.cpf-loading span:after {
    content: '...';
    animation: cpf-dots 1.5s steps(4, end) infinite;
}

@keyframes cpf-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.cpf-no-products {
    text-align: center;
    padding: 60px 20px;
    font-size: 15px;
    color: #999;
    background: var(--cpf-gray-light);
    border-radius: 6px;
    border: 1px dashed #ddd;
}

.cpf-error {
    text-align: center;
    padding: 60px 20px;
    font-size: 15px;
    color: #c0392b;
    background: #fef0f0;
    border-radius: 6px;
    border: 1px solid #fcc;
}

/* ===== PAGINATION ===== */
.cpf-pagination {
    margin-top: 34px;
    text-align: center;
}

.cpf-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 3px;
    border: 1px solid var(--cpf-border);
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    transition: all 0.2s;
    cursor: pointer;
    background: #fff;
}

.cpf-pagination .page-numbers.current {
    background: var(--cpf-black);
    color: #fff;
    border-color: var(--cpf-black);
}

.cpf-pagination .page-numbers:hover:not(.current) {
    background: #f2f2f2;
}

.cpf-pagination .page-numbers.dots {
    border: none;
    background: none;
    cursor: default;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .cpf-layout {
        flex-direction: column;
    }

    .cpf-sidebar {
        flex: 1 1 auto;
        max-width: none;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .cpf-sidebar-header,
    .cpf-clear-all {
        grid-column: 1 / -1;
    }

    .cpf-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 640px) {
    .cpf-top-tabs {
        gap: 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .cpf-top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .cpf-sidebar {
        grid-template-columns: 1fr;
    }

    .cpf-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .cpf-toolbar-right {
        margin-left: 0;
        justify-content: space-between;
    }

    .cpf-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    #cpf-products-container.cpf-view-mode-list .cpf-product-card {
        grid-template-columns: 100px 1fr;
        gap: 12px;
    }

    .cpf-product-title {
        font-size: 14px;
    }
}

/* ===== PRINT ===== */
@media print {
    .cpf-sidebar,
    .cpf-toolbar,
    .cpf-top-bar {
        display: none;
    }
}
