/* ============================================================
   RESPONSIVE STYLES - Mobile First
   ============================================================ */

/* Performance & Scrolling Optimizations */
html, body {
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Hardware acceleration for smooth scrolling */
.hero-section, .product-card {
  transform: translateZ(0);
  will-change: transform;
}

/* Fix sticky scrolling on iOS for popups */
.checkout-modal, .mini-cart, .quickview-modal, .checkout-content, .quickview-content, .auth-modal {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

* {
  -webkit-tap-highlight-color: transparent;
}


/* Small phones (< 576px) */
@media (max-width: 575.98px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  
  .section-title { font-size: 1.35rem; }
  .section-spacing { padding: 30px 0; }
  
  /* Category Page Specific Mobile Spacing */
  .container-category-grid {
    padding-left: 20px !important;
    padding-right: 20px !important;
    overflow: visible !important;
  }
  
  #categoryGrid {
    margin-left: -5px;
    margin-right: -5px;
    overflow: visible !important;
  }
  
  #categoryGrid > div {
    padding-left: 8px;
    padding-right: 8px;
  }
  
  .category-info-bar {
    background: var(--white);
    box-shadow: var(--shadow-card);
    margin-left: 0;
    margin-right: 0;
  }
  
  .mobile-filter-btn {
    border-radius: var(--radius-lg);
  }
  
  /* Header */
  .header-top > .d-flex { position: relative; }
  .header-logo { 
    position: absolute; 
    left: 50%; 
    top: 50%;
    transform: translate(-50%, -50%); 
    margin: 0 !important;
    z-index: 10;
    max-width: 140px;
    justify-content: center;
  }
  .header-logo img {
    max-height: 40px !important;
    width: auto;
  }
  .header-logo .logo-text { font-size: 1.3rem; }
  .search-wrapper { display: none; }
  .search-wrapper.mobile-active {
    display: flex !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--white);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    max-width: 100%;
    z-index: 1001;
    border-top: 1px solid var(--gray-100);
    animation: mobileSearchSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  @keyframes mobileSearchSlideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  
  .mobile-menu-btn { display: flex; }
  
  .mega-nav .navbar-collapse {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background: var(--white);
    z-index: var(--z-drawer);
    transition: left var(--transition-base);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 0; /* Removed padding for tab system */
  }
  
  .mega-nav .navbar-collapse.show {
    left: 0;
  }

  .mega-nav .navbar-collapse {
    top: 0;
    height: 100vh;
    will-change: transform;
    z-index: var(--z-drawer);
  }

  .nav-drawer-tab {
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
  }
  
  .mobile-tab-btn {
    border: none;
    background: #f8f9fa;
    padding: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-500);
    transition: all 0.3s ease;
  }
  .mobile-tab-btn.active {
    background: var(--white);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
  }
  
  .mobile-nav-header #mobileSearchDropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 250px;
    background: #fff;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-radius: 0 0 10px 10px;
  }
  
  .mobile-nav-header #mobileSearchDropdown .search-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
  }
  
  .mobile-nav-header .search-wrapper {
    display: block !important;
  }

  .mega-nav .nav-link {
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.95rem;
  }
  
  .mega-nav .nav-link i {
    width: 24px;
    text-align: center;
    color: var(--primary);
    font-size: 1.1rem;
    vertical-align: middle;
    margin-right: 8px;
  }

  /* Visual Category Grid */
  .category-mobile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    padding-bottom: 30px;
  }
  .category-mobile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #eee;
    border-radius: var(--radius-lg);
    padding: 16px 10px;
    text-align: center;
    text-decoration: none !important;
    transition: all 0.3s ease;
  }
  .category-mobile-card:active {
    background: #f8f9fa;
    transform: scale(0.97);
  }
  .cat-card-icon {
    margin-bottom: 8px;
  }
  .nav-cat-grid-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
  }
  .cat-card-icon i {
    font-size: 1.8rem;
    color: var(--primary);
  }
  .cat-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.2;
    display: block;
  }
  
  /* Hero */
  .hero-section { padding: 15px 12px 0; }
  .hero-slider-wrap, .hero-side-banner { height: auto !important; border-radius: 12px !important; }
  .hero-slide .slide-title { font-size: 1.3rem; margin-bottom: 8px; font-weight: 800; text-shadow: 2px 2px 10px rgba(0,0,0,0.8); }
  .hero-slide .slide-desc { font-size: 0.75rem; display: none; }
  .hero-slide .slide-tag { margin-bottom: 8px; padding: 3px 10px; font-size: 0.55rem; }
  .hero-slide .slide-content { padding: 0; }
  .slide-content-wrap { padding: 0 40px; }
  .slider-arrow { display: none; }
  .slider-dots { left:50%; transform: translateX(-50%); bottom: 8px; }
  .hero-slide .slide-btn { padding: 5px 15px; font-size: 0.7rem; border-radius: 20px; }
  
  /* Products */
  .product-card .product-info { padding: 12px; }
  .product-name { font-size: 0.85rem; }
  .product-price { font-size: 1rem; }
  .product-card .add-to-cart-btn { padding: 8px 12px; font-size: 0.8rem; }
  
  /* Category */
  .category-card { 
    width: 150px; 
    height: 180px; 
    padding: 15px 8px;
    border-radius: 12px;
  }
  .category-card .cat-icon { 
    width: 75px; 
    height: 75px; 
    font-size: 2rem; 
    margin-bottom: 10px;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    overflow: hidden;
  }
  .category-card .cat-name { 
    font-size: 0.85rem; 
  }
  .category-card .cat-count {
    font-size: 0.7rem;
  }
  
  /* Offer Section */
  .offer-section { padding: 30px 15px; }
  .countdown-wrap { gap: 6px !important; }
  .countdown-item { padding: 6px 4px !important; min-width: 45px !important; }
  .countdown-number { font-size: 1.1rem !important; }
  .countdown-label { font-size: 0.6rem !important; }
  
  /* Spacing */
  .section-spacing { padding: 40px 0 !important; }

  /* Quick View & Single Product Page Buttons */
  .quickview-body { grid-template-columns: 1fr; padding: 10px; gap: 0; }
  .qv-gallery { border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 0; }
  .qv-info { padding: 15px 20px; }
  .qv-name { font-size: 1.25rem; font-weight: 800; }
  .qv-price { font-size: 1.4rem; }
  
  .qv-buttons { 
    display: flex !important;
    flex-direction: row !important; 
    flex-wrap: nowrap !important;
    gap: 10px !important; 
    margin-bottom: 20px !important;
  }
  
  .qv-buttons .btn-global,
  .qv-buttons .btn-add-cart, 
  .qv-buttons .btn-buy-now { 
    width: 50% !important;
    flex: 1 !important;
    font-size: 14px !important; 
    padding: 10px 8px !important; 
    white-space: nowrap !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .product-single-container {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  .qv-contact-btns { flex-direction: row; gap: 8px; }
  .qv-contact-btns a { flex: 1; font-size: 14px; padding: 10px; }

  /* Navigation arrows scaling for mobile */
  .qv-main-swiper .swiper-button-next,
  .qv-main-swiper .swiper-button-prev {
    transform: scale(0.65);
    background: rgba(255,255,255,0.8);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    color: var(--primary);
  }
  .qv-main-swiper .swiper-button-next::after,
  .qv-main-swiper .swiper-button-prev::after {
    font-size: 18px;
    font-weight: bold;
  }
  .qv-main-swiper .swiper-button-next { right: 5px; }
  .qv-main-swiper .swiper-button-prev { left: 5px; }
  
  /* Single Step Checkout Responsive */
  .checkout-main-content {
    grid-template-columns: 1fr;
    overflow-y: auto;
    max-height: 80vh;
  }
  .checkout-left-side {
    border-right: none;
    border-bottom: var(--border-light);
    padding: 20px;
  }
  .checkout-right-side {
    padding: 20px;
  }
  .checkout-content {
    max-width: 95vw;
  }

  .checkout-steps { flex-wrap: wrap; gap: 8px; }
  .step-connector { width: 20px; }
  .checkout-step .step-label { font-size: 0.72rem; }
  
  /* Mini Cart */
  /* Mini Cart - Full height and overlap everything */
  .mini-cart { 
    width: 92%; 
    max-width: none; 
    right: -92%; 
    top: 0; 
    height: 100vh;
    will-change: transform;
  }
  
  /* Disable expensive blurs and noise on mobile */
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: none !important;
  }

  body {
    background-image: none !important; /* Disable expensive noise/gradients on mobile */
  }
  
  /* Newsletter */
  .newsletter-form { flex-direction: column; }
  .newsletter-form button { width: 100%; }
  
  /* Footer Centering & Cleanup */
  .footer-box { text-align: center; border-radius: 15px; }
  .footer-contact-list li { justify-content: center; }
  .merged-links-grid { gap: 20px 40px; }
  .merged-link-col { flex: 0 0 calc(50% - 20px); text-align: center; }
  .payment-partner-row .payment-icons { gap: 15px; }
  .payment-partner-row .payment-icons img { height: 20px; }

  /* Toast */
  .toast-container { left: 10px; right: 10px; }
  .toast { min-width: auto; }

  /* Product Page Tabs (Mobile Accordion Style) */
  .nav-tabs#productTabs {
    flex-direction: column;
    border-bottom: none;
    gap: 8px;
  }
  .nav-tabs#productTabs .nav-item {
    width: 100%;
  }
  .nav-tabs#productTabs .nav-link {
    border: 1px solid var(--gray-200) !important;
    border-radius: var(--radius-md) !important;
    text-align: left;
    padding: 12px 15px;
    background: var(--gray-50);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--dark);
  }
  .nav-tabs#productTabs .nav-link.active {
    background: var(--primary);
    color: white !important;
    border-color: var(--primary) !important;
  }
  .nav-tabs#productTabs .nav-link::after {
    content: '\F282';
    font-family: 'bootstrap-icons';
    font-size: 0.8rem;
    transition: transform 0.3s ease;
  }
  .nav-tabs#productTabs .nav-link.active::after {
    transform: rotate(90deg);
  }
  .tab-content {
    margin-top: 15px;
    border: 1px solid var(--gray-200) !important;
    border-radius: var(--radius-md) !important;
    background: white;
  }
}

/* Tablets (576px - 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .mobile-menu-btn { display: flex; }
  .header-top > .d-flex { position: relative; }
  .header-logo { 
    position: absolute; 
    left: 50%; 
    transform: translateX(-50%); 
    margin: 0 !important;
    z-index: 10;
    max-width: 200px;
    justify-content: center;
  }
  .search-wrapper { max-width: 260px; }
  
  .hero-slider-wrap, .hero-side-banner { height: auto !important; }
  .hero-slide .slide-title { font-size: 2rem; }
  
  .quickview-body { grid-template-columns: 1fr; }
  .qv-gallery { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  
  .mega-nav .navbar-collapse {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    background: var(--white);
    z-index: var(--z-drawer);
    transition: left var(--transition-base);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 0;
  }
  
  .mega-nav .navbar-collapse.show {
    left: 0;
  }
}

/* Medium devices (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .mobile-menu-btn { display: flex; }
  .header-top > .d-flex { position: relative; }
  .header-logo { 
    position: absolute; 
    left: 50%; 
    transform: translateX(-50%); 
    margin: 0 !important;
    z-index: 10;
    max-width: 250px;
    justify-content: center;
  }
  
  .hero-slider-wrap, .hero-side-banner { height: auto !important; }
  .hero-slide .slide-title { font-size: 2.2rem; }
  
  .mega-nav .navbar-collapse {
    position: fixed;
    top: 0;
    left: -350px;
    width: 320px;
    height: 100vh;
    background: var(--white);
    z-index: var(--z-drawer);
    transition: left var(--transition-base);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 0;
  }
  
  .mega-nav .navbar-collapse.show {
    left: 0;
  }
}

/* Large devices (992px+) */
@media (min-width: 992px) {
  .mobile-menu-btn { display: none; }
  
  .mega-nav .navbar-collapse {
    display: flex !important;
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: visible;
  }
}

/* Checkout Mobile Unification (Force Single Continuous Flow) & Quick View Mobile Scroll Fix */
@media (max-width: 991.98px) {
  /* Quick View Modal mobile scroll fix */
  .quickview-modal.active {
    display: block !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 15px !important;
  }
  
  .quickview-modal .quickview-content {
    max-height: none !important;
    overflow-y: visible !important;
    margin: 10px auto 80px !important;
    width: 100% !important;
  }

  .checkout-modal {
    display: none !important; /* Keep hidden by default on mobile */
  }

  .checkout-modal.active {
    padding: 15px !important;
    display: block !important; /* Change to block for natural height growth */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: rgba(0,0,0,0.6) !important;
    height: 100% !important;
    min-height: 100vh !important;
    width: 100% !important;
    top: 0 !important;
    left: 0 !important;
    position: fixed !important;
    z-index: 9999 !important;
  }
  
  .checkout-modal .checkout-content {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    border-radius: 24px !important;
    display: block !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2) !important;
    transform: none !important;
    margin: 10px auto 60px !important; /* Increased bottom margin for better visibility */
    overflow: visible !important; /* Ensure content is NOT clipped */
    background: var(--white) !important;
  }

  .checkout-main-content {
    display: block !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: var(--white) !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Merge sides into a single unified column */
  .checkout-left-side, 
  .checkout-right-side {
    display: block !important;
    width: 100% !important;
    padding: 20px 15px !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  /* Remove the dividing background from the right side summary */
  .checkout-right-side {
    background: var(--white) !important;
    border-top: 1px solid var(--gray-100) !important; /* Thin clean line instead of a divider box */
    padding-bottom: 100px !important; /* Leave space at bottom */
  }
  
  /* Make headers consistent as section dividers */
  .checkout-section-title, 
  .checkout-right-side h5 {
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    margin-bottom: 20px !important;
    padding-bottom: 10px !important;
    border-bottom: 2px solid var(--gray-50) !important;
    color: var(--dark) !important;
    display: flex !important;
    align-items: center !important;
  }

  .order-review-items {
    max-height: none !important; /* NO scrollbars here */
    overflow: visible !important;
    padding-right: 0 !important;
    border: none !important;
  }

  .order-summary-item {
    border-bottom: 1px dashed var(--gray-100) !important;
    padding: 15px 0 !important;
  }

  .checkout-header {
    position: sticky;
    top: 0;
    z-index: 10000;
    background: var(--white);
    padding: 15px 20px !important;
    border-bottom: 1px solid var(--gray-100);
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  }

  .checkout-modal .quickview-backdrop {
    display: none !important;
  }
  
  /* Full width form elements */
  .form-floating-custom {
    margin-bottom: 20px !important;
  }
  
  .form-floating-custom input, 
  .form-floating-custom textarea {
    font-size: 16px !important; 
    padding: 12px 15px !important;
    border-radius: 12px !important;
    background: var(--gray-50) !important; /* Subtle contrast for form fields */
    border: 1px solid var(--gray-200) !important;
  }

  .delivery-area-options {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  
  .delivery-area-option {
    padding: 15px !important;
  }

  /* Carousel Navigation for Mobile */
  .carousel-nav {
    display: flex !important; /* Show arrows on mobile */
    opacity: 1 !important; /* Always visible on mobile for better UX */
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
  }
  
  .carousel-nav.prev { left: 0px !important; }
  .carousel-nav.next { right: 0px !important; }

  /* Coupon section unification */
  .coupon-input-wrap {
    background: var(--gray-50);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
  }
}

/* Extra large (1400px+) */
@media (min-width: 1400px) {
  .hero-slider { height: 560px; }
  .hero-slide .slide-title { font-size: 3.2rem; }
}

/* Mobile Bottom Nav Overrides */
@media (max-width: 991.98px) {
  body.has-bottom-nav {
    padding-bottom: 70px !important;
  }
}

/* Print */
@media print {
  .main-header,
  .news-ticker-bar,
  .main-footer,
  .mini-cart,
  .toast-container {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
}
