/* 
 * Responsive Design
 * Mobile-first approach
 */

/* Hide scrollbar for horizontal sliders */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Snap scroll behavior */
.snap-x {
    scroll-snap-type: x mandatory;
}
.snap-start {
    scroll-snap-align: start;
}
.snap-mandatory {
    scroll-snap-type: x mandatory;
}

/* ============================================
   Tablet (768px and below)
   ============================================ */

@media (max-width: 768px) {
    /* Header */
    .top-bar-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .top-bar-left,
    .top-bar-right {
        width: 100%;
        justify-content: center;
    }
    
    .header-content {
        flex-wrap: wrap;
    }
    
    .search-bar {
        order: 3;
        width: 100%;
        max-width: 100%;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Navigation */
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: #ffffff;
        flex-direction: column;
        padding: 20px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        transition: left 0.3s ease;
        z-index: 9999;
        overflow-y: auto;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-menu > li {
        width: 100%;
    }
    
    .nav-menu > li > a {
        color: #1e293b;
        padding: 15px 10px;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        margin-left: 20px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .dropdown.active .dropdown-menu {
        max-height: 500px;
    }
    
    /* Banner - Fixed for mobile */
    .banner-slider,
    .carousel {
        height: 300px !important;
    }
    
    .carousel-item {
        scroll-snap-align: center;
    }
    
    .banner-content h1 {
        font-size: 24px !important;
    }
    
    .banner-content p {
        font-size: 14px !important;
    }
    
    /* Smooth carousel scrolling on mobile */
    .carousel {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Product Cards - 2 columns on mobile */
    .grid-cols-2 {
        gap: 12px;
    }
    
    /* Better touch targets on mobile */
    .btn-xs {
        min-height: 2rem;
        padding: 0 0.75rem;
        font-size: 0.75rem;
    }
    
    .btn-sm {
        min-height: 2.5rem;
    }
    
    /* Category cards */
    .category-card {
        padding: 1rem !important;
    }
    
    /* Hide "Voir tout" text on mobile, show icon only */
    .md\\:flex.hidden {
        display: none !important;
    }
    
    /* Product card improvements for mobile */
    .line-clamp-2 {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
    
    /* Banner */
    .banner-prev,
    .banner-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Sections */
    .section-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .section-header h2 {
        font-size: 24px;
    }
    
    /* Grids */
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .product-image {
        height: 200px;
    }
    
    .product-info {
        padding: 15px;
    }
    
    .product-title {
        font-size: 14px;
        height: 42px;
    }
    
    .current-price {
        font-size: 18px;
    }
    
    .old-price {
        font-size: 14px;
    }
    
    .add-to-cart-btn {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Newsletter */
    .newsletter-content h2 {
        font-size: 24px;
    }
    
    .newsletter-content p {
        font-size: 16px;
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
    }
    
    /* Auth */
    .auth-box {
        padding: 30px 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Mobile (480px and below)
   ============================================ */

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 0 15px;
    }
    
    /* Header */
    .logo h1 {
        font-size: 22px;
    }
    
    .logo img {
        max-height: 40px;
    }
    
    .main-header {
        padding: 15px 0;
    }
    
    /* Banner */
    .banner-slider {
        height: 250px;
    }
    
    .banner-content h1 {
        font-size: 22px;
    }
    
    .banner-content p {
        font-size: 14px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    /* Sections */
    .features-section,
    .categories-section,
    .products-section,
    .newsletter-section {
        padding: 40px 0;
    }
    
    .section-header h2 {
        font-size: 20px;
    }
    
    /* Feature Items */
    .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    .feature-item h3 {
        font-size: 16px;
    }
    
    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-card {
        padding: 20px 15px;
    }
    
    .category-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    
    /* Products */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .product-card {
        border-radius: 6px;
    }
    
    .product-image {
        height: 160px;
    }
    
    .product-info {
        padding: 10px;
    }
    
    .product-title {
        font-size: 13px;
        height: 38px;
    }
    
    .current-price {
        font-size: 16px;
    }
    
    .old-price {
        font-size: 13px;
    }
    
    .add-to-cart-btn {
        padding: 8px;
        font-size: 13px;
    }
    
    .add-to-cart-btn span {
        display: none;
    }
    
    /* Newsletter */
    .newsletter-content h2 {
        font-size: 20px;
    }
    
    .newsletter-content p {
        font-size: 14px;
    }
    
    /* Footer */
    .footer-top {
        padding: 40px 0 20px;
    }
    
    .footer-col h3 {
        font-size: 18px;
    }
    
    /* Scroll to Top */
    .scroll-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .header,
    .footer,
    .scroll-to-top,
    .newsletter-section,
    .add-to-cart-btn {
        display: none !important;
    }
}

/* ============================================
   Cart & Checkout Page Responsive Fixes
   ============================================ */

@media (max-width: 768px) {
    /* Cart page grid */
    .lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
    
    .lg\:col-span-2 {
        grid-column: span 1 !important;
    }
    
    /* Cart item layout */
    .cart-item-row {
        flex-direction: column;
    }
    
    /* Make cart summary full width on mobile */
    .lg\:col-span-1 {
        grid-column: span 1 !important;
    }
    
    /* Order summary sticky positioning */
    .sticky.top-20 {
        position: relative !important;
        top: 0 !important;
    }
    
    /* Quantity controls */
    .join .btn-xs {
        min-width: 32px;
        min-height: 32px;
    }
    
    .join .input-xs {
        width: 40px !important;
        text-align: center;
    }
}

@media (max-width: 480px) {
    /* Progress steps - make more compact */
    .flex.items-center.justify-center.gap-2 {
        gap: 0.25rem !important;
    }
    
    /* Cart items - stack vertically */
    .cart-item .flex {
        flex-direction: column;
    }
    
    /* Smaller product images on very small screens */
    .w-24.sm\:w-32 {
        width: 80px !important;
    }
    
    /* Better quantity row layout */
    .flex-col.sm\:flex-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    /* Full width subtotal box */
    .text-right.bg-primary\/5 {
        width: 100%;
        text-align: center !important;
    }
}

/* ============================================
   Order Success Page Responsive Fixes
   ============================================ */

@media (max-width: 768px) {
    /* Order details grid - scoped to order pages */
    .order-success-page .grid-cols-2,
    .order-details-page .grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Success icon smaller on mobile */
    .w-20.h-20 {
        width: 4rem !important;
        height: 4rem !important;
    }
    
    .w-20.h-20 .text-4xl {
        font-size: 2rem !important;
    }
    
    /* Order card padding - scoped */
    .order-success-page .p-6,
    .order-details-page .p-6 {
        padding: 1rem !important;
    }
    
    /* Action buttons */
    .flex-col.sm\:flex-row {
        flex-direction: column !important;
    }
    
    .flex-col.sm\:flex-row > .flex-1 {
        width: 100%;
    }
}

@media (max-width: 480px) {
    /* Even smaller heading */
    h1.text-3xl {
        font-size: 1.25rem !important;
    }
    
    /* Badge size */
    .badge-lg {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    /* Container padding */
    .container.mx-auto.px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Card max-width for very small screens */
    .max-w-2xl {
        max-width: 100% !important;
    }
}


/* ============================================
   MOBILE PREMIUM EXPERIENCE
   Clean, Consistent Mobile UI
   ============================================ */

@media (max-width: 768px) {

    /* ---- GLOBAL ---- */
    body {
        -webkit-text-size-adjust: 100%;
    }

    .container.mx-auto {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* ---- HEADER COMPACT ---- */
    .header-topbar .container .flex.items-center.justify-between {
        padding-top: 0.35rem !important;
        padding-bottom: 0.35rem !important;
    }

    .header-main .container .flex.items-center {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        gap: 0.5rem !important;
    }

    .site-logo img {
        height: 32px !important;
        max-height: 32px !important;
    }

    .site-logo .w-9.h-9 {
        width: 32px !important;
        height: 32px !important;
    }

    .site-logo .text-xl {
        font-size: 1.05rem !important;
    }

    /* Header action buttons */
    .header-main .w-10.h-10 {
        width: 38px !important;
        height: 38px !important;
    }

    .cart-badge {
        width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
        top: -2px !important;
        right: -2px !important;
    }

    /* ---- HERO SLIDER ---- */
    .hero-carousel,
    section[aria-label*="Bannière"],
    section[aria-label*="البانر"] {
        border-radius: 0 !important;
    }

    .hero-carousel .carousel,
    section[aria-label*="Bannière"] .carousel,
    section[aria-label*="البانر"] .carousel {
        min-height: 220px !important;
    }

    .hero-carousel .carousel-item,
    .hero-slide {
        min-height: 220px !important;
    }

    /* Hero CTA buttons */
    .hero-cta {
        gap: 8px !important;
    }

    .hero-cta .btn {
        font-size: 0.75rem !important;
        padding: 0.5rem 1rem !important;
        min-height: unset !important;
        height: auto !important;
        border-radius: 8px !important;
    }

    /* Nav arrows - smaller */
    .hero-carousel .btn-circle,
    section[aria-label*="Bannière"] .btn-circle,
    section[aria-label*="البانر"] .btn-circle {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        font-size: 0.75rem !important;
    }

    /* ---- BENEFITS SECTION ---- */
    .benefits-mobile-scroll {
        display: flex !important;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 8px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .benefits-mobile-scroll::-webkit-scrollbar { display: none; }

    .benefits-mobile-scroll > * {
        flex: 0 0 auto;
        width: 150px;
        scroll-snap-align: start;
    }

    .benefit-chip {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 14px 10px;
        background: white;
        border-radius: 14px;
        border: 1px solid #f0f0f0;
        text-align: center;
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }

    .benefit-chip .benefit-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
    }

    .benefit-chip .benefit-title {
        font-size: 0.7rem;
        font-weight: 700;
        color: #1f2937;
        line-height: 1.3;
    }

    .benefit-chip .benefit-desc {
        font-size: 0.6rem;
        color: #6b7280;
        line-height: 1.3;
    }

    /* Grid benefits - horizontal scroll */
    .benefits-grid-mobile {
        display: flex !important;
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
        padding-bottom: 6px !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }
    .benefits-grid-mobile::-webkit-scrollbar { display: none; }
    .benefits-grid-mobile > div {
        flex: 0 0 44%;
        min-width: 155px;
    }

    /* ---- CATEGORIES SECTION ---- */
    .categories-scroll-mobile {
        display: flex !important;
        overflow-x: auto;
        flex-wrap: nowrap !important;
        gap: 12px !important;
        padding-bottom: 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }
    .categories-scroll-mobile::-webkit-scrollbar { display: none; }
    .categories-scroll-mobile > a {
        flex: 0 0 auto;
        width: 85px;
        scroll-snap-align: start;
    }
    .categories-scroll-mobile > a .aspect-square {
        width: 76px;
        height: 76px;
    }
    .categories-scroll-mobile > a .rounded-2xl {
        border-radius: 16px !important;
    }
    .categories-scroll-mobile > a h3 {
        margin-top: 0.5rem !important;
        font-size: 0.65rem !important;
    }

    /* ---- PRODUCT CARDS MOBILE ---- */
    .product-grid {
        gap: 10px !important;
    }

    .product-card {
        border-radius: 12px !important;
        border-color: #f0f0f0 !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important;
    }

    .product-card:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s !important;
    }

    .product-card__image {
        border-radius: 12px 12px 0 0 !important;
    }

    .product-card__body {
        padding: 10px 12px 12px !important;
    }

    .product-card__title {
        font-size: 0.8rem !important;
        min-height: 34px !important;
        margin-bottom: 6px !important;
        line-height: 1.4 !important;
    }

    .product-card__price {
        font-size: 0.95rem !important;
        font-weight: 800 !important;
    }

    .product-card__price-old {
        font-size: 0.7rem !important;
    }

    .product-card__price-row {
        margin-bottom: 8px !important;
        gap: 5px !important;
    }

    .product-card__btn {
        padding: 8px 10px !important;
        font-size: 0.75rem !important;
        border-radius: 8px !important;
        gap: 6px !important;
        font-weight: 700 !important;
    }

    .product-card__btn i {
        font-size: 0.7rem !important;
    }

    .product-card__wishlist {
        width: 30px !important;
        height: 30px !important;
        top: 8px !important;
        right: 8px !important;
        opacity: 1 !important;
        font-size: 0.75rem;
    }

    .badge-sale,
    .badge-new,
    .badge-featured,
    .badge-hot {
        top: 8px !important;
        left: 8px !important;
        padding: 3px 8px !important;
        font-size: 0.65rem !important;
        border-radius: 6px !important;
    }

    .product-card__rating {
        font-size: 0.65rem !important;
        margin-bottom: 3px !important;
    }

    /* ---- SECTION HEADERS ---- */
    .section-header {
        margin-bottom: 1rem !important;
    }

    .section-header h2 {
        font-size: 1.15rem !important;
    }

    .section-header .text-sm,
    .section-header .text-gray-500 {
        font-size: 0.75rem !important;
    }

    /* "View All" mobile button */
    .mt-6.text-center.sm\:hidden .btn {
        font-size: 0.75rem !important;
        padding: 0.4rem 1.2rem !important;
        border-radius: 20px !important;
        min-height: unset !important;
        height: auto !important;
    }

    /* ---- REVIEWS SECTION ---- */
    .review-card {
        padding: 1rem !important;
        border-radius: 14px !important;
    }

    /* ---- TRUST BADGES ---- */
    .trust-strip-mobile {
        display: flex !important;
        overflow-x: auto;
        gap: 1.25rem;
        padding: 0 16px 4px;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
    }
    .trust-strip-mobile::-webkit-scrollbar { display: none; }

    .trust-strip-mobile > div {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* ---- FOOTER COMPACT ---- */
    .site-footer > .container {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .site-footer .grid {
        gap: 1.5rem !important;
    }

    .footer-heading {
        font-size: 0.8rem !important;
        margin-bottom: 0.75rem !important;
    }

    .footer-link {
        font-size: 0.8rem !important;
        padding: 0.2rem 0 !important;
    }

    /* ---- MOBILE BOTTOM NAV ---- */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255,255,255,0.97);
        border-top: 1px solid #e5e7eb;
        z-index: 9990;
        padding: 0.35rem 0;
        padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-bottom-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 0.35rem 0;
        color: #9ca3af;
        text-decoration: none;
        font-size: 0.625rem;
        font-weight: 600;
        transition: color 0.2s;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-bottom-nav__item.active {
        color: var(--primary);
    }

    .mobile-bottom-nav__item.active::before {
        content: '';
        position: absolute;
        top: -1px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 2px;
        background: var(--primary);
        border-radius: 2px;
    }

    .mobile-bottom-nav__item i {
        font-size: 1.15rem;
        line-height: 1;
    }

    .mobile-bottom-nav__badge {
        position: absolute;
        top: 0;
        right: calc(50% - 14px);
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        background: var(--primary);
        color: white;
        font-size: 0.6rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
    }

    /* Push content up from bottom nav */
    body {
        padding-bottom: 64px !important;
    }

    .site-footer {
        margin-bottom: 0 !important;
    }

    /* Move floating buttons above bottom nav */
    .whatsapp-fab,
    .whatsapp-float {
        bottom: 76px !important;
    }

    .scroll-to-top,
    #scroll-to-top {
        bottom: 136px !important;
    }

    /* ---- MISC MOBILE POLISH ---- */
    .btn, button, a {
        -webkit-tap-highlight-color: transparent;
    }

    img {
        background-color: #f8f9fa;
    }

    /* Flash messages */
    .flash-message {
        margin: 0.5rem 0.75rem !important;
        padding: 0.75rem 1rem !important;
        font-size: 0.8rem !important;
        border-radius: 10px !important;
    }
}

/* ---- EXTRA SMALL SCREENS (< 380px) ---- */
@media (max-width: 380px) {
    .hero-cta .btn {
        font-size: 0.65rem !important;
        padding: 0.4rem 0.8rem !important;
    }

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

    .product-card__body {
        padding: 8px 10px 10px !important;
    }

    .product-card__title {
        font-size: 0.72rem !important;
        min-height: 30px !important;
    }

    .product-card__price {
        font-size: 0.85rem !important;
    }

    .product-card__btn {
        padding: 7px 8px !important;
        font-size: 0.68rem !important;
    }

    .benefits-mobile-scroll > * {
        width: 130px;
    }

    .categories-scroll-mobile > a {
        width: 72px;
    }
}
