/* ========================================
   ALL MOBILE DEVICES - PREVENT HORIZONTAL SCROLL
   ======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  scroll-behavior: auto;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

h1, h2, h3, p {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Apply to ALL mobile devices (iOS + Android) */
@media (max-width: 768px) {
  /* Prevent horizontal scrolling on all mobile devices */
  html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
  }
  
  /* Prevent all sections from causing horizontal scroll */
  section, div, header, footer, .container, .hero-container {
    max-width: 100vw;
    overflow-x: hidden;
  }
  
  /* All pages start below header on mobile */
  section {
    padding-top: 100px !important;
  }
}

/* ========================================
   iOS-ONLY MOBILE OPTIMIZATION
   ======================================== */

/* iOS-specific detection and fixes */
@supports (-webkit-touch-callout: none) {
  /* This block ONLY applies to iOS devices */
  
  /* Remove white space above header on iOS */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    height: 100%;
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
    position: relative;
  }
  
  /* Force body to start at absolute top */
  body {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  /* Header must be at absolute top with no gap */
  header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 !important;
    z-index: 9999 !important;
    padding-top: max(15px, env(safe-area-inset-top)) !important;
  }
  
  /* Prevent all sections from causing horizontal scroll */
  section, div, header, footer {
    max-width: 100vw;
    overflow-x: hidden;
  }
  
  /* Ensure container doesn't overflow */
  .container, .hero-container {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* iOS Hero Section Optimization */
  .modern-hero {
    min-height: -webkit-fill-available;
    width: 100%;
    overflow-x: hidden;
  }
  
  /* Prevent iOS zoom on input focus */
  input, select, textarea, button {
    font-size: 16px !important;
  }
  
  /* iOS Touch Optimization */
  button:active, a:active {
    opacity: 0.7;
    transition: opacity 0.1s;
  }
  
  /* Prevent iOS Rubber Band Effect - vertical and horizontal */
  body {
    overscroll-behavior: none;
    position: relative;
  }
}

/* Default padding for products section */
.products {
  padding: 40px 0;
  min-height: 60vh;
}

/* Product detail page */
.product-detail-page {
  padding-top: 100px;
}

/* iOS Mobile - ONLY on iOS devices with small screens */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    /* Force padding on ALL sections - iOS specific override */
    section.modern-hero,
    section.features-section,
    section.categories-modern,
    section.products-modern,
    section.testimonial-section,
    section.cta-section,
    section.products,
    .product-detail-page {
      padding-top: 140px !important;
    }
    
    /* Hero section - auto-adjust like desktop */
    section.modern-hero {
      min-height: 100svh;
      padding-top: calc(120px + env(safe-area-inset-top)) !important;
      padding-bottom: 60px !important;
      padding-left: 20px !important;
      padding-right: 20px !important;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      overflow-x: hidden;
    }
    
    .hero-container {
      grid-template-columns: 1fr !important;
      gap: 40px !important;
      max-width: 100% !important;
      width: 100% !important;
      padding: 0 !important;
      overflow-x: hidden;
    }
    
    .hero-content {
      text-align: center;
      width: 100%;
      max-width: 100%;
    }
    
    /* Trust badge */
    .hero-badge {
      font-size: 14px;
      font-weight: 600;
      margin-bottom: 16px;
      display: inline-block;
      padding: 8px 16px;
    }
    
    /* Main headline */
    .hero-title {
      font-size: clamp(28px, 6vw, 36px) !important;
      font-weight: 700 !important;
      line-height: 1.2 !important;
      margin-bottom: 16px !important;
      padding: 0 !important;
      width: 100%;
    }
    
    /* Subheading */
    .hero-subtitle {
      font-size: clamp(14px, 4vw, 16px) !important;
      margin: 0 auto 24px auto !important;
      line-height: 1.6;
      padding: 0 !important;
      width: 100%;
    }
    
    /* CTA buttons container */
    .hero-actions {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      justify-content: center;
      margin-bottom: 32px;
      width: 100%;
      max-width: 100%;
    }
    
    /* Buttons */
    .primary-btn, .secondary-btn {
      padding: 14px 22px;
      font-size: 15px;
      font-weight: 600;
      border-radius: 999px;
      cursor: pointer;
      white-space: nowrap;
      flex: 1;
      min-width: 140px;
      max-width: 100%;
    }
    
    /* Stats grid */
    .hero-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 20px;
      width: 100%;
      max-width: 100%;
      margin: 0 auto;
      padding: 0 20px;
      box-sizing: border-box;
    }
    
    /* Stat item */
    .stat {
      text-align: center;
    }
    
    /* Stat number */
    .stat-number {
      display: block;
      font-size: 22px;
      font-weight: 700;
    }
    
    /* Stat label */
    .stat-label {
      font-size: 13px;
      opacity: 0.8;
    }
    
    /* Hero Visual Card */
    .hero-visual {
      width: 100%;
      max-width: 100%;
      display: flex;
      justify-content: center;
      overflow-x: hidden;
    }
    
    .floating-card {
      width: 100%;
      max-width: 400px;
      padding: 24px;
      margin: 0 auto;
    }
    
    .hero-logo {
      width: 60px !important;
      height: 60px !important;
    }
    
    .card-content h3 {
      font-size: 1.25rem;
    }
    
    .stats-mini {
      display: flex;
      justify-content: space-around;
      gap: 16px;
    }
  }

  /* Small iOS devices - Auto-adjusting */
  @media (max-width: 480px) {
    section.modern-hero {
      padding-top: calc(70px + env(safe-area-inset-top)) !important;
      padding-bottom: 30px !important;
      padding-left: 12px !important;
      padding-right: 12px !important;
    }
    
    .hero-container {
      padding: 0 12px !important;
    }
    
    .hero-title {
      font-size: 28px !important;
    }
    
    .hero-subtitle {
      font-size: 15px !important;
    }
    
    .hero-actions {
      flex-direction: column;
      width: 100%;
    }
    
    .primary-btn, .secondary-btn {
      width: 100%;
      min-width: auto;
    }
    
    .hero-stats {
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
    }
    
    .stat-number {
      font-size: 20px;
    }
    
    .stat-label {
      font-size: 11px;
    }
    
    .floating-card {
      padding: 20px;
    }
    
    .hero-logo {
      width: 50px !important;
      height: 50px !important;
    }
  }

  /* iOS Landscape Mode Fixes */
  @media screen and (orientation: landscape) and (max-height: 500px) {
    section.modern-hero {
      min-height: auto;
      padding: 20px 16px;
    }
    
    .hero-title {
      font-size: 24px !important;
    }
    
    .hero-stats {
      gap: 12px;
    }
  }

  /* Very small iOS screens */
  @media (max-width: 375px) {
    .hero-title {
      font-size: 24px !important;
    }
    
    .hero-subtitle {
      font-size: 14px !important;
    }
  }
}
