/* Mobile Products Layout Enhancement */

/* Enhanced touch targets and spacing */
.mobile-product-card {
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-product-card:active {
    opacity: 0.9;
}

/* Better loading states */
.product-image.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Enhanced price displays */
.price-option {
    cursor: pointer;
    transition: all 0.2s ease;
}

.price-option:hover {
    background-color: #f8f9fa;
    border-radius: 6px;
}

.price-option:active {
    background-color: #e9ecef;
}

/* Better add to cart button states */
.add-to-cart-btn {
    position: relative;
    overflow: hidden;
}

.add-to-cart-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.add-to-cart-btn:active::before {
    width: 200px;
    height: 200px;
}

/* Loading spinner for cart actions */
.add-to-cart-btn.loading {
    pointer-events: none;
}

.add-to-cart-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Improved mobile spacing */
@media (max-width: 480px) {
    .mobile-products-grid {
        padding: 12px 8px;
        gap: 8px;
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .product-subtitle {
        font-size: 10px;
    }
    
    .add-to-cart-btn {
        padding: 10px;
        font-size: 12px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .mobile-product-card,
    .product-image,
    .add-to-cart-btn {
        transition: none;
    }
    
    .add-to-cart-btn::before {
        display: none;
    }
    
    .loading {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-product-card {
        border: 2px solid #000;
        box-shadow: none;
    }
    
    .product-badge {
        border: 1px solid #fff;
    }
    
    .add-to-cart-btn {
        border: 2px solid #fff;
    }
}

/* Focus states for keyboard navigation */
.mobile-product-card:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.add-to-cart-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    .mobile-product-card {
        background: #2d3748;
        color: #f7fafc;
    }
    
    .product-title {
        color: #f7fafc;
    }
    
    .product-subtitle {
        color: #a0aec0;
    }
    
    .price-option:hover {
        background-color: #4a5568;
    }
}

/* Smooth scrolling for product grids */
.mobile-products-grid {
    scroll-behavior: smooth;
}

/* Enhanced visual feedback */
.mobile-product-card:hover .product-image {
    transform: scale(1.02);
}

/* Better text readability */
.product-title,
.product-subtitle {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sticky Filter Container Styles */
#filterContainer {
    position: relative;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 100;
    transition: all 0.3s ease;
    padding: 12px 16px;
    box-shadow: none;
}

#filterContainer.sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
    border-bottom: 2px solid #f44336;
    padding: 8px 16px;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#filterContainer .filter {
    display: inline-block;
    background: #f8f9fa;
    color: #495057;
    padding: 8px 16px;
    margin: 4px 8px 4px 0;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#filterContainer .filter:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

#filterContainer .filter:active {
    background: #f44336;
    color: white;
    border-color: #f44336;
    transform: translateY(0);
}

#filterContainer .filter.active {
    background: #f44336;
    color: white;
    border-color: #f44336;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.3);
}

/* Mobile optimization for filters */
@media (max-width: 768px) {
    #filterContainer {
        padding: 10px 12px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #filterContainer::-webkit-scrollbar {
        display: none;
    }
    
    #filterContainer.sticky {
        padding: 6px 12px;
    }
    
    #filterContainer .filter {
        font-size: 13px;
        padding: 6px 14px;
        margin-right: 6px;
        min-width: auto;
    }
}

/* Content offset when filter is sticky */
.filter-sticky-offset {
    padding-top: 60px;
    transition: padding-top 0.3s ease;
}

@media (max-width: 768px) {
    .filter-sticky-offset {
        padding-top: 50px;
    }
}

/* Performance optimizations for sticky behavior */
#filterContainer * {
    will-change: auto;
}

#filterContainer.sticky {
    will-change: transform;
    transform: translateZ(0); /* Force hardware acceleration */
}

/* Scroll indicator for filter container */
#filterContainer::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#filterContainer:hover::after,
#filterContainer.scrollable::after {
    opacity: 1;
}

@media (max-width: 768px) {
    #filterContainer::after {
        display: none;
    }
}

/* Smooth transitions for layout shifts */
.main-content {
    transition: padding-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus management for accessibility */
#filterContainer.sticky .filter:focus {
    outline-offset: 3px;
    z-index: 1;
}