/* Performance-optimized CSS additions */

/* Lazy loading styles */
.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy.loaded {
    opacity: 1;
}

/* Optimized toast system */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    pointer-events: auto;
    transform: translateX(100%);
    animation: slideIn 0.3s ease-out forwards;
    max-width: 300px;
    word-wrap: break-word;
    font-weight: 600;
    font-size: 1rem;
}

.toast-success {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-error {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-danger {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-info {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-warning {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-message {
    background: #ef4444;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.toast-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    color: rgba(255, 255, 255, 1);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Performance optimizations */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.product-card {
    will-change: transform;
    transform: translateZ(0); /* Force hardware acceleration */
}

.product-image img {
    will-change: transform;
    backface-visibility: hidden;
}

/* Reduce layout shifts */
.product-image {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--radius-md);
    position: relative;
}

.placeholder-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--surface-color));
    color: hsl(var(--muted-color));
}

.placeholder-image svg {
    width: 48px;
    height: 48px;
}

/* Optimize animations */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
        transform: translateX(0);
    }
    
    .fade-in-up {
        animation: none;
        opacity: 1;
        transform: translateY(0);
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Critical loading states */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Optimize button interactions */
.btn-add-cart,
.btn-wishlist,
.btn-quick-view {
    contain: layout style paint;
    will-change: transform;
}

.btn-add-cart:hover,
.btn-wishlist:hover,
.btn-quick-view:hover {
    transform: translateY(-1px);
}

/* Optimize modal performance */
.modal-overlay {
    contain: layout style paint;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Font loading optimization */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZ9hiA.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Intersection Observer fallback */
.no-js .lazy {
    opacity: 1;
}

/* Optimize scrolling performance */
.smooth-scroll {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    .smooth-scroll {
        scroll-behavior: auto;
    }
}

/* Container queries for responsive design */
@container (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* Optimize focus states for accessibility */
.btn:focus-visible {
    outline: 2px solid hsl(var(--primary-color));
    outline-offset: 2px;
}

/* Reduce paint complexity */
.glass {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    contain: layout style paint;
}

/* Optimize image loading */
img[loading="lazy"] {
    content-visibility: auto;
}

/* Performance hints for browsers */
.hero {
    contain: layout style paint;
}

.product-card {
    contain: layout style;
}

/* Optimize text rendering */
body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    text-rendering: optimizeLegibility;
}

/* Critical resource hints */
.preload-hint {
    content: '';
}

/* Optimize for mobile performance */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }
    
    .toast {
        max-width: none;
    }
}