/* WooCommerce Product Filter - Frontend Styles */

:root {
    --wcpf-dark: #0f1115;
    --wcpf-light: #ffffff;
    --wcpf-bg-light: #f9f9f9;
    --wcpf-border: #e0e0e0;
    --wcpf-text-dark: #2c3338;
    --wcpf-text-light: #6c7781;
}

.wcpf-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    margin-bottom: 40px;
}

/* Filter Header (Dark Mode) */
.wcpf-filter-header {
    background-color: var(--wcpf-dark);
    color: var(--wcpf-light);
    padding: 30px 40px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.wcpf-filter-header h2 {
    color: var(--wcpf-light);
    font-size: 20px;
    margin: 0 0 20px 0;
    font-weight: 600;
}

/* Search Bar */
.wcpf-search-wrap {
    margin-bottom: 25px;
}

.wcpf-search-input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 30px;
    border: none;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}

/* Filters Row */
.wcpf-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: flex-start;
    justify-content: space-between;
}

.wcpf-filter-group {
    flex: 1;
    min-width: 200px;
}

.wcpf-filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #fff;
}

/* Select Dropdowns */
.wcpf-select {
    width: 100%;
    padding: 10px 15px;
    border-radius: 4px;
    border: none;
    background-color: #fff;
    color: #333;
    font-size: 14px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* Custom Dropdown UI */
.wcpf-custom-select {
    position: relative;
    width: 100%;
}

.wcpf-custom-select-trigger {
    padding: 10px 15px;
    border-radius: 4px;
    background-color: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wcpf-custom-select-arrow {
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.2s ease;
}

.wcpf-custom-select.is-open .wcpf-custom-select-arrow {
    transform: rotate(180deg);
}

.wcpf-custom-select-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    color: #333;
    padding: 10px;
}

/* Checkbox Lists */
.wcpf-checkbox-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wcpf-checkbox-list li {
    margin-bottom: 8px;
}
.wcpf-checkbox-list li:last-child {
    margin-bottom: 0;
}

.wcpf-dropdown-checkbox {
    display: flex;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
    color: #333;
    margin: 0 !important;
}

.wcpf-dropdown-checkbox input {
    margin-right: 8px;
    cursor: pointer;
}

/* Category Tree Styles */
.wcpf-category-tree {
    margin-left: 22px; /* Provide space for absolute positioned toggles */
}

.wcpf-category-item {
    margin-bottom: 5px;
}

.wcpf-cat-row {
    position: relative;
    display: flex;
    align-items: center;
    padding: 3px 0;
}

.wcpf-cat-toggle {
    position: absolute;
    left: -22px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    font-size: 14px;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-family: monospace;
}

.wcpf-cat-toggle:hover {
    color: #000;
}

.wcpf-cat-children {
    padding-left: 10px;
    margin-top: 5px;
    border-left: 1px dashed #ddd;
    margin-left: 4px;
}

/* Price Range Slider */
.wcpf-price-wrap {
    min-width: 250px;
}

.wcpf-range-slider {
    position: relative;
    width: 100%;
    height: 4px;
    margin-top: 15px;
    background-color: #333;
    border-radius: 2px;
}

.wcpf-slider-track {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 2px;
    pointer-events: none;
}

.wcpf-slider-range {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: var(--wcpf-primary);
    border-radius: 2px;
}

.wcpf-range-slider input[type="range"] {
    position: absolute !important;
    width: 100% !important;
    height: 16px !important; /* Matches thumb height for natural centering */
    top: -6px !important; /* (-6px top + 16px height / 2) centers at 2px (middle of 4px track) */
    left: 0 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background: transparent !important;
    pointer-events: none;
    outline: none !important;
    margin: 0 !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* Hide default tracks completely in WebKit and Firefox */
.wcpf-range-slider input[type="range"]::-webkit-slider-runnable-track {
    background: transparent !important;
    border: none !important;
    height: 0 !important;
    box-shadow: none !important;
}
.wcpf-range-slider input[type="range"]::-moz-range-track {
    background: transparent !important;
    border: none !important;
    height: 0 !important;
    box-shadow: none !important;
}

.wcpf-range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 16px !important;
    height: 16px !important;
    border-radius: 50% !important;
    background: var(--wcpf-primary) !important;
    cursor: grab;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
    border: none !important;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    margin-top: -8px !important; /* Fix vertical alignment for webkit thumbs without track height */
}

.wcpf-range-slider input[type="range"]::-webkit-slider-thumb:hover,
.wcpf-range-slider input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    cursor: grabbing;
}

.wcpf-range-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--wcpf-primary);
    cursor: grab;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.wcpf-range-slider input[type="range"]::-moz-range-thumb:hover,
.wcpf-range-slider input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    cursor: grabbing;
}

.wcpf-price-values {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ccc;
    font-size: 14px;
    font-weight: 500;
}

.wcpf-price-values span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wcpf-price-separator {
    color: #666;
}

.wcpf-price-input {
    width: 65px !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    border: 1px solid #444 !important;
    background-color: #222 !important;
    color: #fff !important;
    font-size: 13px !important;
    outline: none !important;
    text-align: center !important;
    transition: border-color 0.2s;
    box-shadow: none !important;
}

.wcpf-price-input:focus {
    border-color: var(--wcpf-primary) !important;
    background-color: #222 !important;
    color: #fff !important;
}

/* Hide number input spinners */
.wcpf-price-input::-webkit-outer-spin-button,
.wcpf-price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.wcpf-price-input[type=number] {
  -moz-appearance: textfield;
}

/* Product Type Checkboxes */
.wcpf-type-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.wcpf-custom-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #ccc !important;
    position: relative;
}

.wcpf-custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.wcpf-checkmark {
    height: 16px;
    width: 16px;
    background-color: #333;
    border-radius: 3px;
    margin-right: 8px;
    position: relative;
    display: inline-block;
}

.wcpf-custom-checkbox:hover input ~ .wcpf-checkmark {
    background-color: #444;
}

.wcpf-custom-checkbox input:checked ~ .wcpf-checkmark {
    background-color: var(--wcpf-primary);
}

/* Product Grid (List View Default) */
.wcpf-products-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.wcpf-product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background-color: var(--wcpf-bg-light);
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--wcpf-border);
    transition: box-shadow 0.2s, transform 0.2s;
}

body.wcpf-dark-mode .wcpf-product-item {
    background-color: #1a1a1a;
    border-color: #333;
}

.wcpf-product-item:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.wcpf-product-image-col {
    flex: 0 0 70px;
}
.wcpf-product-image {
    width: 100%;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
    display: block;
}

.wcpf-product-details-col {
    flex: 1 1 auto;
    min-width: 0;
}

.wcpf-product-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--wcpf-text-dark);
    margin: 0 0 5px 0;
    text-decoration: none !important;
}

.wcpf-product-link {
    text-decoration: none !important;
    color: inherit !important;
}
body.wcpf-dark-mode .wcpf-product-title {
    color: #fff;
}

.wcpf-product-price {
    display: block;
    font-size: 15px;
    font-weight: bold;
    color: var(--wcpf-primary);
    margin-bottom: 5px;
}

.wcpf-product-stock {
    display: block;
    font-size: 13px;
    color: var(--wcpf-text-light);
}
body.wcpf-dark-mode .wcpf-product-stock {
    color: #aaa;
}

.wcpf-product-action-col {
    flex: 0 0 auto;
}

.wcpf-add-to-cart-wrapper {
    display: inline-flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 36px;
    max-width: 160px;
}
body.wcpf-dark-mode .wcpf-add-to-cart-wrapper {
    background: #222;
    border-color: #444;
}

.wcpf-qty-input {
    width: 45px !important;
    min-width: 45px !important;
    max-width: 45px !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    border-right: 1px solid #ddd !important;
    border-radius: 0 !important;
    font-size: 14px !important;
    color: #333 !important;
    box-shadow: none !important;
}
body.wcpf-dark-mode .wcpf-qty-input {
    border-right-color: #444 !important;
    color: #fff !important;
}

/* Hide number input spinners inside the box */
.wcpf-qty-input::-webkit-outer-spin-button,
.wcpf-qty-input::-webkit-inner-spin-button {
  appearance: none !important;
  -webkit-appearance: none !important;
  margin: 0 !important;
}
.wcpf-qty-input[type=number] {
  appearance: textfield !important;
  -moz-appearance: textfield !important;
}

.wcpf-add-to-cart-btn {
    border: none !important;
    background: var(--wcpf-primary) !important;
    color: #fff !important;
    padding: 0 15px !important;
    margin: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: opacity 0.2s !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
}
.wcpf-add-to-cart-btn:hover {
    opacity: 0.9;
}

/* Grid Cards (Classic) View Overrides */
.wcpf-products-grid.wcpf-view-classic {
    display: grid;
    grid-template-columns: repeat(var(--wcpf-grid-cols, 3), 1fr);
    gap: 20px;
}

.wcpf-view-classic .wcpf-product-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
}

.wcpf-view-classic .wcpf-product-image-col {
    flex: 0 0 auto;
    width: 100%;
}
.wcpf-view-classic .wcpf-product-image {
    aspect-ratio: 1 / 1;
}

.wcpf-view-classic .wcpf-product-details-col {
    text-align: center;
}

.wcpf-view-classic .wcpf-product-action-col {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: auto;
}

/* Classic Column (Table Row) View Overrides */
.wcpf-products-grid.wcpf-view-classic_column .wcpf-product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.wcpf-view-classic_column .wcpf-product-image-col {
    flex: 0 0 70px;
}

.wcpf-view-classic_column .wcpf-product-details-col {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.wcpf-view-classic_column .wcpf-product-title {
    flex: 2;
    margin: 0;
}

.wcpf-view-classic_column .wcpf-product-price {
    flex: 1;
    margin: 0;
    text-align: center;
}

.wcpf-view-classic_column .wcpf-product-stock {
    flex: 1;
    text-align: center;
}

.wcpf-view-classic_column .wcpf-product-action-col {
    flex: 0 0 auto;
}

/* Loader */
#wcpf-loader {
    text-align: center;
    padding: 40px;
    font-size: 16px;
    color: var(--wcpf-text-light);
}

.wcpf-pagination-wrap {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.wcpf-page-btn {
    padding: 8px 12px;
    border: 1px solid var(--wcpf-border);
    background: #fff;
    cursor: pointer;
    border-radius: 3px;
}

.wcpf-page-btn.active {
    background: var(--wcpf-primary);
    color: #fff;
    border-color: var(--wcpf-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .wcpf-products-grid.wcpf-view-modern .wcpf-product-item,
    .wcpf-products-grid.wcpf-view-classic_column .wcpf-product-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .wcpf-products-grid.wcpf-view-modern .wcpf-product-image-col,
    .wcpf-products-grid.wcpf-view-classic_column .wcpf-product-image-col {
        flex: 0 0 auto;
        width: 80px;
    }
    .wcpf-view-classic_column .wcpf-product-details-col {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 5px;
    }
    .wcpf-view-classic_column .wcpf-product-price,
    .wcpf-view-classic_column .wcpf-product-stock {
        text-align: left;
    }
    .wcpf-products-grid.wcpf-view-modern .wcpf-product-action-col,
    .wcpf-products-grid.wcpf-view-classic_column .wcpf-product-action-col {
        width: 100%;
        display: flex;
        justify-content: flex-start;
    }

    .wcpf-products-grid.wcpf-view-classic {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .wcpf-products-grid.wcpf-view-classic {
        grid-template-columns: 1fr !important;
    }
}
