/**
 * Mobile Filters (Bottom Sheet)
 * Touch-optimized filter system
 */

:root {
    --filter-sheet-bg: #ffffff;
    --filter-text-color: #333333;
    --filter-border-color: #e0e0e0;
    --filter-accent-color: #d32f2f;
    --filter-button-bg: #f8f9fa;
}

/* Filter Button (Sticky) */
.mobile-filter-button {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--filter-accent-color);
    color: #ffffff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
    cursor: pointer;
    z-index: 998;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Button Position Variants */
.mobile-filter-button.mobile-filter-bottom-left {
    right: auto;
    left: 16px;
}

.mobile-filter-button.mobile-filter-top-right {
    bottom: auto;
    top: 80px;
}

.mobile-filter-button.mobile-filter-bottom-right {
    bottom: 80px;
    right: 16px;
}

@media (max-width: 768px) {
    .mobile-filter-button {
        display: flex;
    }
}

.mobile-filter-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(211, 47, 47, 0.4);
}

.mobile-filter-button svg {
    width: 20px;
    height: 20px;
}

.filter-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ffffff;
    color: var(--filter-accent-color);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

/* Filter Sheet */
.mobile-filter-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-filter-sheet.active {
    opacity: 1;
    visibility: visible;
}

/* Overlay */
.filter-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Content */
.filter-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: var(--filter-sheet-bg);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.mobile-filter-sheet.active .filter-sheet-content {
    transform: translateY(0);
}

/* Header */
.filter-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--filter-border-color);
    flex-shrink: 0;
}

.filter-sheet-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--filter-text-color);
}

.filter-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--filter-text-color);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.filter-sheet-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Active Filter Tags */
.filter-active-tags {
    padding: 12px 20px;
    border-bottom: 1px solid var(--filter-border-color);
    display: none;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-active-tags.has-filters {
    display: flex;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--filter-button-bg);
    border-radius: 16px;
    font-size: 13px;
    color: var(--filter-text-color);
}

.filter-tag-remove {
    display: flex;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    color: #999999;
    cursor: pointer;
}

/* Body */
.filter-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Filter Section */
.filter-section {
    margin-bottom: 24px;
}

.filter-section-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--filter-text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--filter-button-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 44px;
}

.filter-option:hover {
    background: #e9ecef;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

.filter-option span {
    font-size: 14px;
    color: var(--filter-text-color);
}

/* Price Range */
.filter-price-range {
    padding: 12px;
    background: var(--filter-button-bg);
    border-radius: 8px;
}

.price-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.price-input-min,
.price-input-max {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--filter-border-color);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.price-separator {
    color: var(--filter-text-color);
    font-weight: 600;
}

input[type="range"].price-range-slider {
    width: 100%;
    height: 6px;
    min-height: 6px;
    border-radius: 3px;
    background: var(--filter-border-color);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 12px;
}

.price-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--filter-accent-color);
    cursor: pointer;
}

.price-range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--filter-accent-color);
    cursor: pointer;
    border: none;
}

.price-range-values {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--filter-text-color);
}

/* Rating Stars */
.rating-stars {
    font-size: 16px;
    color: #ffc107;
}

/* Footer */
.filter-sheet-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--filter-border-color);
    flex-shrink: 0;
}

.filter-clear-all,
.filter-apply {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
}

.filter-clear-all {
    background: var(--filter-button-bg);
    color: var(--filter-text-color);
}

.filter-clear-all:hover {
    background: #e9ecef;
}

.filter-apply {
    background: var(--filter-accent-color);
    color: #ffffff;
}

.filter-apply:hover {
    background: #b71c1c;
}

/* Loading State */
.filter-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* Safe area insets */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .filter-sheet-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Loading States */
.filter-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.filter-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--filter-border-color);
    border-top-color: var(--filter-accent-color);
    border-radius: 50%;
    animation: filterSpin 0.8s linear infinite;
}

@keyframes filterSpin {
    to {
        transform: rotate(360deg);
    }
}

.filter-apply.loading {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.filter-apply.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 16px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: filterSpin 0.6s linear infinite;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mobile-filter-sheet,
    .filter-sheet-content,
    .filter-option,
    .filter-spinner {
        animation: none;
        transition: none;
    }
}
