/* Mobile Responsiveness Fixes */

/* Ensure smooth scrolling on mobile */
html {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }
}

/* Tablet Responsive (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        padding: 0 var(--space-6);
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-6);
    }
    
    .brands-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile Landscape (481px - 768px) */
@media (max-width: 768px) and (min-width: 481px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
    
    .product-card {
        min-height: auto;
    }
    
    .hero {
        min-height: 50vh;
    }
}

/* Mobile Portrait (max 480px) */
@media (max-width: 480px) {
    /* Typography adjustments */
    html {
        font-size: 14px;
    }
    
    /* Container padding */
    .container {
        padding: 0 var(--space-3);
    }
    
    /* Section spacing */
    .section {
        padding: var(--space-10) 0;
    }
    
    /* Grid layouts */
    .products-grid,
    .brands-grid,
    .about-stats,
    .contact-info {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    /* Cards */
    .product-card,
    .brand-card {
        margin-bottom: var(--space-4);
    }
    
    /* Images */
    .product-image img,
    .brand-image img {
        height: 200px;
        object-fit: contain;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: var(--space-4);
    }
    
    input,
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Extra Small Mobile (max 360px) */
@media (max-width: 360px) {
    html {
        font-size: 13px;
    }
    
    .nav-logo {
        font-size: var(--text-base);
    }
    
    .hero-title {
        font-size: var(--text-2xl);
    }
    
    .section-title {
        font-size: var(--text-2xl);
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    .filter-btn {
        min-height: 44px;
        min-width: 44px;
        padding: var(--space-3) var(--space-4);
    }
    
    /* Remove hover effects on touch devices */
    .product-card:hover,
    .brand-card:hover {
        transform: none;
    }
    
    /* Better tap highlighting */
    * {
        -webkit-tap-highlight-color: rgba(30, 64, 175, 0.1);
    }
}

/* Landscape orientation fixes */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: var(--space-8) 0;
    }
    
    .nav-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image img,
    .brand-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #f0f0f0;
    }
}

/* Print styles */
@media print {
    .navbar,
    .whatsapp-float,
    .nav-toggle,
    .hero-buttons {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    .product-card,
    .brand-card {
        page-break-inside: avoid;
    }
}

/* Fix for notched devices (iPhone X and newer) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-left: max(var(--space-4), env(safe-area-inset-left));
        padding-right: max(var(--space-4), env(safe-area-inset-right));
    }
}

/* Improve scrolling performance */
.nav-menu,
.product-card,
.brand-card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Fix for sticky elements on iOS */
.navbar {
    position: -webkit-sticky;
    position: sticky;
}

/* Better font rendering on mobile */
@media (max-width: 768px) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
}

/* Improve tap targets for accessibility */
@media (max-width: 768px) {
    a,
    button,
    .btn,
    .nav-link,
    .filter-btn,
    .product-card {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Fix for viewport height on mobile browsers */
.hero,
.brand-hero {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Optimize images for mobile */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .lazy-load {
        background: var(--gray-100);
    }
}

