/* Mobile Responsive Styles for HalalLens */

/* ========== NAVIGATION & HEADER ========== */

/* Mobile Navigation Base */
@media (max-width: 768px) {
    /* Fix navigation padding and spacing */
    nav .container {
        padding: 0.75rem 1rem !important;
    }
    
    /* Logo optimization for mobile */
    nav .container > a {
        transform: scale(0.9);
    }
    
    nav .container > a .text-lg {
        font-size: 1.1rem;
    }
    
    nav .container > a .text-\\[11px\\] {
        display: none; /* Hide tagline on mobile for cleaner look */
    }
    
    /* Search bar in header - mobile specific */
    nav .hidden.md\\:flex {
        display: none !important;
    }
    
    /* Mobile search should be prominent */
    .md\\:hidden .relative input {
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
        padding: 0.625rem 2.5rem 0.625rem 1rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Mobile menu button alignment */
    #mobileMenuBtn {
        padding: 0.5rem !important;
        margin-left: 0.5rem !important;
    }
}

/* ========== PRODUCTS PAGE ========== */

/* Mobile Products Header */
@media (max-width: 768px) {
    /* Main heading */
    .text-4xl {
        font-size: 1.75rem !important;
        line-height: 2.25rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Subtitle */
    .text-xl {
        font-size: 1rem !important;
        line-height: 1.5rem !important;
    }
    
    /* Stats cards - stack vertically */
    #stats-container {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .stats-card {
        padding: 1rem !important;
        border-radius: 0.75rem !important;
    }
    
    .stats-card .text-3xl {
        font-size: 1.5rem !important;
    }
    
    .stats-card div:last-child {
        font-size: 0.75rem !important;
    }
}

/* Mobile Filter Section */
@media (max-width: 768px) {
    .filter-section {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
        border-radius: 0.75rem !important;
    }
    
    .filter-section h3 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Search input container */
    .filter-section .lg\\:col-span-2 {
        grid-column: span 1 !important;
    }
    
    /* Make search prominent on mobile */
    #search {
        font-size: 1rem !important;
        padding: 0.625rem 0.625rem 0.625rem 2.5rem !important;
    }
    
    /* Filter dropdowns */
    .filter-section select {
        font-size: 0.9rem !important;
        padding: 0.5rem !important;
    }
    
    /* Filter grid - single column on mobile */
    .filter-section .grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

/* Mobile Product Cards */
@media (max-width: 768px) {
    /* Product grid - 2 columns on mobile */
    #products-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0 !important;
    }
    
    .product-card {
        border-radius: 0.5rem !important;
        padding: 0.75rem !important;
    }
    
    /* Product image */
    .product-card .product-thumbnail,
    .product-card img {
        height: 120px !important;
        border-radius: 0.375rem !important;
    }
    
    /* Product title */
    .product-card h3 {
        font-size: 0.875rem !important;
        line-height: 1.25rem !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.25rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    /* Brand name */
    .product-card .text-gray-600 {
        font-size: 0.75rem !important;
    }
    
    /* Status badges */
    .product-card .halal-badge,
    .product-card .haram-badge,
    .product-card .mushbooh-badge,
    .product-card .pending-badge {
        font-size: 0.625rem !important;
        padding: 0.25rem 0.5rem !important;
        border-radius: 0.25rem !important;
    }
    
    /* Barcode */
    .product-card .font-mono {
        font-size: 0.625rem !important;
    }
    
    /* Hide less important info on mobile */
    .product-card .text-xs:not(.font-mono) {
        display: none;
    }
}

/* ========== TABLET OPTIMIZATIONS ========== */

@media (min-width: 768px) and (max-width: 1024px) {
    /* Navigation adjustments */
    nav .container {
        padding: 1rem 1.5rem !important;
    }
    
    /* Products grid - 3 columns on tablet */
    #products-container {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* Stats cards - 2x2 grid on tablet */
    #stats-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========== SEARCH BAR SPECIFIC ========== */

/* Mobile search bar enhancements */
@media (max-width: 768px) {
    /* Top navigation search */
    .md\\:hidden {
        display: block !important;
        padding: 0.5rem 1rem 0.75rem !important;
        background: rgba(0, 0, 0, 0.1);
        margin-top: -0.25rem;
    }
    
    /* Ensure search is always visible on products page */
    #search-container,
    .filter-section > div:first-child {
        position: sticky;
        top: 60px;
        z-index: 10;
        background: white;
        padding: 0.75rem;
        margin: -0.75rem -0.75rem 0.75rem;
        border-bottom: 1px solid #e5e7eb;
    }
}

/* ========== LOADING STATES ========== */

@media (max-width: 768px) {
    .loading-spinner {
        width: 2rem !important;
        height: 2rem !important;
        border-width: 3px !important;
    }
    
    #loading-container {
        padding: 3rem 1rem !important;
    }
}

/* ========== PAGINATION ========== */

@media (max-width: 768px) {
    #pagination-container {
        padding: 1rem 0 !important;
    }
    
    #pagination-container button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
        margin: 0 0.25rem !important;
    }
    
    #page-info {
        font-size: 0.75rem !important;
        margin: 0 0.5rem !important;
    }
}

/* ========== PIXEL PERFECT ADJUSTMENTS ========== */

/* Fine-tune spacing and alignment */
@media (max-width: 768px) {
    /* Remove unnecessary margins on mobile */
    .max-w-7xl {
        padding: 0.5rem !important;
    }
    
    /* Consistent padding throughout */
    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Better touch targets */
    button, a, select, input {
        min-height: 44px !important;
    }
    
    /* Improve readability */
    body {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Fix menu overlay */
    #mobileMenu {
        top: 0 !important;
        height: 100vh !important;
        width: 85vw !important;
    }
}

/* ========== PRODUCT DETAIL PAGE ========== */

@media (max-width: 768px) {
    .product-detail-container {
        padding: 1rem !important;
    }
    
    /* Main image */
    .main-image {
        height: 250px !important;
    }
    
    /* Thumbnails */
    .image-thumbnails {
        padding: 0.5rem 0 !important;
    }
    
    .thumbnail-item {
        width: 60px !important;
        height: 60px !important;
    }
    
    /* Product info */
    .product-detail-container h1 {
        font-size: 1.5rem !important;
        line-height: 2rem !important;
    }
    
    /* Info cards */
    .info-card {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Tabs */
    .tab-nav {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .tab-button {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
        white-space: nowrap !important;
    }
}

/* ========== LANDING PAGE ========== */

@media (max-width: 768px) {
    /* Hero section */
    .hero-section {
        padding: 2rem 1rem !important;
    }
    
    /* CTA buttons */
    .hero-section .cta-buttons {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .hero-section .cta-buttons a,
    .hero-section .cta-buttons button {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.875rem !important;
        font-size: 1rem !important;
    }
    
    /* Feature cards */
    .feature-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* ========== iOS SPECIFIC FIXES ========== */

@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific fixes */
    input[type="text"],
    input[type="search"],
    select {
        font-size: 16px !important; /* Prevent zoom */
        -webkit-appearance: none;
        border-radius: 0.5rem;
    }
    
    /* Fix sticky positioning on iOS */
    .sticky {
        position: -webkit-sticky;
    }
    
    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== ANDROID SPECIFIC FIXES ========== */

@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Android Chrome specific fixes */
    input:focus,
    select:focus {
        outline: 2px solid #00A878;
        outline-offset: 2px;
    }
}

/* ========== ACCESSIBILITY ========== */

@media (max-width: 768px) {
    /* Ensure good contrast on mobile */
    .text-gray-600 {
        color: #4b5563 !important;
    }
    
    /* Better focus indicators */
    *:focus {
        outline: 2px solid #00A878 !important;
        outline-offset: 2px !important;
    }
    
    /* Larger tap targets */
    .clickable,
    [role="button"] {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */

@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    * {
        animation-duration: 0.2s !important;
    }
    
    /* Disable hover effects on touch devices */
    @media (hover: none) {
        .product-card:hover {
            transform: none !important;
            box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
        }
    }
}