/**
 * Vaishnavi Garments — Mobile & Tablet Responsive Enhancements
 * Amazon & Flipkart Inspired UX Standards (320px - 1024px)
 * Strict Zero-Regression for Desktop Layouts
 */

/* ==========================================================================
   1. GLOBAL RESPONSIVE SAFETY (All Screens < 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    html, body {
        overflow-x: hidden !important;
        width: 100%;
        position: relative;
    }

    img, video, canvas, svg {
        max-width: 100%;
        height: auto;
    }

    /* Prevent text resizing on orientation change */
    body {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* ==========================================================================
   2. TABLET ADAPTATIONS (768px – 1024px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    :root {
        --header-height: 76px;
    }

    .container {
        padding: 0 1.25rem;
    }

    /* Tablet Header Spacing */
    .nav-container {
        gap: 1rem;
    }

    .logo-main {
        font-size: 1.5rem;
    }

    .logo-sub {
        font-size: 0.65rem;
        letter-spacing: 2.5px;
    }

    .nav-icon-group {
        gap: 0.85rem;
    }

    /* Product Grid: Clean 3-Column on Tablet */
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.25rem !important;
    }

    /* Product Details Page on Tablet */
    .product-detail-layout {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    /* Cart & Checkout on Tablet */
    .cart-grid, .co-grid {
        gap: 1.5rem;
    }

    /* Tablet Hero Slider */
    .hero {
        height: 380px !important;
        min-height: auto;
    }
}

/* ==========================================================================
   3. MOBILE VIEW ENHANCEMENTS (320px – 767px)
   ========================================================================== */
@media (max-width: 767px) {
    :root {
        --header-height: 64px;
    }

    .container {
        padding: 0 0.85rem;
    }

    /* --- Compact Amazon/Flipkart Style Mobile Header --- */
    .main-header {
        height: var(--header-height);
    }

    .nav-container {
        height: var(--header-height);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.4rem;
        padding: 0 0.5rem;
    }

    .hamburger {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        font-size: 1.4rem;
        cursor: pointer;
        padding: 4px;
        color: var(--text-heading);
        border-radius: var(--radius-pill);
        pointer-events: auto !important;
        z-index: 1600 !important;
        position: relative;
    }

    /* Responsive Logo */
    .logo {
        gap: 6px;
        flex-shrink: 1;
        min-width: 0;
    }

    .logo-mark {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .logo-emblem {
        font-size: 1.15rem;
    }

    .logo-text-wrap {
        line-height: 1;
    }

    .logo-main {
        font-size: 1.25rem;
        letter-spacing: 0;
    }

    .logo-sub {
        font-size: 0.55rem;
        letter-spacing: 1.8px;
        margin-top: 2px;
    }

    /* Nav Icons Row - Compact & Touch-Friendly */
    .nav-icons {
        height: var(--header-height);
        display: flex;
        align-items: center;
    }

    .nav-icon-group {
        gap: 0.35rem;
    }

    .nav-icon-btn, .nav-icon-link {
        width: 34px;
        height: 34px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
    }

    /* Move theme toggle inside mobile drawer to prevent top bar clutter on < 390px */
    .nav-icon-group #themeToggleBtn {
        display: none !important;
    }

    .cart-icon-wrapper {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .cart-badge {
        min-width: 17px;
        height: 17px;
        font-size: 0.62rem;
        top: -3px;
        right: -3px;
    }

    /* Full-Width Mobile Expanding Search Bar */
    .nav-icons.search-active {
        position: static;
    }

    .nav-icons.search-active .search-box-inline {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        transform: none !important;
        width: 100vw !important;
        max-width: 100% !important;
        height: var(--header-height) !important;
        background: var(--bg-card) !important;
        padding: 0 0.85rem !important;
        display: flex !important;
        align-items: center !important;
        z-index: 2000 !important;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
        border-radius: 0 !important;
    }

    .search-form-inline {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .search-input-inline {
        width: 100% !important;
        font-size: 0.9rem;
        padding: 9px 12px;
    }

    .search-close-btn {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    /* --- Slide-out Mobile Navigation Drawer --- */
    .nav-links {
        display: flex !important;
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: 85%;
        max-width: 320px;
        height: calc(100vh - var(--header-height));
        overflow-y: auto;
        background: var(--bg-card);
        flex-direction: column;
        align-items: flex-start;
        padding: 1.5rem 1.25rem 3rem;
        gap: 0.25rem;
        transform: translateX(-110%);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1500;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
        border-right: 1px solid var(--border-color);
        border-bottom: none;
    }

    .nav-links.active {
        transform: translateX(0) !important;
    }

    .nav-links .nav-item {
        width: 100%;
        padding: 12px 14px;
        font-size: 0.92rem;
        border-radius: 8px;
        display: flex;
        align-items: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    }

    .nav-links .nav-item:hover {
        background: var(--bg-soft);
    }

    .mobile-theme-row {
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    .mobile-theme-btn {
        width: 100%;
        height: 44px;
        border-radius: 8px;
        justify-content: flex-start;
        padding: 0 14px;
        gap: 10px;
    }

    /* --- Flipkart / Amazon Inspired Two-Column Product Grid --- */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
        margin-top: 1rem;
    }

    .product-card {
        border-radius: 10px;
        overflow: hidden;
        border: 1px solid var(--border-color);
        background: var(--bg-card);
        display: flex;
        flex-direction: column;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    .product-img-container, .product-image-wrapper {
        aspect-ratio: 3 / 4;
        width: 100%;
    }

    .product-info {
        padding: 0.65rem 0.6rem !important;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
    }

    /* Line-clamp long product titles like Amazon/Flipkart */
    .product-name, .product-title {
        font-size: 0.85rem !important;
        line-height: 1.35 !important;
        height: 2.7em !important;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin-bottom: 0.35rem !important;
        font-weight: 600;
    }

    .product-price-row {
        margin-top: auto;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.35rem;
    }

    .product-price {
        font-size: 1rem !important;
        font-weight: 700;
    }

    .original-price {
        font-size: 0.78rem;
    }

    .discount-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .add-to-cart-btn, .btn-quick-add {
        font-size: 0.75rem !important;
        padding: 8px 10px !important;
        height: 36px;
        border-radius: 6px;
        margin-top: 0.5rem;
    }

    /* --- Product Detail Page on Mobile --- */
    .product-detail-layout {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .product-main-image {
        border-radius: 12px;
    }

    .product-action-buttons {
        display: flex;
        gap: 0.65rem;
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        padding: 0.75rem 0.5rem;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
        z-index: 900;
    }

    .product-action-buttons .btn {
        flex: 1;
        padding: 12px 14px !important;
        font-size: 0.82rem !important;
        height: 46px;
    }

    /* --- WhatsApp Floating Button Mobile Safe Position --- */
    .whatsapp-float {
        width: 48px !important;
        height: 48px !important;
        bottom: 20px !important;
        right: 14px !important;
        font-size: 26px !important;
        z-index: 800 !important;
    }

    /* --- Cart & Checkout Mobile Optimization --- */
    .cart-grid, .co-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    .co-addr-card {
        padding: 1rem !important;
    }

    .co-card {
        padding: 1.25rem 1rem !important;
    }

    .btn-checkout, .btn-place-order {
        width: 100%;
        height: 48px;
        font-size: 0.9rem !important;
    }

    /* --- Proportional Mobile Hero Slider (Amazon / Flipkart Banner Standard) --- */
    .hero {
        height: auto !important;
        aspect-ratio: 2000 / 818 !important;
        min-height: 150px;
        max-height: 310px;
        width: 100%;
        position: relative;
        overflow: hidden;
    }

    .hero-slider, .hero-slide {
        height: 100% !important;
        width: 100% !important;
    }

    .hero-slide {
        background-size: cover !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
    }

    /* Subtle overlay to preserve high image clarity on mobile */
    .hero::before {
        opacity: 0.25;
    }
}

/* ==========================================================================
   4. ULTRA-SMALL MOBILE DEVICES (< 360px, e.g. iPhone SE 1st Gen)
   ========================================================================== */
@media (max-width: 359px) {
    .nav-container {
        padding: 0 0.35rem;
    }

    .logo-main {
        font-size: 1.1rem;
    }

    .logo-sub {
        display: none; /* Hide sub-heading on very narrow 320px screens */
    }

    .nav-icon-group {
        gap: 0.2rem;
    }

    .nav-icon-btn, .nav-icon-link {
        width: 30px;
        height: 30px;
        font-size: 1.1rem;
    }

    .product-grid {
        gap: 0.45rem !important;
    }

    .product-info {
        padding: 0.5rem 0.4rem !important;
    }
}


/* ==========================================================================
   5. FLIPKART / AMAZON STYLE MOBILE BOTTOM APP NAVIGATION & SCROLL STRIP
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding-bottom: 64px !important; /* Space for sticky bottom navigation */
    }

    /* Fixed App Bottom Navigation Bar */
    .mobile-app-bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 56px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        display: flex !important;
        align-items: center;
        justify-content: space-around;
        z-index: 1100;
        box-shadow: 0 -3px 15px rgba(0, 0, 0, 0.06);
    }

    .mobile-bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.68rem;
        font-weight: 500;
        height: 100%;
        gap: 3px;
        transition: color 0.2s ease;
        position: relative;
    }

    .mobile-bottom-nav-item i {
        font-size: 1.3rem;
        line-height: 1;
    }

    .mobile-bottom-nav-item.active,
    .mobile-bottom-nav-item:hover {
        color: var(--accent-primary);
    }

    .mobile-bottom-nav-item .mobile-nav-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 18px);
        background: var(--accent-gradient);
        color: #ffffff;
        font-size: 0.58rem;
        font-weight: 700;
        padding: 1px 5px;
        border-radius: 10px;
        min-width: 15px;
        text-align: center;
        line-height: 1.2;
    }

    /* Move floating WhatsApp up so bottom bar doesn't cover it */
    .whatsapp-float {
        bottom: 68px !important;
    }

    /* Flipkart Style Horizontal Quick Category Rail */
    .mobile-category-rail {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem 0.65rem 0.5rem;
        gap: 0.85rem;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        scrollbar-width: none;
    }

    .mobile-category-rail::-webkit-scrollbar {
        display: none;
    }

    .mobile-cat-pill {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        flex-shrink: 0;
        width: 62px;
        text-align: center;
        gap: 4px;
    }

    .mobile-cat-thumb {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid var(--border-color);
        background: var(--bg-soft);
        padding: 2px;
    }

    .mobile-cat-thumb-placeholder {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--accent-subtle);
        border: 1.5px solid var(--border-accent);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        color: var(--accent-primary);
    }

    .mobile-cat-name {
        font-size: 0.65rem;
        font-weight: 600;
        color: var(--text-main);
        line-height: 1.2;
        max-width: 62px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* --- Ultra-Clean Compact Mobile Footer & Zero-Waste Spacing --- */
    .pre-footer-trust {
        padding: 1.25rem 0 !important;
    }

    .pre-footer-trust .trust-grid {
        gap: 0.65rem !important;
    }

    .pre-footer-trust .trust-item {
        padding: 0.4rem 0 !important;
        gap: 0.6rem !important;
    }

    .pre-footer-trust .trust-icon-box {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.05rem !important;
        flex-shrink: 0 !important;
    }

    .pre-footer-trust .trust-text h4 {
        font-size: 0.8rem !important;
        margin-bottom: 2px !important;
    }

    .pre-footer-trust .trust-text p {
        font-size: 0.68rem !important;
        line-height: 1.3 !important;
    }

    footer, .main-footer {
        padding: 0 !important;
        margin: 0 !important;
    }

    .mobile-footer {
        padding: 1.25rem 1rem 1rem !important;
    }

    .mobile-logo-wrap {
        margin-bottom: 0.25rem !important;
    }

    .mobile-logo-main {
        font-size: 1.35rem !important;
    }

    .mobile-logo-sub {
        font-size: 0.62rem !important;
        letter-spacing: 2.5px !important;
    }

    .mobile-footer-desc {
        font-size: 0.75rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.85rem !important;
    }

    .mobile-quick-actions {
        margin-bottom: 0.75rem !important;
        gap: 8px !important;
    }

    .mobile-action-pill {
        padding: 5px 12px !important;
        font-size: 0.75rem !important;
    }

    .mobile-email-actions {
        gap: 4px !important;
        margin-bottom: 0.75rem !important;
    }

    .mobile-email-link {
        font-size: 0.74rem !important;
    }

    .mobile-address-box {
        font-size: 0.7rem !important;
        line-height: 1.35 !important;
        margin-bottom: 0.85rem !important;
        padding: 0 !important;
    }

    .mobile-footer-bottom {
        padding-top: 0.6rem !important;
        font-size: 0.68rem !important;
    }
}

@media (min-width: 769px) {
    .mobile-app-bottom-bar,
    .mobile-category-rail {
        display: none !important;
    }
}
