/**
 * ============================================================================
 * MOBILE RESPONSIVE CSS - UNIFIED
 * ============================================================================
 * Fichier CSS consolidé pour une expérience mobile parfaite
 * Compatible: Android Chrome + iOS Safari
 * Version: 1.0
 */

/* ============================================================================
   VARIABLES CSS MOBILE
   ============================================================================ */
:root {
    /* Touch-Friendly Sizes */
    --touch-target-min: 44px;
    --touch-target-recommended: 48px;

    /* Mobile Spacing */
    --mobile-padding: 16px;
    --mobile-gap: 12px;

    /* Dynamic Viewport Height (iOS fix) */
    --vh: 1vh;

    /* Safe Area Insets (iPhone notch/Dynamic Island) */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* ============================================================================
   MOBILE FOUNDATION
   ============================================================================ */

/* Prevent horizontal scroll on all devices */
html,
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Smooth scrolling with momentum on iOS */
body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Disable text selection inflation on Android */
* {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ============================================================================
   MOBILE BREAKPOINTS - UNIFIED
   ============================================================================ */

/* Very Small Mobile (320px - 479px) */
@media (max-width: 479px) {
    .container {
        padding: 0 var(--mobile-padding);
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

/* Mobile Portrait (480px - 767px) */
@media (max-width: 767px) {

    /* HERO SECTION */
    .hero-slider {
        height: calc(var(--vh, 1vh) * 60);
        min-height: 400px;
    }

    .hero-video {
        object-fit: cover;
    }

    /* NAVIGATION - Hide desktop nav, show mobile */
    .main-nav {
        display: none !important;
    }

    .mobile-nav-toggle {
        display: flex !important;
    }

    /* HEADER */
    .site-header {
        padding: 0 var(--mobile-padding);
    }

    .header-container {
        padding: 0;
        height: 50px;
    }

    .header-icons {
        gap: 0.75rem;
    }

    .logo img {
        height: 28px;
    }

    /* GRIDS - Single Column */
    .grid-3,
    .grid-4,
    .product-grid,
    .promo-grid {
        grid-template-columns: 1fr !important;
        gap: var(--mobile-gap);
    }

    /* FEATURES GRID */
    .features-section .grid-3 {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .feature-box {
        padding: 1rem;
        border-radius: 12px;
        background: var(--white);
        box-shadow: var(--shadow-sm);
    }

    /* SECTIONS SPACING */
    .py-5 {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    /* PRODUCT CARDS */
    .product-card,
    .promo-card {
        margin: 0 auto;
        max-width: 100%;
    }

    .product-img,
    .promo-img {
        height: 200px;
    }

    .product-info,
    .promo-info {
        padding: 14px 16px 16px;
    }

    /* BUTTONS - Touch Optimized */
    .btn,
    .tab-btn,
    .promo-btn {
        min-height: var(--touch-target-min);
        padding: 12px 24px;
        font-size: 0.95rem;
    }

    /* TABS */
    .tabs {
        flex-wrap: wrap;
        gap: 8px;
        padding: 6px;
    }

    .tab-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    /* CART SIDEBAR - Full Width */
    .cart-sidebar {
        width: 100vw !important;
        right: -100vw;
    }

    .cart-sidebar.open {
        right: 0;
    }

    /* MODALS - Full Screen */
    .detail-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        overflow-y: auto;
    }

    .detail-grid {
        grid-template-columns: 1fr !important;
    }

    .detail-gallery {
        padding: 20px;
    }

    .main-image-container {
        height: 300px;
    }

    .detail-info {
        padding: 20px;
    }

    /* PRODUCTS MODAL - Full Screen */
    .products-modal-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .products-modal-body {
        padding: var(--mobile-padding);
    }

    /* FOOTER */
    .site-footer .grid-4 {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .footer-col {
        text-align: center;
    }

    /* TECH EXCELLENCE SECTION */
    .tech-qa-container {
        padding: 0;
    }

    .tech-question {
        padding: 16px;
        font-size: 0.95rem;
    }

    .tech-answer {
        padding: 16px;
    }

    /* FLOATING BUTTONS */
    .floating-buttons {
        bottom: calc(20px + var(--safe-area-bottom));
        right: calc(16px + var(--safe-area-right));
    }

    .floating-btn {
        width: 52px;
        height: 52px;
    }

    /* WELCOME BANNER */
    .welcome-banner {
        font-size: 0.85rem;
        padding: 10px;
    }
}

/* Tablet Portrait (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {

    .product-grid,
    .promo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }

    .hero-slider {
        height: 500px;
    }
}

/* ============================================================================
   MOBILE NAVIGATION - HAMBURGER MENU
   ============================================================================ */

/* Mobile Toggle Button */
.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    z-index: 1001;
}

.mobile-nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-dark);
    margin: 3px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

.mobile-nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile Menu Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Sidebar */
.mobile-nav-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--white);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(50px + var(--safe-area-top));
    padding-bottom: var(--safe-area-bottom);
}

.mobile-nav-sidebar.active {
    left: 0;
}

.mobile-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-menu li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.mobile-nav-menu a {
    display: block;
    padding: 18px 24px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
}

.mobile-nav-menu a:active {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-nav-menu a.active {
    color: var(--primary-color);
    background: rgba(197, 160, 89, 0.05);
}

/* Mobile Megamenu (Accordion) */
.mobile-megamenu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 18px 24px;
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    text-align: left;
    cursor: pointer;
    min-height: var(--touch-target-min);
}

.mobile-megamenu-toggle i {
    transition: transform 0.3s ease;
}

.mobile-megamenu-toggle.active i {
    transform: rotate(180deg);
}

.mobile-megamenu-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.02);
}

.mobile-megamenu-content.active {
    max-height: 3000px;
    /* Large enough for many categories */
    overflow-y: visible;
}

.mobile-megamenu-category {
    padding: 12px 24px 12px 40px;
}

.mobile-megamenu-category-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.mobile-megamenu-category a {
    display: block;
    padding: 12px 0;
    font-size: 0.95rem;
    color: var(--text-dark);
    font-weight: 400;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

/* Expanded state for subcategories on mobile click */
.mobile-megamenu-category-title {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.mobile-megamenu-category-title::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--accent-color);
}

.mobile-megamenu-category.expanded .mobile-megamenu-category-title::after {
    content: '-';
}

/* ============================================================================
   TOUCH INTERACTIONS
   ============================================================================ */

/* Disable tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Custom tap highlight for interactive elements */
a,
button,
.product-card,
.promo-card {
    -webkit-tap-highlight-color: rgba(197, 160, 89, 0.1);
}

/* Active states for touch */
.btn:active,
.tab-btn:active,
.product-card:active,
.promo-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* Prevent double-tap zoom on buttons */
button,
.btn,
a.btn {
    touch-action: manipulation;
}

/* ============================================================================
   iOS SAFE AREAS
   ============================================================================ */

@supports (padding: max(0px)) {
    .site-header {
        padding-left: max(var(--mobile-padding), var(--safe-area-left));
        padding-right: max(var(--mobile-padding), var(--safe-area-right));
    }

    .site-footer {
        padding-bottom: max(2rem, var(--safe-area-bottom));
    }

    .cart-sidebar {
        padding-bottom: max(20px, var(--safe-area-bottom));
    }
}

/* ============================================================================
   ANDROID CHROME OPTIMIZATIONS
   ============================================================================ */

/* Remove 300ms click delay on Android */
a,
button,
input,
select,
textarea {
    touch-action: manipulation;
}

/* Optimize scrolling performance */
.product-grid,
.promo-grid,
.cart-items {
    will-change: scroll-position;
}

/* Hardware acceleration for smooth animations */
.product-card,
.promo-card,
.btn,
.floating-btn {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ============================================================================
   ACCESSIBILITY & VISIBILITY
   ============================================================================ */

/* Ensure minimum text size for readability */
@media (max-width: 767px) {
    body {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    input,
    textarea,
    select {
        font-size: 16px;
        /* Prevents zoom on focus */
    }
}

/* Focus states for keyboard navigation */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

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

/* Lazy load images - optimize initial paint */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Reduce animation on low-end devices */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   DARK MODE MOBILE SUPPORT
   ============================================================================ */

@media (max-width: 767px) {
    [data-theme="dark"] .mobile-nav-sidebar {
        background: #1a1a1d;
    }

    [data-theme="dark"] .mobile-nav-menu a {
        color: #f5f5f7;
    }

    [data-theme="dark"] .mobile-nav-menu li {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Responsive text alignment */
@media (max-width: 767px) {
    .mobile-text-center {
        text-align: center !important;
    }
}