/* WooCommerce Integration Styles */
.woocommerce .button.alt {
  background-color: var(--mg-primary) !important;
  color: #ffffff !important;
}
.woocommerce span.onsale {
  background-color: #e11d48 !important;
}

/* ==========================================================================
   GLOBAL HEADER FIX FOR ALL PAGES (HOMEPAGE, SINGLE PRODUCTS, SHOP ARCHIVES)
   ========================================================================== */

header, .mg-header, #mg-site-header, .site-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 10000 !important;
  background-color: #ffffff !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06) !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}

header .container, .mg-header-inner, .mg-header .container, header .mg-header-inner {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 0.75rem 1.5rem !important;
  gap: 2rem !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
  width: 100% !important;
}

.mg-logo, a.custom-logo-link, header a.logo, header .logo, header .mg-logo {
  display: flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  max-width: 220px !important;
  height: 52px !important;
  max-height: 52px !important;
  margin: 0 !important;
}

.mg-logo-img, .mg-logo img, a.custom-logo-link img, img.custom-logo, header img, .mg-header img, header .logo img {
  height: 52px !important;
  max-height: 52px !important;
  width: auto !important;
  max-width: 220px !important;
  object-fit: contain !important;
  display: block !important;
}

.mg-nav, header nav, .mg-header nav {
  display: flex !important;
  align-items: center !important;
  flex-grow: 1 !important;
  justify-content: center !important;
}

.mg-nav-list, ul.mg-nav-list, .mg-nav ul, header nav ul {
  display: flex !important;
  list-style: none !important;
  gap: 2.2rem !important;
  margin: 0 !important;
  padding: 0 !important;
  align-items: center !important;
}

.mg-nav-list li, header nav ul li {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.mg-nav-list a, header nav ul li a {
  font-weight: 600 !important;
  color: #1e293b !important;
  font-size: 1.02rem !important;
  white-space: nowrap !important;
  text-decoration: none !important;
  transition: all 0.25s ease !important;
}

.mg-nav-list a:hover, header nav ul li a:hover {
  color: #0d5c3a !important;
}

.mg-header-actions, header .mg-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 1.2rem !important;
  flex-shrink: 0 !important;
}

@media (max-width: 1024px) {
  .mg-nav-list, header nav ul { gap: 1.2rem !important; }
}

@media (max-width: 850px) {
  .mg-nav, header nav { display: none !important; }
  .mg-mobile-toggle { display: flex !important; }
}

/* ==========================================================================
   ULTRA MOBILE RESPONSIVE DESIGN SYSTEM (320px - 768px Mobile Perfection)
   ========================================================================== */

/* Universal Viewport Boundary Guard */
html, body {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

.container, .mg-header-inner, .mg-topbar-inner, .mg-footer-grid {
  box-sizing: border-box !important;
  max-width: 100% !important;
}

/* Mobile Header & Topbar */
@media (max-width: 768px) {
  .mg-topbar {
    padding: 0.4rem 0 !important;
    font-size: 0.8rem !important;
  }

  .mg-topbar-left {
    gap: 0.5rem !important;
  }

  .mg-tagline-badge, .mg-topbar-right .mg-topbar-link:not(:first-child) {
    display: none !important;
  }

  .mg-header-inner {
    padding: 0.5rem 1rem !important;
    gap: 0.8rem !important;
  }

  .mg-logo, a.custom-logo-link, header a.logo {
    max-width: 150px !important;
    height: 40px !important;
    max-height: 40px !important;
  }

  .mg-logo-img, .mg-logo img, a.custom-logo-link img, img.custom-logo, header img {
    height: 40px !important;
    max-height: 40px !important;
    max-width: 150px !important;
  }

  /* Hide Desktop Nav & Search on Mobile */
  .mg-nav, header nav, .mg-search-form {
    display: none !important;
  }

  /* Show Hamburger & Shop Now on Mobile */
  .mg-mobile-toggle {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 4px !important;
    background: transparent !important;
    border: none !important;
    padding: 8px !important;
    cursor: pointer !important;
    z-index: 10001 !important;
  }

  .mg-mobile-toggle span {
    width: 22px !important;
    height: 2.5px !important;
    background-color: #1e293b !important;
    border-radius: 2px !important;
  }

  .mg-header-actions {
    gap: 0.6rem !important;
  }

  .mg-header-actions .mg-btn {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.82rem !important;
  }
}

/* Mobile Slide-out Drawer Menu */
.mg-mobile-menu {
  position: fixed !important;
  top: 0 !important;
  right: -100% !important;
  width: 85% !important;
  max-width: 320px !important;
  height: 100vh !important;
  background: #ffffff !important;
  z-index: 99999 !important;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2) !important;
  transition: right 0.35s ease-in-out !important;
  padding: 1.5rem !important;
  display: flex !important;
  flex-direction: column !important;
}

.mg-mobile-menu.active {
  right: 0 !important;
}

.mg-mobile-menu-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding-bottom: 1rem !important;
  margin-bottom: 1.5rem !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

.mg-mobile-title {
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #0d5c3a !important;
}

.mg-mobile-close {
  background: #f1f5f9 !important;
  border: none !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  font-size: 1.2rem !important;
  cursor: pointer !important;
  color: #334155 !important;
}

.mg-mobile-nav-list {
  list-style: none !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 1rem !important;
  padding: 0 !important;
  margin: 0 !important;
}

.mg-mobile-nav-list a {
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  color: #1e293b !important;
  text-decoration: none !important;
  display: block !important;
  padding: 0.6rem 0 !important;
  border-bottom: 1px solid #f8faf9 !important;
}

.mg-mobile-nav-list a:hover {
  color: #0d5c3a !important;
}

/* Mobile Hero Section */
@media (max-width: 768px) {
  .mg-hero {
    padding: 2.5rem 0 3rem !important;
  }

  .mg-hero-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
    text-align: center !important;
  }

  .mg-hero-title {
    font-size: 2rem !important;
    line-height: 1.2 !important;
  }

  .mg-hero-subtitle {
    font-size: 0.95rem !important;
    margin-bottom: 1.5rem !important;
  }

  .mg-hero-actions {
    flex-direction: column !important;
    gap: 0.8rem !important;
    width: 100% !important;
  }

  .mg-hero-actions .mg-btn {
    width: 100% !important;
  }

  .mg-hero-stats {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem !important;
    justify-items: center !important;
  }

  .mg-stat-divider {
    display: none !important;
  }

  .mg-hero-img {
    max-height: 240px !important;
  }
}

/* Mobile Category Grid */
@media (max-width: 768px) {
  .mg-category-grid {
    grid-template-columns: 1fr !important;
    gap: 1.2rem !important;
  }

  .mg-category-card {
    padding: 1.5rem !important;
  }
}

/* Mobile Filter Buttons & Products Grid */
@media (max-width: 768px) {
  .mg-section-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    margin-bottom: 1.8rem !important;
  }

  .mg-filter-buttons {
    width: 100% !important;
    overflow-x: auto !important;
    padding-bottom: 0.5rem !important;
    white-space: nowrap !important;

  }

  .mg-filter-btn {
    padding: 0.4rem 1rem !important;
    font-size: 0.85rem !important;

  }

  .mg-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.8rem !important;
  }

  .mg-product-card {
    border-radius: 8px !important;
  }

  .mg-product-img-wrap {
    height: 150px !important;
    padding: 0.8rem !important;
  }

  .mg-product-img {
    max-height: 130px !important;
  }

  .mg-product-body {
    padding: 0.8rem !important;
  }

  .mg-product-cat {
    font-size: 0.68rem !important;
  }

  .mg-product-title {
    font-size: 0.88rem !important;
    height: 2.6em !important;
    margin: 0.2rem 0 0.4rem !important;
  }

  .mg-product-short-desc {
    display: none !important;
  }

  .mg-price-row {
    margin-bottom: 0.6rem !important;
    padding-top: 0.5rem !important;
  }

  .mg-price {
    font-size: 1.1rem !important;
  }

  .mg-regular-price {
    font-size: 0.8rem !important;
  }

  .mg-weight-tag {
    font-size: 0.7rem !important;
    padding: 0.15rem 0.35rem !important;
  }

  .mg-btn {
    min-height: 42px !important;
    font-size: 0.85rem !important;
  }
}

@media (max-width: 420px) {
  .mg-products-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile Single Product Page */
@media (max-width: 768px) {
  .mg-single-product-wrap {
    padding: 1.5rem 0 2.5rem !important;
  }

  .mg-sp-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    margin-bottom: 2rem !important;
  }

  .mg-sp-main-img-wrap {
    padding: 1.5rem !important;
  }

  .mg-sp-main-img {
    max-height: 260px !important;
  }

  .mg-sp-title {
    font-size: 1.5rem !important;
  }

  .mg-sp-current-price {
    font-size: 1.8rem !important;
  }

  .mg-sp-benefits-grid {
    grid-template-columns: 1fr !important;
  }

  .mg-sp-actions {
    flex-direction: column !important;
  }

  .mg-sp-tab-headers {
    overflow-x: auto !important;
    white-space: nowrap !important;

  }

  .mg-sp-tab-btn {
    padding: 0.8rem 1.2rem !important;
    font-size: 0.88rem !important;

  }

  .mg-sp-tab-content {
    padding: 1.5rem 1rem !important;
  }
}

/* Mobile Footer & About / Contact */
@media (max-width: 768px) {
  .mg-about-grid, .mg-contact-grid, .mg-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  .mg-footer {
    padding-top: 2.5rem !important;
  }

  .mg-footer-bottom-inner {
    flex-direction: column !important;
    gap: 0.8rem !important;
    text-align: center !important;
  }

  .mg-contact-form-wrap {
    padding: 1.5rem !important;
  }

  .mg-input {
    font-size: 1rem !important; /* Prevents iOS auto-zoom on input focus */
  }
}

/* ==========================================================================
   COMPLETE MOBILE-FIRST & FLUID RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

/* Prevent horizontal page overflow on all mobile viewports */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

.container {
  width: 100% !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
  padding: 0 1.25rem !important;
  box-sizing: border-box !important;
}

/* Touch-friendly base sizing */
a, button, input, select, textarea {
  touch-action: manipulation;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* TABLET (<= 1024px) */
@media (max-width: 1024px) {
  .mg-hero-grid {
    grid-template-columns: 1fr !important;
    gap: 2.5rem !important;
  }
  
  .mg-about-grid, .mg-contact-grid, .mg-sp-grid {
    grid-template-columns: 1fr !important;
    gap: 2.5rem !important;
  }

  .mg-category-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.2rem !important;
  }

  .mg-products-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.2rem !important;
  }

  .mg-features-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.2rem !important;
  }

  .mg-footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
  }
}

/* MOBILE MEDIUM / SMALL TABLET (<= 850px) */
@media (max-width: 850px) {
  /* Topbar Mobile Alignment */
  .mg-topbar {
    padding: 0.5rem 0 !important;
  }

  .mg-topbar-inner {
    flex-direction: column !important;
    gap: 0.35rem !important;
    text-align: center !important;
  }

  .mg-topbar-left, .mg-topbar-right {
    justify-content: center !important;
    gap: 0.8rem !important;
    flex-wrap: wrap !important;
  }

  .mg-tagline-badge {
    display: none !important; /* Hide long text on mobile to conserve space */
  }

  /* Header Navigation */
  .mg-header-inner {
    padding: 0.6rem 1rem !important;
  }

  .mg-logo-img, .mg-logo img, a.custom-logo-link img, img.custom-logo, header img {
    height: 42px !important;
    max-height: 42px !important;
    max-width: 170px !important;
  }

  .mg-nav {
    display: none !important;
  }

  .mg-search-form {
    display: none !important;
  }

  .mg-mobile-toggle {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    padding: 0.5rem !important;
    width: 44px !important;
    height: 44px !important;
  }

  .mg-mobile-toggle span {
    width: 22px !important;
    height: 2.5px !important;
    background-color: #1e293b !important;
    border-radius: 2px !important;
  }

  /* Mobile Drawer Overlay Menu */
  .mg-mobile-menu {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    width: 85% !important;
    max-width: 320px !important;
    height: 100vh !important;
    background-color: #ffffff !important;
    z-index: 99999 !important;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15) !important;
    transition: right 0.35s ease !important;
    padding: 1.5rem !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
  }

  .mg-mobile-menu.active {
    right: 0 !important;
  }

  .mg-mobile-menu-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-bottom: 1rem !important;
    border-bottom: 1px solid #e2e8f0 !important;
    margin-bottom: 1.5rem !important;
  }

  .mg-mobile-title {
    font-weight: 800 !important;
    font-size: 1.1rem !important;
    color: #0d5c3a !important;
  }

  .mg-mobile-close {
    background: none !important;
    border: none !important;
    font-size: 1.5rem !important;
    cursor: pointer !important;
    color: #64748b !important;
    padding: 0.2rem 0.5rem !important;
  }

  .mg-mobile-nav-list {
    list-style: none !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mg-mobile-nav-list li a {
    font-size: 1.05rem !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    display: block !important;
    padding: 0.6rem 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    text-decoration: none !important;
  }

  /* Hero Mobile */
  .mg-hero {
    padding: 2.5rem 0 3.5rem !important;
  }

  .mg-hero-title {
    font-size: 2.1rem !important;
    line-height: 1.2 !important;
  }

  .mg-hero-subtitle {
    font-size: 0.98rem !important;
    margin-bottom: 1.5rem !important;
  }

  .mg-hero-actions {
    flex-direction: column !important;
    gap: 0.8rem !important;
    width: 100% !important;
  }

  .mg-hero-actions .mg-btn {
    width: 100% !important;
  }

  .mg-hero-stats {
    flex-wrap: wrap !important;
    gap: 1rem !important;
    justify-content: space-between !important;
  }

  .mg-stat-divider {
    display: none !important;
  }

  .mg-category-grid {
    grid-template-columns: 1fr !important;
  }

  .mg-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.9rem !important;
  }

  .mg-product-card {
    border-radius: 10px !important;
  }

  .mg-product-img-wrap {
    height: 160px !important;
    padding: 0.8rem !important;
  }

  .mg-product-img {
    max-height: 140px !important;
  }

  .mg-product-body {
    padding: 0.85rem !important;
  }

  .mg-product-title {
    font-size: 0.92rem !important;
    height: 2.6em !important;
  }

  .mg-price {
    font-size: 1.1rem !important;
  }

  .mg-filter-buttons {
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding-bottom: 0.5rem !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* SMARTPHONE SMALL / NARROW (<= 480px / 414px / 390px / 375px / 320px) */
@media (max-width: 480px) {
  .container {
    padding: 0 1rem !important;
  }

  .mg-hero-title {
    font-size: 1.75rem !important;
  }

  .mg-section-title {
    font-size: 1.6rem !important;
  }

  .mg-products-grid {
    grid-template-columns: 1fr !important; /* Single column on phones for full readability */
    gap: 1.2rem !important;
  }

  .mg-product-img-wrap {
    height: 200px !important;
  }

  .mg-product-img {
    max-height: 170px !important;
  }

  .mg-product-title {
    font-size: 1rem !important;
    height: auto !important;
  }

  .mg-price-row {
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
  }

  /* Single Product View Mobile */
  .mg-sp-title {
    font-size: 1.5rem !important;
  }

  .mg-sp-current-price {
    font-size: 1.8rem !important;
  }

  .mg-sp-actions {
    flex-direction: column !important;
    gap: 0.8rem !important;
  }

  .mg-sp-tab-headers {
    overflow-x: auto !important;
    white-space: nowrap !important;
  }

  .mg-sp-tab-btn {
    padding: 0.8rem 1.1rem !important;
    font-size: 0.88rem !important;
  }

  .mg-sp-tab-content {
    padding: 1.25rem !important;
  }

  /* Footer Mobile */
  .mg-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.8rem !important;
    text-align: center !important;
  }

  .mg-footer-logo img {
    margin: 0 auto 1rem !important;
  }

  .mg-footer-bottom-inner {
    flex-direction: column !important;
    gap: 0.8rem !important;
    text-align: center !important;
  }

  .mg-footer-legal {
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 1rem !important;
  }
}
