/* 
   I-PETS MARKETPLACE RESPONSIVE OVERHAUL 2026
   Focus: UI/UX for Mobile (375px) and Tablet (768px)
   Author: Senior Front-end Developer (15 years exp)
*/

/* --- 1. TABLET OPTIMIZATION (max-width: 768px) --- */
@media screen and (max-width: 768px) {
    /* Container adjustment */
    .container {
        width: calc(100% - 24px);
        padding: 0;
    }

    /* Top Bar - Hide less important info, focus on Brand & Actions */
    .top-nav-row {
        grid-template-columns: 1fr auto !important;
        padding: 8px 0;
    }
    .top-left-tools { display: none; } /* Hide city select on mobile top */
    .brand-center img { width: 140px; }
    .brand-slogan { font-size: 0.9rem; }

    /* Search Zone - Compact */
    .top-search-zone {
        padding: 40px 0 50px;
    }
    .top-tagline {
        font-size: 24px;
        margin-bottom: 12px;
    }

    /* Top Categories - Horizontal Scroll or Grid 3 columns */
    .top-showcase .top-categories {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    .top-category-tile h3 { font-size: 13px; }
    .top-category-icon { width: 44px; height: 44px; }
    .top-category-icon.is-image { width: 80px; height: 44px; }

    /* Market Layout - Stacked */
    .market-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Sidebar - Collapsible or top-placed */
    .sidebar {
        position: static;
        max-height: none;
        order: -1;
    }

    /* Grids - 2 columns for products (UX best practice) */
    .popular-products-grid, .special-offers-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Hero Section - Stacked */
    .hero {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    .hero h1 { font-size: 28px; }

    /* Ads Carousel */
    .ads-slide {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .ads-slide-media {
        order: -1;
        height: 180px;
    }
    .ads-slide-copy h3 { font-size: 20px; }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 30px;
    }

    /* Sticky Bottom Nav */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        z-index: 100;
        justify-content: space-around;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    }
    .mobile-bottom-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--muted);
        font-size: 10px;
        cursor: pointer;
    }
    .mobile-bottom-nav-btn.is-active {
        color: var(--primary);
    }
    .mobile-bottom-nav-ico {
        font-size: 20px;
    }

    /* Body padding for fixed nav */
    body {
        padding-bottom: 70px;
    }

    /* --- PRODUCT PAGE FIXES --- */
    .product-summary {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    .product-specs-brief {
        grid-template-columns: 1fr !important;
    }
    .product-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .product-qr-inline { display: none; } /* Hide QR on mobile, not useful there */
    
    .product-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .product-tab { font-size: 15px; }

    /* --- SUBCATEGORY PAGE FIXES --- */
    .sub-layout {
        grid-template-columns: 1fr !important;
    }
    .sub-filters {
        position: static !important;
        margin-bottom: 15px;
    }
    .sub-product-list.is-grid-mode {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .sub-product-card {
        grid-template-columns: 1fr !important;
        padding: 10px !important;
    }
    .sub-product-image { height: 140px !important; }
    .sub-product-price { justify-items: start !important; text-align: left !important; }

    /* --- CABINET PAGE FIXES --- */
    .cabinet-layout {
        grid-template-columns: 1fr !important;
        margin: 10px auto !important;
    }
    .cabinet-main-sidebar {
        position: static !important;
        max-height: none !important;
        padding: 10px !important;
    }
    .cabinet-main-nav {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .cabinet-title { font-size: 24px !important; }
    .cabinet-topbar { padding: 8px !important; flex-wrap: wrap; }
}

/* --- 2. MOBILE OPTIMIZATION (max-width: 375px) --- */
@media screen and (max-width: 375px) {
    /* Brand Logo even smaller */
    .brand-center img { width: 120px; }
    
    /* Top Categories - 2 columns */
    .top-showcase .top-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hero */
    .hero-points {
        grid-template-columns: 1fr;
    }

    /* Product Cards - 2 columns */
    .popular-products-grid, .special-offers-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .popular-product-card { min-height: 220px !important; }
    .popular-product-media { height: 100px !important; }
    .popular-product-price { font-size: 15px !important; }
    .popular-product-btn { display: none; } /* On very small screens, click on card is enough */
    .popular-product-body h3 { font-size: 13px !important; }

    /* Cabinet Nav - 1 column for better readability */
    .cabinet-main-nav {
        grid-template-columns: 1fr;
    }

    /* Section Headings */
    .section-head h2 { font-size: 18px; }
}

/* --- 3. COMMON UX IMPROVEMENTS --- */
.mobile-bottom-nav { display: none; } /* Hidden by default on PC */

/* Sticky Search Bar for Mobile */
@media screen and (max-width: 768px) {
    .header-wrap {
        position: sticky;
        top: 0;
        background: var(--surface);
        padding: 4px 0;
    }
    .header-main {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
        padding: 6px 0;
    }
    .brand img { width: 120px; }
    .head-tools .control-group { display: none; } /* Hide theme toggle in header on mobile */
}

/* Smooth transitions for interactive elements */
.top-category-tile, .popular-product-card, .brand-card-btn, .ads-slide-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure images don't break layout */
img {
    max-width: 100%;
    height: auto;
}

/* Better touch targets for mobile */
@media (pointer: coarse) {
    button, a, input, select {
        min-height: 44px;
    }
    .top-category-tile, .mobile-bottom-nav-btn {
        min-height: auto; /* Respect their specific layouts */
    }
}

