/**
 * Modern Product Filters Styling
 * All classes use 'pf-' prefix to avoid conflicts
 * Apple-inspired clean design with slide-in drawer
 * 
 * IMPORTANT: Does NOT interfere with JavaScript - all old class names preserved
 */

/* Filter Toggle Button - Floating bottom left, aligned with content */
.pf-drawer-toggle {
    position: fixed;
    bottom: 20px;
    left: 320px; /* 300px sidebar + 20px spacing */
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pf-drawer-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pf-drawer-toggle:active {
    transform: translateY(0);
}

.pf-drawer-toggle i {
    color: #6b7280;
    font-size: 16px;
}

/* Active filter badge */
.pf-filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #3b82f6;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.4);
}

/* Filter Drawer - Optimized for smooth mobile performance */
.pf-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    max-width: 90vw;
    height: 100%;
    background: #f5f5f7;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 122, 255, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(88, 86, 214, 0.02) 0%, transparent 50%);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translate3d(100%, 0, 0); /* GPU acceleration */
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    will-change: transform;
    -webkit-transform: translate3d(100%, 0, 0);
    -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pf-drawer.pf-drawer-open {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

/* Drawer Header */
.pf-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid #e5e5e7;
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.pf-drawer-title {
    font-size: 22px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

.pf-drawer-title i {
    color: #007AFF;
    font-size: 20px;
}

.pf-drawer-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f5f5f7;
    color: #1d1d1f;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.pf-drawer-close:hover {
    background: #007AFF;
    color: #fff;
    transform: rotate(90deg);
}

.pf-drawer-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Drawer Content */
.pf-drawer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding: 16px;
    background: transparent;
    min-height: 0; /* Important for flex scrolling */
}

.pf-drawer-content::-webkit-scrollbar {
    width: 8px;
}

.pf-drawer-content::-webkit-scrollbar-track {
    background: #f5f5f7;
}

.pf-drawer-content::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 4px;
}

.pf-drawer-content::-webkit-scrollbar-thumb:hover {
    background: #86868b;
}

/* Drawer Overlay - Optimized for mobile performance */
.pf-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    z-index: 9999;
    -webkit-tap-highlight-color: transparent;
}

.pf-drawer-overlay.pf-overlay-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

/* Ensure filters stack vertically inside drawer */
.pf-drawer .productFilters {
    display: block !important;
    width: 100% !important;
}

/* Reset All Filters (Top) */
.pf-reset-all {
    margin-bottom: 20px;
    text-align: center;
}

.pf-reset-all .pf-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #ff3b30;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.pf-reset-all .pf-reset-btn:hover {
    background: #d62828;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 59, 48, 0.4);
    text-decoration: none;
}

.pf-reset-all .pf-reset-btn:active {
    transform: translateY(0);
}

.pf-reset-all .pf-reset-btn i {
    font-size: 16px;
}

.pf-reset-all .pf-reset-btn span {
    font-weight: 600;
}

/* Filter Section */
.pf-section {
    background: #fff;
    margin-bottom: 8px;
    overflow: visible;
    transition: all 0.2s ease;
    width: 100%;
    display: block;
    position: relative;
    border-radius: 12px;
    border: 1px solid #e5e5e7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Highlight sections with active filters */
.pf-section:has(.pf-active-badge) {
    border-color: rgba(0, 122, 255, 0.3);
    box-shadow: 0 1px 4px rgba(0, 122, 255, 0.12);
}

.pf-section:hover {
    border-color: #d1d1d6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.pf-section:has(.pf-active-badge):hover {
    border-color: rgba(0, 122, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

/* Filter Header - MUST be clickable */
.pf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: background 0.15s ease;
    position: relative;
    z-index: 1;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* Prevents delay on mobile */
}

.pf-header:hover {
    background: #fafafa;
}

.pf-section.pf-open .pf-header,
.pf-section.open .pf-header {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.04) 0%, rgba(88, 86, 214, 0.04) 100%);
    border-radius: 12px 12px 0 0;
}

.pf-header * {
    pointer-events: none; /* Ensure clicks go to the header */
}

.pf-header-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
}

.pf-icon {
    font-size: 16px;
    color: #007AFF;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.pf-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.pf-title {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.pf-current {
    font-size: 12px;
    color: #6e6e73;
    font-weight: 400;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pf-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.pf-active-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #007AFF;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
}

/* Header Reset Button */
.pf-header-reset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #86868b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
    pointer-events: all !important; /* Override parent pointer-events: none */
    z-index: 10;
    position: relative;
}

.pf-header-reset:hover {
    background: #f5f5f7;
    color: #ff3b30;
    transform: rotate(90deg);
}

.pf-header-reset:active {
    background: #e5e5e7;
    transform: rotate(90deg) scale(0.9);
}

.pf-chevron {
    font-size: 12px;
    color: #86868b;
    transition: transform 0.3s ease;
}

.pf-section.pf-open .pf-chevron,
.pf-section.open .pf-chevron {
    transform: rotate(180deg);
}

/* Filter Content - Let jQuery handle display toggling */
.pf-content {
    padding: 14px 16px 16px;
    background: #fff;
    position: relative;
    overflow: visible;
    border-radius: 0 0 12px 12px;
    border-top: 1px solid #f0f0f0;
}

/* Search Box */
.pf-search-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.pf-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #86868b;
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}

.pf-search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: #f5f5f7;
    transition: all 0.2s ease;
    height: auto;
    line-height: normal;
    position: relative;
}

.pf-search-input:focus {
    outline: none;
    background: #fff;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.pf-search-input::placeholder {
    color: #86868b;
}

/* Filter Chips */
.pf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.pf-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #007AFF;
    color: #fff;
    border: 1px solid #007AFF;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pf-chip-label {
    line-height: 1;
}

.pf-chip-remove {
    cursor: pointer;
    opacity: 0.8;
    font-size: 12px;
    transition: opacity 0.2s ease;
    pointer-events: all;
}

.pf-chip-remove:hover {
    opacity: 1;
}

/* Filter Options List */
.pf-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 300px;
    overflow-y: auto;
}

/* Custom Scrollbar */
.pf-options::-webkit-scrollbar {
    width: 6px;
}

.pf-options::-webkit-scrollbar-track {
    background: #f5f5f7;
    border-radius: 3px;
}

.pf-options::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 3px;
}

.pf-options::-webkit-scrollbar-thumb:hover {
    background: #86868b;
}

/* Individual Option */
.pf-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
    margin-bottom: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pf-option input {
    display: none;
}

.pf-option:hover {
    background: #f5f5f7;
}

.pf-option.pf-checked {
    background: rgba(0, 122, 255, 0.08);
}

.pf-option.pf-checked:hover {
    background: rgba(0, 122, 255, 0.12);
}

.pf-option.pf-checked .pf-label {
    color: #007AFF;
    font-weight: 600;
}

.pf-checkbox-icon {
    font-size: 18px;
    color: #007AFF;
    margin-right: 12px;
    transition: all 0.2s ease;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.pf-checkbox-icon.fa-square,
.pf-checkbox-icon.fa-circle {
    color: #d1d1d6;
}

.pf-label {
    font-size: 14px;
    color: #1d1d1f;
    flex: 1;
    line-height: 1.4;
}

.pf-count {
    font-size: 12px;
    color: #86868b;
    font-weight: 500;
    background: #f5f5f7;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Rating Stars - Apple aesthetic */
.pf-stars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    line-height: 1;
}

.pf-stars i {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0;
}

.pf-stars .fas.fa-star {
    color: #FF9500 !important;
}

.pf-stars .far.fa-star {
    color: #d1d1d6 !important;
}

.pf-star-text {
    margin-left: 10px;
    font-size: 14px;
    color: #1d1d1f;
    font-weight: 500;
}

/* Make sure rating options align nicely */
.pf-option .pf-label:has(.pf-stars) {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Price Range - Modern Preset + Custom Input Design */
.pf-price-range {
    padding: 0;
}

/* Preset Price Buttons */
.pf-price-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.pf-price-preset {
    padding: 10px 14px;
    background: #fff;
    border: 2px solid #e5e5e7;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: 'Inter', sans-serif;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.pf-price-preset:hover {
    border-color: #007AFF;
    background: #fafafa;
}

.pf-price-preset.pf-preset-active {
    background: #007AFF;
    color: #fff;
    border-color: #007AFF;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* Custom Price Inputs */
.pf-price-custom {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e7;
}

.pf-price-custom-label {
    font-size: 11px;
    color: #86868b;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pf-price-inputs {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px;
}

.pf-price-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pf-input-label {
    font-size: 11px;
    color: #86868b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pf-price-input {
    width: 100%;
    padding: 9px 11px;
    border: 2px solid #e5e5e7;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    background: #fff;
}

.pf-price-input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.pf-input-separator {
    font-size: 18px;
    color: #d1d1d6;
    font-weight: 300;
    padding-bottom: 9px;
    flex-shrink: 0;
}

.pf-price-apply {
    width: 100%;
    padding: 10px;
    background: #007AFF;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 3px 8px rgba(0, 122, 255, 0.3);
}

.pf-price-apply:hover {
    background: #0051D5;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.pf-price-apply:active {
    transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    /* On tablet/mobile, move button to left edge */
    .pf-drawer-toggle {
        left: 20px;
    }
    
    .pf-drawer {
        width: 100%;
        max-width: 100vw;
    }
    
    .pf-drawer-content {
        padding: 20px;
        overflow-y: scroll; /* Force scrollbar on mobile */
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .pf-drawer-toggle {
        left: 50%;
        transform: translateX(-50%);
        bottom: 16px;
        padding: 12px 20px;
    }
    
    .pf-drawer-toggle:hover {
        transform: translateX(-50%) translateY(-1px);
    }
    
    .pf-drawer-toggle:active {
        transform: translateX(-50%) translateY(0);
    }
    
    .pf-drawer-header {
        padding: 18px 20px;
    }
    
    .pf-drawer-title {
        font-size: 19px;
    }
    
    .pf-drawer-content {
        padding: 16px;
    }
    
    .pf-section {
        margin-bottom: 12px;
    }
    
    .pf-header {
        padding: 14px 16px;
    }
    
    .pf-content {
        padding: 16px;
    }
    
    .pf-option {
        padding: 10px 12px;
    }
    
    /* Keep price inputs horizontal on mobile - just make them smaller */
    .pf-price-presets {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .pf-price-preset {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .pf-price-inputs {
        gap: 8px;
    }
    
    .pf-price-input-group {
        flex: 1;
    }
    
    .pf-price-input {
        padding: 10px;
        font-size: 15px;
    }
    
    .pf-input-label {
        font-size: 10px;
    }
    
    .pf-input-separator {
        font-size: 16px;
        padding-bottom: 10px;
    }
    
    .pf-price-custom-label {
        font-size: 10px;
    }
    
    .pf-price-apply {
        padding: 12px;
        font-size: 14px;
    }
}

/* Accessibility */
.pf-option:focus-within {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

.pf-header:focus {
    outline: 2px solid #007AFF;
    outline-offset: -2px;
}

/* Disable hover effects on touch devices to prevent double-tap issue */
@media (hover: none) and (pointer: coarse) {
    .pf-drawer-toggle:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .pf-section:hover {
        border-color: #e5e5e7;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
        transform: none;
    }
    
    .pf-header:hover {
        background: #fff;
    }
    
    .pf-option:hover {
        background: transparent;
    }
    
    .pf-price-preset:hover {
        border-color: #e5e5e7;
        background: #fff;
    }
    
    .pf-price-apply:hover {
        background: #007AFF;
        transform: none;
        box-shadow: 0 3px 8px rgba(0, 122, 255, 0.3);
    }
    
    .pf-header-reset:hover {
        background: transparent;
        color: #86868b;
        transform: none;
    }
    
    .pf-drawer-close:hover {
        background: #f5f5f7;
        color: #1d1d1f;
        transform: none;
    }
    
    .pf-section-reset .pf-reset-btn:hover {
        background: transparent;
        color: #86868b;
        transform: none;
    }
}
