/* ============================================
   MOBILE OPTIMIZATION - Art by Adliya
   Comprehensive mobile-first responsive fixes
   ============================================ */

/* === GLOBAL MOBILE RESETS === */
@media (max-width: 768px) {
    /* Prevent text inflation */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    /* Fast tap response */
    button, a, input, select, textarea, [role="button"], .btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Minimum touch targets */
    button:not(.swatch-btn),
    .btn,
    [role="button"],
    input[type="submit"],
    input[type="button"],
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }

    /* Word break for overflow prevention */
    h1, h2, h3, h4, h5, h6, p, td, th, li, label, .product-name {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Image containment */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Table responsive */
    .table-responsive,
    .order-items-wrapper,
    .compare-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100vw;
    }
}

/* === HEADER & NAVIGATION MOBILE === */
@media (max-width: 768px) {
    /* Mega menu containment */
    .mega-menu,
    .mega-dropdown,
    .mega-dropdown-inner {
        min-width: unset !important;
        width: 100% !important;
        position: relative !important;
    }

    .mega-dropdown .mega-col {
        width: 100% !important;
        padding: 8px 16px !important;
    }

    /* Mobile header */
    .header-actions {
        gap: 8px !important;
    }

    .header-actions .action-btn {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Search bar mobile */
    .search-bar {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        padding: 8px 16px !important;
    }

    .search-bar input {
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 44px;
    }
}

/* === HERO SECTION MOBILE === */
@media (max-width: 768px) {
    .hero-section,
    .hero-slider {
        min-height: 50vh !important;
        max-height: 70vh !important;
    }

    .hero-content h1 {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
    }

    .hero-content p {
        font-size: 0.95rem !important;
    }

    .hero-dots {
        bottom: 16px !important;
    }

    .hero-dots .dot {
        min-width: 12px;
        min-height: 12px;
    }
}

/* === PRODUCT CARDS MOBILE === */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .product-card {
        border-radius: 10px !important;
    }

    .product-card .product-name {
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
    }

    .product-card .product-price {
        font-size: 0.9rem !important;
    }

    .product-card .add-to-cart-btn,
    .product-card .quick-view-btn {
        min-height: 40px !important;
        font-size: 0.8rem !important;
    }
}

@media (max-width: 375px) {
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
}

/* === FORMS MOBILE === */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
        min-height: 48px;
        padding: 12px 16px !important;
    }

    .form-row,
    .form-grid,
    .checkout-form .form-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 6px !important;
    }

    /* Error messages readable */
    .error-message,
    .field-error,
    #card-errors {
        font-size: 12px !important;
        padding: 4px 0 !important;
    }
}

/* === CHECKOUT MOBILE === */
@media (max-width: 768px) {
    .payment-methods {
        gap: 8px !important;
    }

    .payment-card {
        padding: 12px !important;
        min-height: 56px;
    }

    .payment-card label {
        gap: 10px !important;
    }

    .order-summary {
        position: static !important; /* Don't stick on mobile */
    }

    .btn-place-order {
        min-height: 52px !important;
        font-size: 1rem !important;
        width: 100% !important;
    }

    .trust-badges {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .cod-fee-row,
    .summary-row {
        font-size: 0.9rem !important;
    }
}

/* === CART MOBILE === */
@media (max-width: 768px) {
    .cart-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .cart-item-image {
        width: 80px !important;
        height: 80px !important;
    }

    .quantity-controls {
        min-height: 44px;
    }

    .quantity-controls button {
        min-width: 36px;
        min-height: 36px;
    }

    .coupon-input-group {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .coupon-input-group input {
        width: 100% !important;
    }

    .coupon-input-group button {
        width: 100% !important;
        min-height: 44px;
    }
}

/* === PRODUCT PAGE MOBILE === */
@media (max-width: 768px) {
    .product-gallery {
        max-height: 400px !important;
    }

    .product-thumbnails {
        gap: 8px !important;
    }

    .product-thumbnail {
        width: 60px !important;
        height: 60px !important;
    }

    .product-info {
        padding: 20px 16px !important;
    }

    .product-tabs .tab-btn {
        min-height: 44px;
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
    }

    .mobile-sticky-cart {
        box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    }
}

/* === MODALS & OVERLAYS MOBILE === */
@media (max-width: 768px) {
    .quick-view-modal,
    .lightbox-overlay {
        padding: 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .quick-view-content {
        max-height: 90vh !important;
        overflow-y: auto !important;
        border-radius: 12px !important;
    }

    .modal-close,
    .quick-view-close,
    .lightbox-close {
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        top: 8px !important;
        right: 8px !important;
    }
}

/* === SIDEBAR LAYOUTS COLLAPSE === */
@media (max-width: 768px) {
    .shop-layout,
    .cart-layout,
    .checkout-layout,
    .account-layout,
    .blog-layout,
    .tracking-layout,
    .two-column-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .shop-sidebar,
    .cart-summary,
    .checkout-sidebar,
    .account-sidebar,
    .blog-sidebar,
    .order-summary {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* === FOOTER MOBILE === */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
        text-align: center;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-social a {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .footer-bottom {
        flex-direction: column !important;
        gap: 12px !important;
        text-align: center;
    }
}

/* === WHATSAPP BUTTON SAFE AREA === */
@media (max-width: 768px) {
    .whatsapp-float {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        right: 16px !important;
        width: 52px !important;
        height: 52px !important;
    }

    .wa-tooltip {
        display: none !important;
    }
}

/* === TOAST NOTIFICATIONS MOBILE === */
@media (max-width: 768px) {
    .store-toast {
        left: 16px !important;
        right: 16px !important;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        max-width: none !important;
        font-size: 0.9rem !important;
    }
}

/* === COUNTDOWN TIMERS MOBILE === */
@media (max-width: 768px) {
    .countdown-timer {
        gap: 6px !important;
    }

    .countdown-unit {
        min-width: 45px;
        padding: 6px 4px !important;
        font-size: 0.8rem !important;
    }
}

/* === BACK TO TOP MOBILE === */
@media (max-width: 768px) {
    .back-to-top {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
        right: 16px !important;
        width: 44px !important;
        height: 44px !important;
    }
}

/* === SCROLL PROGRESS BAR === */
@media (max-width: 768px) {
    .scroll-progress-bar {
        height: 3px !important;
    }
}

/* === ANNOUNCEMENT BAR MOBILE === */
@media (max-width: 768px) {
    .announcement-bar {
        font-size: 0.8rem !important;
        padding: 8px 16px !important;
    }
}

/* === HIDE DESKTOP-ONLY ELEMENTS === */
@media (max-width: 768px) {
    .desktop-only,
    .luxury-cursor,
    .luxury-cursor-ring {
        display: none !important;
    }
}

/* === iOS INPUT ZOOM PREVENTION === */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        input, select, textarea {
            font-size: 16px !important;
        }
    }
}

/* === SAFE AREA PADDING FOR FIXED ELEMENTS === */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-sticky-cart,
    .mobile-bottom-nav {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}

/* === PRINT STYLES === */
@media print {
    .whatsapp-float,
    .back-to-top,
    .scroll-progress-bar,
    .mobile-sticky-cart,
    .store-toast {
        display: none !important;
    }
}
