/* Optimized CSS for better performance */

/* Critical CSS - Above the fold */
:root {
    --primary-color: #ff6b00;
    --secondary-color: #ff8533;
    --accent-color: #fff5eb;
    --text-color: #333333;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.15rem 1.75rem rgba(255, 107, 0, 0.15);
    --transition: all 0.3s ease;
}

/* Mobile-first approach */
.mobile-navbar {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    padding: 0.5rem 0.5rem;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030 !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100% !important;
    max-width: 100vw !important;
    height: 60px;
}

.mobile-search {
    background: white;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #eee;
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1020 !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    height: 60px;
    display: flex;
    align-items: center;
}

/* Optimized product cards */
.mobile-product-card {
    height: auto;
    width: 100%;
    margin: 0 auto;
    border: none;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    background: white;
    will-change: transform;
}

.mobile-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.mobile-product-card .card-img-top {
    height: 1.5in;
    object-fit: cover;
    border-bottom: 1px solid #f0f0f0;
    width: 100%;
}

/* Lazy loading optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

.container-fluid {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Reduced motion for better performance */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimized grid layout */
.row-cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem !important;
    padding: 0.3rem !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    justify-items: center !important;
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-product-card {
        border: 2px solid #000;
    }

    .btn-primary {
        background-color: #000;
        border-color: #000;
    }
}

/* Focus indicators */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip links for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Optimized animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Use transform and opacity for better performance */
.animate-in {
    animation: slideInFromRight 0.5s ease-out forwards;
}

/* Optimized hover effects */
.mobile-product-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Reduce layout shifts */
.mobile-product-card .card-img-top {
    aspect-ratio: 3/2;
    object-fit: cover;
}

/* Optimized typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

/* Optimized button styles */
.btn {
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    will-change: transform;
}

.btn:active {
    transform: scale(0.98);
}

/* Optimized form controls */
.form-control {
    border-radius: var(--border-radius);
    border: 2px solid #e9ecef;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(255, 107, 0, 0.25);
}

/* Optimized spacing */
.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

/* Optimized responsive breakpoints */
@media (max-width: 480px) {
    .mobile-product-card {
        min-height: 255px;
        width: calc(100% + 0.8in);
    }

    .row-cols-2 {
        gap: 0.5rem !important;
        padding: 0.25rem !important;
    }
}

@media (max-width: 360px) {
    .mobile-product-card {
        min-height: 235px;
        width: calc(100% + 0.6in);
    }

    .row-cols-2 {
        gap: 0.4rem !important;
        padding: 0.2rem !important;
    }
}

/* Desktop optimizations */
@media (min-width: 768px) {
    .mobile-navbar,
    .mobile-search {
        display: none;
    }

    .main-content {
        margin-top: 20px !important;
        margin-left: 280px;
        padding: 1rem;
    }
}

/* Print styles */
@media print {
    .mobile-navbar,
    .mobile-search,
    .btn,
    .carousel-control-prev,
    .carousel-control-next {
        display: none !important;
    }

    .main-content {
        margin-top: 0 !important;
        margin-left: 0 !important;
    }
}

