/* Garo Product Filters - Premium Frontend UI (Optimized) */

:root {
    --gpf-bg: #ffffff;
    --gpf-surface: #f8fafc;
    --gpf-text: #0f172a;
    --gpf-text-light: #64748b;
    --gpf-border: #e2e8f0;
    --gpf-radius: 4px;
    --gpf-font: inherit;
}

/* 1. Trigger Button (Shopify Ignite Style + Vertical Alignment) */
.gpf-trigger-wrapper {
    float: left;
    margin-right: 20px;
    margin-bottom: 24px;
    height: 42px; /* Hard anchor for alignment */
}

.gpf-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gpf-bg);
    border: 1px solid var(--gpf-border);
    color: var(--gpf-text);
    padding: 0 20px;
    height: 42px; /* Matches WooCommerce default select height */
    font-size: 14px;
    font-weight: 500;
    text-transform: none; /* Sentence case like Shopify */
    letter-spacing: 0;
    border-radius: var(--gpf-radius); /* Strict 4px luxury rule */
    cursor: pointer;
    font-family: var(--gpf-font);
    transition: all 0.3s ease;
    /* Soft, diffused Shopify Ignite shadow */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03); 
}

.gpf-trigger-btn:hover {
    border-color: #cbd5e1;
    /* Elevated shadow on hover */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.gpf-trigger-btn svg {
    margin-right: 8px;
    color: var(--gpf-text);
}

/* Force Vertical Alignment with WooCommerce Defaults */
.woocommerce-result-count {
    float: left;
    line-height: 42px; /* Vertically centers text with the 42px button */
    margin-top: 0 !important;
    margin-bottom: 24px !important;
}

.woocommerce-ordering {
    float: right;
    margin-bottom: 24px !important;
}

.woocommerce-ordering select {
    height: 42px; /* Match button height exactly */
    padding-top: 0;
    padding-bottom: 0;
    vertical-align: middle;
    /* Give default sorting the same Ignite shadow for consistency */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    border-radius: var(--gpf-radius);
    border: 1px solid var(--gpf-border);
}

/* Mobile Layout (60/40 Split Ignite Style) */
@media (max-width: 768px) {
    /* Hide the text result count to keep it clean */
    .woocommerce-result-count {
        display: none !important; 
    }
    
    /* Filter Button takes up approx 55-60% of the screen */
    .gpf-trigger-wrapper {
        width: calc(65% - 10px); 
        margin-right: 10px;
        margin-bottom: 20px;
        float: left;
    }
    
    .gpf-trigger-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* WooCommerce Sort Dropdown takes up the remaining 45% */
    .woocommerce-ordering {
        width: 35%;
        margin-bottom: 20px !important;
        float: right;
    }
    
    .woocommerce-ordering select,
    .woocommerce-ordering .ct-select-dropdown {
        width: 100%;
        height: 42px;
        padding-left: 12px;
        padding-right: 25px; /* Leaves room for the dropdown arrow */
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        font-size: 13px; /* Slightly smaller to ensure "Sort by latest" fits */
    }
}

/* 2. Off-Canvas Overlay */
.gpf-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

body.gpf-modal-open .gpf-overlay {
    opacity: 1;
    visibility: visible;
}

body.gpf-modal-open {
    overflow: hidden; 
}

/* 3. The Modal Drawer */
.gpf-modal {
    position: fixed;
    top: 0; 
    right: 0;
    transform: translateX(100%);
    width: 100%;
    max-width: 380px;
    height: 100vh;
    height: 100dvh;
    background: var(--gpf-bg);
    z-index: 999999;
    box-shadow: -10px 0 40px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    font-family: var(--gpf-font);
}

body.gpf-modal-open .gpf-modal {
    transform: translateX(0);
}

/* 4. Modal Header */
.gpf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gpf-border);
}

.gpf-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gpf-text);
}

.gpf-close-btn {
    background: var(--gpf-surface);
    border: 1px solid var(--gpf-border);
    color: var(--gpf-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin-right: -5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.gpf-close-btn svg {
    width: 24px;
    height: 24px;
}

.gpf-close-btn:hover {
    background: var(--gpf-border);
    transform: scale(1.05);
}

/* 5. Modal Body & Filter Groups */
.gpf-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.gpf-filter-group {
    margin-bottom: 32px;
}

.gpf-filter-group:last-child {
    margin-bottom: 0;
}

.gpf-filter-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gpf-text);
    margin: 0 0 16px 0;
    letter-spacing: 0.5px;
}

.gpf-filter-options input[type="checkbox"] {
    display: none !important;
}

.gpf-term-label {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gpf-text-light);
    transition: color 0.2s ease;
}

.gpf-term-label:hover {
    color: var(--gpf-text);
}

/* 6. Product Search Bar & Internal Category Search */
.gpf-product-search {
    position: relative;
    margin-bottom: 20px;
}

.gpf-product-search input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--gpf-border);
    border-radius: var(--gpf-radius);
    background: var(--gpf-surface);
    font-size: 14px;
    color: var(--gpf-text);
}

.gpf-product-search input:focus {
    outline: none;
    border-color: var(--gpf-accent);
}

.gpf-product-search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

/* Fix Search Bar icon padding */
.gpf-product-search input {
padding-left: 40px !important;
}
.gpf-product-search svg {
left: 14px;
}

.gpf-term-search-input {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--gpf-border);
    border-radius: var(--gpf-radius);
    font-size: 13px;
    background: #ffffff;
}

.gpf-term-scroll-list {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 5px;
}

.gpf-term-scroll-list::-webkit-scrollbar {
    width: 4px;
}

.gpf-term-scroll-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* 7. Checkboxes */
.gpf-checkbox-custom {
    width: 18px;
    height: 18px;
    border: 1px solid #cbd5e1;
    border-radius: var(--gpf-radius);
    margin-right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: transparent;
}

input[type="checkbox"]:checked + .gpf-checkbox-custom {
    background-color: var(--gpf-accent);
    border-color: var(--gpf-accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

input[type="checkbox"]:checked ~ .gpf-term-name {
    color: var(--gpf-text);
    font-weight: 500;
}

.gpf-count {
    color: #94a3b8;
    font-size: 13px;
    margin-left: 4px;
}

/* 8. Swatches */
.gpf-style-swatch {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.gpf-style-swatch .gpf-term-label {
    margin: 0;
}

.gpf-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--gpf-radius);
    border: 1px solid var(--gpf-border);
    box-shadow: inset 0 0 0 2px #fff;
    transition: all 0.2s ease;
}

input[type="checkbox"]:checked + .gpf-swatch {
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--gpf-accent);
    border-color: var(--gpf-accent);
}

/* 9. Pill Buttons */
.gpf-style-button {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.gpf-style-button .gpf-term-label {
    margin: 0;
}

.gpf-pill {
    padding: 8px 16px;
    border: 1px solid var(--gpf-border);
    border-radius: var(--gpf-radius);
    font-size: 13px;
    color: var(--gpf-text-light);
    transition: all 0.2s ease;
    background: var(--gpf-bg);
}

input[type="checkbox"]:checked + .gpf-pill {
    background: var(--gpf-accent);
    border-color: var(--gpf-accent);
    color: #ffffff;
}

/* 10. Brand Logos */
.gpf-brand-label {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.gpf-brand-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: var(--gpf-radius);
    border: 1px solid var(--gpf-border);
    background: #ffffff;
    padding: 2px;
    margin-right: 12px;
}

.gpf-brand-placeholder {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--gpf-radius);
    background: #f1f5f9;
    border: 1px solid var(--gpf-border);
    margin-right: 12px;
    font-weight: 600;
    color: var(--gpf-text-light);
    font-size: 14px;
}

/* 11. Price Slider & Manual Inputs */
.gpf-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.gpf-input-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--gpf-surface);
    border: 1px solid var(--gpf-border);
    border-radius: var(--gpf-radius);
    padding: 8px 12px;
}

.gpf-currency {
    color: var(--gpf-text-light);
    font-size: 13px;
    margin-right: 4px;
}

.gpf-input-box input[type="number"] {
    width: 100%;
    border: none !important;
    background: transparent !important;
    font-size: 14px !important;
    color: var(--gpf-text) !important;
    padding: 0 !important;
    box-shadow: none !important;
    -moz-appearance: textfield;
}

.gpf-input-box input[type="number"]::-webkit-outer-spin-button,
.gpf-input-box input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.gpf-input-box input[type="number"]:focus {
    outline: none !important;
}

.gpf-to {
    font-size: 13px;
    color: var(--gpf-text-light);
    font-weight: 500;
}

.gpf-slider-track {
    position: relative;
    height: 24px;
    margin-bottom: 10px;
}

.gpf-slider-track::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gpf-border);
    border-radius: 2px;
}

.gpf-slider-track input[type="range"] {
    position: absolute;
    width: 100%;
    top: 3px;
    pointer-events: none;
    -webkit-appearance: none;
    background: transparent;
    margin: 0;
}

.gpf-slider-track input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--gpf-accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 12. Modal Footer */
.gpf-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--gpf-border);
    background: var(--gpf-surface);
}

.gpf-clear-btn, .gpf-apply-btn {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: var(--gpf-radius);
    cursor: pointer;
    transition: all 0.3s ease;
}

.gpf-clear-btn {
    background: transparent;
    border: 1px solid var(--gpf-border);
    color: var(--gpf-text-light);
}

.gpf-clear-btn:hover {
    background: #e2e8f0;
    color: var(--gpf-text);
}

.gpf-apply-btn {
    background: var(--gpf-accent);
    border: 1px solid var(--gpf-accent);
    color: #ffffff;
}

.gpf-apply-btn:hover {
    filter: brightness(0.9);
}