/* Catalog Image Optimizations */
.lazy-load {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
    background-color : white;
}

.lazy-load.error {
    opacity: 0.5;
}

.product-image-container {
    position: relative;
    background: linear-gradient(45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(-45deg, #f8f9fa 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f8f9fa 75%), 
                linear-gradient(-45deg, transparent 75%, #f8f9fa 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 8px 8px 0 0;
}

/* Hover effects */
.product-card:hover .lazy-load {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.product-card {
    transition: box-shadow 0.3s ease;
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* Loading animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.lazy-load:not(.loaded):not(.error) {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Loading spinner for individual images */
.product-image-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #dee2e6;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

.product-image-container.loaded::before {
    display: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Progressive enhancement for better UX */
.product-title {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title:hover {
    color: #007bff;
    text-decoration: none;
}

.product-price {
    margin-top: auto;
    padding-top: 10px;
}

.price-old {
    text-decoration: line-through;
    color: #6c757d;
    font-size: 0.85rem;
}

.price {
    font-weight: bold;
    color: #28a745;
    font-size: 1.1rem;
}

.btn-link-details {
    color: #007bff;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.btn-link-details:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Product badges */
.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-offer {
    background-color: #dc3545;
    color: white;
}

.badge-out-of-stock {
    background-color: #6c757d;
    color: white;
}

/* Responsive optimizations */
@media (max-width: 768px) {
    .product-image-container {
        height: 150px;
    }
    
    .product-title {
        font-size: 0.9rem;
    }
    
    .price {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .product-image-container {
        height: 120px;
    }
    
    .product-title {
        font-size: 0.85rem;
        -webkit-line-clamp: 3;
    }
    
    .price {
        font-size: 0.95rem;
    }
    
    .btn-link-details {
        font-size: 0.8rem;
    }
}

/* Filter improvements */
.filter-card {
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.filter-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
}

/* Performance optimizations */
.catalog-container {
    contain: layout style;
}

.product-card {
    contain: layout style;
}

/* Reduce layout thrashing */
.row.g-3 {
    will-change: auto;
}

/* Grid optimizations for better performance */
@supports (display: grid) {
    .row.g-3 {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .col-xl-4, .col-lg-6, .col-md-6, .col-6 {
        grid-column: auto;
    }
    
    @media (max-width: 768px) {
        .row.g-3 {
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        }
    }
    
    @media (max-width: 576px) {
        .row.g-3 {
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        }
    }
}
