/* Mobile-First Enhancements for FarmsApp */
/* Optimized for 95% mobile users */

/* Touch-friendly tap targets */
* {
    -webkit-tap-highlight-color: rgba(22, 163, 74, 0.2);
}

/* Smooth scrolling for better mobile UX */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

/* Optimized body for mobile */
body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Touch-friendly button and link sizing */
button, 
.btn, 
a.button,
.download-button-header,
.nav-link,
.top-bar-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Prevent text overflow on mobile */
h1, h2, h3, h4, h5, h6, p {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Form inputs mobile-friendly */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="search"],
textarea,
select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
}

/* Mobile-specific utility classes */
.mobile-hide {
    display: none !important;
}

@media (min-width: 769px) {
    .mobile-hide {
        display: block !important;
    }
    
    .desktop-hide {
        display: none !important;
    }
}

/* Sticky header for mobile */
@media (max-width: 768px) {
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Optimized container spacing */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Better mobile typography */
    body {
        font-size: 16px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 0.875rem;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
        margin-bottom: 0.75rem;
    }
    
    p {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }
    
    /* Card spacing on mobile */
    .product-card,
    .offer-card,
    .category-card {
        margin-bottom: 15px;
    }
    
    /* Footer optimization */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .footer-column {
        margin-bottom: 20px;
    }
    
    /* Navigation mobile-friendly */
    .nav-links,
    .nav-menu {
        gap: 8px;
        flex-wrap: wrap;
    }
    
    /* Product grid mobile optimization */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 0;
    }
    
    /* Offers grid mobile */
    .offers-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Search bar mobile */
    .search-container {
        width: 100%;
        margin: 10px 0;
    }
    
    .search-input {
        width: 100%;
        padding: 12px 40px 12px 12px;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Reduce section padding on very small screens */
    section {
        padding: 20px 0;
    }
    
    /* Smaller buttons on very small screens */
    button,
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Landscape orientation optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-banner {
        padding: 20px 0;
    }
    
    .hero-content h1 {
        font-size: 1.5rem;
    }
}

/* High DPI screens (retina displays) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    * {
        max-width: 100%;
    }
}

/* Loading states optimized for mobile */
.loading-spinner {
    width: 40px;
    height: 40px;
}

/* Mobile-friendly modals and overlays */
.modal,
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        margin: 5vh auto;
    }
}
