/* Mobile Filter Styles */
:root {
    --filter-primary: #ff4757;
    --filter-primary-dark: #e03a48;
    --filter-bg: #ffffff;
    --filter-text: #333333;
    --filter-border: #e0e0e0;
    --filter-shadow: rgba(0, 0, 0, 0.1);
    --filter-chip-bg: #f5f5f5;
    --filter-chip-active: #ff4757;
    --filter-chip-text: #333333;
    --filter-chip-active-text: #ffffff;
    --filter-drawer-width: 85vw;
    --filter-drawer-max-width: 400px;
    --filter-z-index: 1000;
    --filter-transition: 0.3s ease;
    --filter-border-radius: 12px;
}

.dark-mode {
    --filter-bg: #1a1a1a;
    --filter-text: #f1f1f1;
    --filter-border: #444444;
    --filter-shadow: rgba(0, 0, 0, 0.3);
    --filter-chip-bg: #2a2a2a;
    --filter-chip-text: #e0e0e0;
}

/* Desktop Filter (hide on mobile) */
@media (max-width: 768px) {
    .desktop-filter {
        display: none;
    }
}

/* Mobile Filter Button */
.mobile-filter-button {
    position: fixed;
    bottom: 30px; /* Increased from 20px to ensure it's not cut off */
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--filter-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px var(--filter-shadow);
    z-index: 9999; /* Increased z-index to ensure it's above all other elements */
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* Ensure the button is fully visible on page load */
    transform: translateZ(0); /* Force hardware acceleration */
    will-change: transform; /* Optimize for animations */
    visibility: visible !important;
    opacity: 1 !important;
}

.mobile-filter-button:active {
    transform: scale(0.95);
}

.mobile-filter-button i {
    font-size: 20px;
    margin-bottom: 2px;
}

.mobile-filter-button span {
    font-size: 12px;
    font-weight: 500;
}

/* Hide on desktop - more specific and forceful */
@media (min-width: 769px) {
    .mobile-filter-button {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Filter Drawer */
.mobile-filter-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: var(--filter-drawer-width);
    max-width: var(--filter-drawer-max-width);
    height: 100vh;
    background-color: var(--filter-bg);
    box-shadow: -5px 0 15px var(--filter-shadow);
    z-index: calc(var(--filter-z-index) + 10);
    transition: right var(--filter-transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-filter-drawer.open {
    right: 0;
}

/* Filter Header */
.mobile-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--filter-border);
}

.mobile-filter-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--filter-text);
    margin: 0;
}

.close-filter {
    background: none;
    border: none;
    color: var(--filter-text);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-filter:hover {
    background-color: var(--filter-chip-bg);
}

/* Filter Content */
.mobile-filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

.mobile-filter-group {
    margin: 20px 0;
}

.mobile-filter-group h4 {
    font-size: 16px;
    font-weight: 500;
    color: var(--filter-text);
    margin: 0 0 15px 0;
}

/* Filter Chips */
.mobile-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-chip {
    padding: 8px 16px;
    background-color: var(--filter-chip-bg);
    color: var(--filter-chip-text);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    user-select: none;
}

.filter-chip:active {
    transform: scale(0.95);
}

.filter-chip.active {
    background-color: var(--filter-chip-active);
    color: var(--filter-chip-active-text);
}

/* Price Range Slider */
.price-slider-container {
    padding: 15px 5px 45px; /* Increased bottom padding */
    margin-bottom: 15px;
}

#price-range-slider {
    height: 8px;
    margin: 15px 0 35px; /* Increased bottom margin */
}

.price-range-values {
    display: flex;
    justify-content: space-between;
    color: var(--filter-text);
    font-size: 14px;
    font-weight: 500;
    margin-top: 5px;
}

/* NoUiSlider Custom Styling */
.noUi-target {
    border: none;
    background-color: var(--filter-chip-bg);
    box-shadow: none;
    border-radius: 4px;
    height: 6px;
}

.noUi-connect {
    background-color: var(--filter-primary);
}

.noUi-handle {
    border: 2px solid var(--filter-primary);
    background-color: white;
    box-shadow: 0 2px 5px var(--filter-shadow);
    border-radius: 50%;
    cursor: pointer;
    height: 20px !important;
    width: 20px !important;
    top: -8px !important;
    right: -10px !important;
    transition: transform 0.2s ease;
}

.noUi-handle:hover {
    transform: scale(1.1);
}

.noUi-handle:before,
.noUi-handle:after {
    display: none;
}

/* Tooltips */
.noUi-tooltip {
    background-color: var(--filter-primary);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transform: translate(-50%, 5px);
}

/* Pips (markers) */
.noUi-pips {
    padding-top: 15px;
}

.noUi-marker {
    background-color: var(--filter-border);
}

.noUi-marker-large {
    height: 8px;
}

.noUi-marker-normal {
    height: 5px;
}

.noUi-value {
    color: var(--filter-text);
    font-size: 11px;
    opacity: 0.7;
    top: 15px;
    white-space: nowrap;
}

/* Fix for overlapping price tags */
.noUi-value-horizontal {
    transform: translate(-50%, 50%);
}

.noUi-value:nth-child(2) {
    transform: translate(-50%, 50%);
}

.noUi-value:nth-child(4) {
    transform: translate(-30%, 50%);
}

.noUi-value:nth-child(6) {
    transform: translate(-50%, 50%);
}

.noUi-value:nth-child(8) {
    transform: translate(-70%, 50%);
}

.noUi-value:nth-child(10) {
    transform: translate(-50%, 50%);
}

.noUi-value:nth-child(12) {
    transform: translate(-70%, 50%);
}

.noUi-value-large {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

/* Filter Footer */
.mobile-filter-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--filter-border);
    display: flex;
    gap: 10px;
}

.mobile-filter-footer button {
    padding: 12px 0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    border: none;
}

.mobile-filter-footer button:active {
    transform: scale(0.98);
}

.reset-filters {
    flex: 1;
    background-color: var(--filter-chip-bg);
    color: var(--filter-text);
}

.apply-filters {
    flex: 2;
    background-color: var(--filter-primary);
    color: white;
}

/* Filter Overlay */
.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--filter-z-index) + 5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--filter-transition), visibility var(--filter-transition);
}

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

/* Active Filter Indicator */
.filter-active-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 12px;
    height: 12px;
    background-color: var(--filter-primary);
    border-radius: 50%;
    border: 2px solid white;
}

/* Floating Cart Button - Enhanced Animations */
.floating-cart-button {
    position: fixed;
    bottom: 30px;
    left: 20px;
    width: 60px;
    height: 60px;
    background-color: #2ecc71;
    color: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    cursor: pointer;
    transform: translateY(100px); /* Start hidden below the viewport */
    will-change: transform, box-shadow;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backface-visibility: hidden; /* Prevent flickering on some browsers */
    perspective: 1000px; /* 3D effect for children */
}

/* Spring animation when becoming visible */
.floating-cart-button.visible {
    transform: translateY(0);
    animation: cart-spring-in 0.7s cubic-bezier(0.18, 1.25, 0.4, 1.1) forwards;
}

/* Realistic press effect with shadow change */
.floating-cart-button:active {
    transform: scale(0.92) translateY(3px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hover effect */
.floating-cart-button:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px) scale(1.02);
}

/* Spring animation keyframes */
@keyframes cart-spring-in {
    0% {
        transform: translateY(100px);
        opacity: 0;
    }
    60% {
        transform: translateY(-10px);
        opacity: 1;
    }
    80% {
        transform: translateY(5px);
    }
    100% {
        transform: translateY(0);
    }
}

.floating-cart-button i {
    font-size: 20px;
    margin-bottom: 2px;
}

.floating-cart-button span {
    font-size: 12px;
    font-weight: 500;
}

.floating-cart-button .cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--filter-primary);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Hide floating cart on desktop */
@media (min-width: 769px) {
    .floating-cart-button {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Swipe Hint */
.swipe-hint {
    text-align: center;
    padding: 10px;
    color: #888;
    font-size: 12px;
    opacity: 0.7;
}

/* Animation for Filter Button */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 12px var(--filter-shadow);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px var(--filter-shadow);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 12px var(--filter-shadow);
    }
}

.mobile-filter-button.pulse {
    animation: pulse 1.5s infinite;
}
