/**
 * Premium styles for WC Advanced Filter Pro
 *
 * @package WCAFE_Pro
 */

/* Price Range Slider */
.wcafe-price-range {
    padding: 15px 0;
}

.wcafe-price-slider {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin: 0 8px 20px;
    position: relative;
}

.wcafe-price-slider .ui-slider-range {
    background: #333;
    height: 100%;
    border-radius: 4px;
    position: absolute;
}

.wcafe-price-slider .ui-slider-handle {
    width: 20px;
    height: 20px;
    background: #333;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin-left: -10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    outline: none;
    transition: transform 0.1s ease;
}

.wcafe-price-slider .ui-slider-handle:hover,
.wcafe-price-slider .ui-slider-handle:focus {
    transform: translateY(-50%) scale(1.1);
}

.wcafe-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcafe-price-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.wcafe-price-input-wrap .wcafe-currency {
    padding: 0 10px;
    color: #666;
    font-weight: 500;
}

.wcafe-price-input {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    -moz-appearance: textfield;
}

.wcafe-price-input::-webkit-outer-spin-button,
.wcafe-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wcafe-price-separator {
    color: #999;
    font-weight: 500;
}

/* Toggle Filter (On Sale, Featured) */
.wcafe-toggle-filter {
    padding: 10px 0;
}

.wcafe-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.wcafe-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wcafe-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    margin-right: 12px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.wcafe-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wcafe-toggle-input:checked + .wcafe-toggle-slider {
    background: #333;
}

.wcafe-toggle-input:checked + .wcafe-toggle-slider::before {
    transform: translateX(20px);
}

.wcafe-toggle-label {
    font-size: 14px;
    color: #333;
}

/* Rating Filter Stars */
.wcafe-filter-buttons[data-filter-type="rating"] .wcafe-filter-button {
    font-size: 16px;
    letter-spacing: 2px;
}

.wcafe-filter-buttons[data-filter-type="rating"] .wcafe-filter-button .stars {
    color: #ffb900;
}

/* Stock Status Colors */
.wcafe-filter-button[data-value="instock"] {
    border-color: #4caf50;
}

.wcafe-filter-button[data-value="instock"].active {
    background: #4caf50;
    border-color: #4caf50;
}

.wcafe-filter-button[data-value="outofstock"] {
    border-color: #f44336;
}

.wcafe-filter-button[data-value="outofstock"].active {
    background: #f44336;
    border-color: #f44336;
}

.wcafe-filter-button[data-value="onbackorder"] {
    border-color: #ff9800;
}

.wcafe-filter-button[data-value="onbackorder"].active {
    background: #ff9800;
    border-color: #ff9800;
}

/* Animation for filter changes */
.wcafe-filter-widget.wcafe-animating .wcafe-filter-button,
.wcafe-filter-widget.wcafe-animating .wcafe-checkbox-item,
.wcafe-filter-widget.wcafe-animating .wcafe-toggle-slider {
    transition: all 0.2s ease;
}

/* Off-Canvas Overlay */
/* Keep inside widget container for Elementor {{WRAPPER}} selectors to work */
.wcafe-offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--wcafe-offcanvas-duration, 400ms) ease,
                visibility var(--wcafe-offcanvas-duration, 400ms) ease;
    /* Ensure overlay covers entire viewport even when inside widget container */
    margin: 0;
    padding: 0;
}

.wcafe-offcanvas-overlay.wcafe-offcanvas-active {
    opacity: 1;
    visibility: visible;
}

/* Elementor Editor - Off-canvas should only be visible when explicitly opened */
/* No forced visibility - it should work exactly like frontend */

/* Off-Canvas Container */
/* Keep inside widget container for Elementor {{WRAPPER}} selectors to work */
/* position: fixed works relative to viewport, not parent, so it will work correctly */
.wcafe-offcanvas-container {
    position: fixed !important;
    z-index: 99999 !important;
    background: #fff;
    overflow: visible; /* Allow close button to extend outside */
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: transform var(--wcafe-offcanvas-duration, 400ms) ease,
                opacity var(--wcafe-offcanvas-duration, 400ms) ease,
                visibility var(--wcafe-offcanvas-duration, 400ms) ease;
    display: flex;
    flex-direction: column;
    /* Ensure container is positioned relative to viewport, not parent */
    margin: 0;
    padding: 0;
}

.wcafe-offcanvas-container.wcafe-offcanvas-active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Position Styles - Left */
.wcafe-offcanvas-container.wcafe-offcanvas-position-left,
.wcafe-offcanvas-container.wcafe-offcanvas-left {
    top: 0;
    left: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    transform: translateX(-100%);
}

.wcafe-offcanvas-container.wcafe-offcanvas-position-left.wcafe-offcanvas-active,
.wcafe-offcanvas-container.wcafe-offcanvas-left.wcafe-offcanvas-active {
    transform: translateX(0);
}

/* Position Styles - Right */
.wcafe-offcanvas-container.wcafe-offcanvas-position-right,
.wcafe-offcanvas-container.wcafe-offcanvas-right {
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    transform: translateX(100%);
}

.wcafe-offcanvas-container.wcafe-offcanvas-position-right.wcafe-offcanvas-active,
.wcafe-offcanvas-container.wcafe-offcanvas-right.wcafe-offcanvas-active {
    transform: translateX(0);
}

/* Position Styles - Top */
.wcafe-offcanvas-container.wcafe-offcanvas-position-top,
.wcafe-offcanvas-container.wcafe-offcanvas-top {
    top: 0;
    left: 0;
    right: 0;
    height: 50vh;
    max-height: 90vh;
    transform: translateY(-100%);
}

.wcafe-offcanvas-container.wcafe-offcanvas-position-top.wcafe-offcanvas-active,
.wcafe-offcanvas-container.wcafe-offcanvas-top.wcafe-offcanvas-active {
    transform: translateY(0);
}

/* Position Styles - Bottom */
.wcafe-offcanvas-container.wcafe-offcanvas-position-bottom,
.wcafe-offcanvas-container.wcafe-offcanvas-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 50vh;
    max-height: 90vh;
    transform: translateY(100%);
}

.wcafe-offcanvas-container.wcafe-offcanvas-position-bottom.wcafe-offcanvas-active,
.wcafe-offcanvas-container.wcafe-offcanvas-bottom.wcafe-offcanvas-active {
    transform: translateY(0);
}

/* Animation - Fade */
.wcafe-offcanvas-container.wcafe-offcanvas-animation-fade {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    opacity: 0;
    visibility: hidden;
    border-radius: 8px;
}

.wcafe-offcanvas-container.wcafe-offcanvas-animation-fade.wcafe-offcanvas-active {
    opacity: 1;
    visibility: visible;
}

/* Animation - Zoom */
.wcafe-offcanvas-container.wcafe-offcanvas-animation-zoom {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    opacity: 0;
    visibility: hidden;
    border-radius: 8px;
}

.wcafe-offcanvas-container.wcafe-offcanvas-animation-zoom.wcafe-offcanvas-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Animation - Flip */
.wcafe-offcanvas-container.wcafe-offcanvas-animation-flip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) perspective(1000px) rotateY(-90deg);
    width: 500px;
    max-width: 90vw;
    max-height: 90vh;
    opacity: 0;
    visibility: hidden;
    border-radius: 8px;
}

.wcafe-offcanvas-container.wcafe-offcanvas-animation-flip.wcafe-offcanvas-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) perspective(1000px) rotateY(0);
}

/* Off-Canvas Inner Layout */
.wcafe-offcanvas-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    overflow: hidden; /* Contain scrolling to content area */
}

/* Off-Canvas Header */
.wcafe-offcanvas-header {
    flex-shrink: 0;
    padding: 30px 30px 20px;
    background: #fff;
}

.wcafe-offcanvas-title {
    font-size: 24px;
    font-weight: 400;
    color: #333;
    margin: 0;
    font-family: inherit;
}

/* Off-Canvas Close Button - White Circle with Black X, Inside Container */
.wcafe-offcanvas-close {
    position: absolute;
    z-index: 100001;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important; /* Ensure touch target size */
    min-height: 40px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
    pointer-events: auto !important; /* Ensure clickable */
    transition: all 0.3s ease;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); /* Mobile tap highlight */
}

/* Show close button when container is active */
.wcafe-offcanvas-container.wcafe-offcanvas-active .wcafe-offcanvas-close {
    opacity: 1;
    visibility: visible;
}

/* Default position */
.wcafe-offcanvas-close {
    top: 15px;
    left: -50px;
    right: auto;
}

/* For right-side panels, close button on left edge */
.wcafe-offcanvas-position-right .wcafe-offcanvas-close,
.wcafe-offcanvas-right .wcafe-offcanvas-close {
    top: 15px;
    left: -50px;
    right: auto;
}

/* For left-side panels, close button on right edge */
.wcafe-offcanvas-position-left .wcafe-offcanvas-close,
.wcafe-offcanvas-left .wcafe-offcanvas-close {
    top: -24px;
    left: auto;
    right: -24px;
}

/* For top panels, close button on bottom edge */
.wcafe-offcanvas-position-top .wcafe-offcanvas-close,
.wcafe-offcanvas-top .wcafe-offcanvas-close {
    top: auto;
    bottom: -24px;
    left: 30px;
    right: auto;
}

/* For bottom panels, close button on top edge */
.wcafe-offcanvas-position-bottom .wcafe-offcanvas-close,
.wcafe-offcanvas-bottom .wcafe-offcanvas-close {
    top: -24px;
    bottom: auto;
    left: 30px;
    right: auto;
}

.wcafe-offcanvas-close:hover {
    background: #f5f5f5;
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.wcafe-offcanvas-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}

/* Off-Canvas Content - Scrollable Area */
.wcafe-offcanvas-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 30px 30px;
}

/* Off-Canvas Footer - Fixed at Bottom */
.wcafe-offcanvas-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px 30px 30px;
     background: #F3F2E7;
    border-top: 0px solid #eee;
}

.wcafe-offcanvas-footer .wcafe-apply-filters {
    width: 100%;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wcafe-offcanvas-footer .wcafe-clear-filters {
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: transparent;
    border: none;
    color: #333;
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wcafe-offcanvas-footer .wcafe-clear-filters:hover {
    color: #000;
}

/* Filter groups inside off-canvas */
.wcafe-offcanvas-content .wcafe-filter-group {
    margin-bottom: 25px;
}

.wcafe-offcanvas-content .wcafe-filter-group:last-child {
    margin-bottom: 0;
}

.wcafe-offcanvas-content .wcafe-filter-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #333;
    margin-bottom: 12px;
}

/* Category grouping label in off-canvas (like ORIGIN, TEA in design) */
.wcafe-offcanvas-content .wcafe-filter-category-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #666;
    margin: 30px 0 15px;
    padding-bottom: 5px;
}

.wcafe-offcanvas-content .wcafe-filter-category-label:first-child {
    margin-top: 0;
}

/* Body scroll lock when off-canvas is open */
body.wcafe-offcanvas-open {
    overflow: hidden;
}

/* Tablet and smaller - ensure close button is visible */
@media screen and (max-width: 1024px) {
    /* For right-side panels on tablet, position close button inside if it would be cut off */
    .wcafe-offcanvas-position-right .wcafe-offcanvas-close,
    .wcafe-offcanvas-right .wcafe-offcanvas-close {
        /* If left: -50px would be off-screen, position inside instead */
        left: auto !important;
        right: 15px !important;
    }
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .wcafe-price-inputs {
        flex-direction: column;
    }

    .wcafe-price-input-wrap {
        width: 100%;
    }

    .wcafe-price-separator {
        display: none;
    }
    
    /* Off-canvas responsive */
    .wcafe-offcanvas-container.wcafe-offcanvas-position-left,
    .wcafe-offcanvas-container.wcafe-offcanvas-position-right,
    .wcafe-offcanvas-container.wcafe-offcanvas-left,
    .wcafe-offcanvas-container.wcafe-offcanvas-right {
        width: 100%;
        max-width: 100vw;
    }
    
    .wcafe-offcanvas-container.wcafe-offcanvas-animation-fade,
    .wcafe-offcanvas-container.wcafe-offcanvas-animation-zoom,
    .wcafe-offcanvas-container.wcafe-offcanvas-animation-flip {
        width: 95%;
        max-width: 95vw;
    }
    
    /* Close button on mobile - position inside panel for better visibility and touch-friendly size */
    .wcafe-offcanvas-close {
        top: 15px !important;
        left: auto !important;
        right: 15px !important;
        width: 44px !important; /* Slightly larger for better touch target */
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    
    /* For right-side panels on mobile, position inside top-right */
    .wcafe-offcanvas-position-right .wcafe-offcanvas-close,
    .wcafe-offcanvas-right .wcafe-offcanvas-close {
        top: 15px !important;
        left: auto !important;
        right: 15px !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* For left-side panels on mobile, position inside top-left */
    .wcafe-offcanvas-position-left .wcafe-offcanvas-close,
    .wcafe-offcanvas-left .wcafe-offcanvas-close {
        top: 15px !important;
        left: 15px !important;
        right: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* For top panels on mobile */
    .wcafe-offcanvas-position-top .wcafe-offcanvas-close,
    .wcafe-offcanvas-top .wcafe-offcanvas-close {
        top: auto !important;
        bottom: 15px !important;
        left: auto !important;
        right: 15px !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* For bottom panels on mobile */
    .wcafe-offcanvas-position-bottom .wcafe-offcanvas-close,
    .wcafe-offcanvas-bottom .wcafe-offcanvas-close {
        top: 15px !important;
        bottom: auto !important;
        left: auto !important;
        right: 15px !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Adjust header/footer padding on mobile */
    .wcafe-offcanvas-header {
        padding: 20px;
    }
    
    .wcafe-offcanvas-content {
        padding: 0 20px 20px;
    }
    
    .wcafe-offcanvas-footer {
        padding: 15px 20px 20px;
    }
    
    /* Larger SVG icon on mobile for better visibility */
    .wcafe-offcanvas-close svg {
        width: 22px !important;
        height: 22px !important;
    }
}

