/* FIXED: Mobile Touch Event CSS for PGE Filters */

/* Filter Header - Enhanced for mobile touch */
.pge-filter-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: #fafafa;
    cursor: pointer;
    position: relative;
    /* FIXED: Ensure proper touch target size */
    min-height: 44px; /* iOS recommended touch target */
    /* FIXED: Prevent text selection on touch */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* FIXED: Improve touch responsiveness */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* FIXED: Active state for touch feedback */
.pge-filter-header:active {
    background: #f0f0f0;
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* Filter Content Transitions - FIXED for better mobile performance */
.pge-filter-content {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
    /* FIXED: Use transform instead of max-height for smoother animations */
    transform: scaleY(1);
    transform-origin: top;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

.pge-filter-section.collapsed .pge-filter-content {
    /* FIXED: Better collapse animation */
    transform: scaleY(0);
    opacity: 0;
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
}

/* Tag Filters - FIXED transitions */
.pge-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px 20px;
    transform: scaleY(1);
    transform-origin: top;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

.pge-filter-section.collapsed .pge-filter-tags {
    transform: scaleY(0);
    opacity: 0;
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
}

/* Clear buttons - FIXED touch targets */
.pge-filter-clear,
.pge-clear-all,
.pge-active-filter-remove {
    /* FIXED: Ensure proper touch target size */
    min-height: 44px;
    min-width: 44px;
    /* FIXED: Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* FIXED: Improve touch responsiveness */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* Filter Items - FIXED for better touch interaction */
.pge-filter-item {
    display: flex;
    align-items: center;
    padding: 12px 0; /* Increased for better touch targets */
    cursor: pointer;
    transition: background 0.2s;
    /* FIXED: Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* FIXED: Better touch targets */
    min-height: 44px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
    touch-action: manipulation;
}

.pge-filter-item:hover,
.pge-filter-item:active {
    background: #f8f8f8;
    margin: 0 -10px;
    padding: 12px 10px; /* Consistent with increased padding */
}

/* Filter Tags - FIXED touch interaction */
.pge-filter-tag {
    display: inline-block;
    cursor: pointer;
    /* FIXED: Better touch interaction */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

.pge-tag-label {
    display: inline-block;
    padding: 8px 16px; /* Increased for better touch targets */
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    color: #666;
    transition: all 0.2s;
    /* FIXED: Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* FIXED: Better touch targets */
    min-height: 36px;
    line-height: 1.4;
}

/* FIXED: Active states for better feedback */
.pge-filter-tag:active .pge-tag-label {
    transform: scale(0.95);
    background: #e0e0e0;
}

/* Responsive - ENHANCED mobile fixes */
@media (max-width: 768px) {
    .pge-active-filters {
        padding: 12px 15px;
    }
    
    .pge-active-filters-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .pge-filter-header {
        padding: 15px 15px; /* Better touch spacing */
        /* FIXED: Ensure full-width touch area */
        margin: 0 -5px;
        padding: 15px 20px;
        min-height: 50px; /* Larger touch target on mobile */
    }
    
    .pge-filter-content {
        padding: 15px;
    }
    
    .pge-filter-section.collapsed .pge-filter-content {
        padding: 0 15px;
    }
    
    .pge-filter-tags {
        padding: 12px 15px;
    }
    
    .pge-filter-section.collapsed .pge-filter-tags {
        padding: 0 15px;
    }
    
    /* FIXED: Better mobile spacing for filter items */
    .pge-filter-item {
        padding: 15px 0; /* Even more padding on mobile */
        min-height: 50px;
    }
    
    .pge-filter-item:hover,
    .pge-filter-item:active {
        margin: 0 -15px;
        padding: 15px 15px;
    }
    
    /* FIXED: Better mobile tag sizing */
    .pge-tag-label {
        padding: 10px 18px;
        min-height: 40px;
        font-size: 14px;
    }
    
    /* FIXED: Clear button positioning on mobile */
    .pge-filter-clear {
        position: relative; /* Changed from absolute for better mobile layout */
        margin-left: auto;
        margin-right: 10px;
    }
}

/* FIXED: Prevent iOS bounce scrolling issues */
@media (max-width: 768px) {
    .pge-filter-content {
        -webkit-overflow-scrolling: touch;
        /* FIXED: Prevent momentum scrolling interference */
        overscroll-behavior: contain;
    }
}

/* FIXED: Dark mode support for better touch visibility */
@media (prefers-color-scheme: dark) {
    .pge-filter-header:active {
        background: #2a2a2a;
    }
    
    .pge-filter-item:hover,
    .pge-filter-item:active {
        background: #2a2a2a;
    }
    
    .pge-tag-label {
        background: #2a2a2a;
        border-color: #444;
        color: #ccc;
    }
    
    .pge-filter-tag:active .pge-tag-label {
        background: #1a1a1a;
    }
}

/* FIXED: Focus states for accessibility */
.pge-filter-header:focus,
.pge-filter-item:focus,
.pge-filter-tag:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* FIXED: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .pge-filter-content,
    .pge-filter-tags,
    .pge-filter-header,
    .pge-filter-item,
    .pge-tag-label {
        transition: none !important;
        transform: none !important;
    }
}