/* ==========================================================================
   فني جدة | FANNY JEDDAH — COMPREHENSIVE RESPONSIVE STYLESHEET (responsive.css)
   Full Device Coverage: 320px up to 1920px and beyond (Ultra-wide, Desktop,
   Laptop, Tablet, Mobile, and Ultra-Small Screens).
   Anti-Overflow, Smooth Scaling, Safe-Area Optimization, and Sticky Floating Button
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. GLOBAL RESPONSIVE SAFETY & OVERFLOW PREVENTION
   -------------------------------------------------------------------------- */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

*, *::before, *::after {
  /* Prevent word/content overflows on narrow viewports */
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Ensure all media scales proportionally without distortion */
img, svg, picture, video {
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   1. ULTRA-WIDE & LARGE DESKTOP (min-width: 1440px up to 1920px+)
   -------------------------------------------------------------------------- */
@media (min-width: 1440px) {
  :root {
    --container-max: 1320px;
    --section-spacing-desktop: 6rem;
  }

  .hero-portal__title,
  .hero-electrical__title,
  .hero-plumbing__title {
    font-size: 3.25rem;
  }

  .floating-call-btn {
    width: 64px;
    height: 64px;
    bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
    right: calc(2.5rem + env(safe-area-inset-right, 0px));
  }

  .floating-call-btn__icon {
    width: 30px;
    height: 30px;
  }
}

@media (min-width: 1920px) {
  :root {
    --container-max: 1420px;
    --section-spacing-desktop: 6.5rem;
  }

  body {
    font-size: 17px;
  }

  .floating-call-btn {
    width: 64px;
    height: 64px;
    bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
    right: calc(3rem + env(safe-area-inset-right, 0px));
  }
}

/* --------------------------------------------------------------------------
   2. STANDARD LAPTOP & DESKTOP (1024px to 1439px)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) and (max-width: 1439px) {
  .hero-portal__grid,
  .hero-electrical__grid,
  .hero-plumbing__grid {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3rem;
  }

  .floating-call-btn {
    width: 60px;
    height: 60px;
    bottom: calc(2.25rem + env(safe-area-inset-bottom, 0px));
    right: calc(2.25rem + env(safe-area-inset-right, 0px));
  }
}

/* --------------------------------------------------------------------------
   3. TABLET BREAKPOINT (768px to 1023px)
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  :root {
    --section-spacing-desktop: 4.25rem;
  }

  /* Navigation Drawer for Tablets */
  .nav-menu {
    position: fixed;
    top: 76px;
    right: 0;
    left: 0;
    background-color: #FFFFFF;
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 850;
  }

  .nav-menu.is-active {
    display: flex;
  }

  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
  }

  /* Reorder Hero Layout on Tablets */
  .hero-portal__grid,
  .hero-electrical__grid,
  .hero-plumbing__grid {
    grid-template-columns: 1fr;
    gap: 2.75rem;
  }

  .hero-portal__visual,
  .hero-electrical__visual,
  .hero-plumbing__visual {
    order: -1;
    max-width: 580px;
    margin: 0 auto;
    width: 100%;
  }

  .process-steps {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .trust-grid,
  .features-proof-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2.25rem;
  }

  /* Floating call button on Tablet (Mobile bar is NOT active on >= 768px) */
  .floating-call-btn {
    width: 58px;
    height: 58px;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    right: calc(2rem + env(safe-area-inset-right, 0px));
  }
}

/* --------------------------------------------------------------------------
   4. MOBILE BREAKPOINT (max-width: 767px)
   - Mandatory Mobile Optimization
   - Minimum Clickable Target: 48x48px
   - Recommended Button Size: 56-64px
   - Respect Mobile Safe Areas
   - Prevent Conflicts with Mobile Bottom Bar (No Overlap)
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  :root {
    --container-padding: 1.25rem;
    --section-spacing-desktop: 3.5rem;
  }

  /* Persistent Mobile Bottom Call Bar */
  .mobile-bottom-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: rgba(16, 36, 58, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }

  /* Prevent page content from being clipped by sticky mobile elements */
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .site-header {
    height: 68px;
  }

  .header-inner {
    height: 68px;
  }

  .brand-logo img {
    height: 38px;
    width: auto;
  }

  .header-actions .header-call-btn {
    display: none; /* Hide header call button on mobile to save space */
  }

  /* Sticky Floating Call Button on Mobile:
     - Prominent, fixed position
     - Size: 56px x 56px (recommended 56-64px, touch target >= 48px)
     - Elevated cleanly above the mobile bottom bar (74px + safe-area + 12px)
     - Strictly ZERO overlap or conflict with the mobile bottom bar
     - Respects env(safe-area-inset-bottom) and env(safe-area-inset-right)
  */
  .floating-call-btn {
    width: 56px;
    height: 56px;
    min-width: 48px;
    min-height: 48px;
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px) + 12px);
    right: calc(1rem + env(safe-area-inset-right, 0px));
    z-index: 998;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.14);
  }

  .floating-call-btn__icon {
    width: 25px;
    height: 25px;
  }

  /* Tooltip is disabled on mobile touch devices to avoid layout interference */
  .floating-call-btn__tooltip {
    display: none;
  }

  /* Mobile Bottom Bar Elements Sizing */
  .mobile-bottom-call-btn {
    min-height: 50px;
    font-size: 1.1rem;
    padding: 0 1rem;
    border-radius: var(--radius-md);
  }

  .mobile-bottom-copy-btn {
    width: 50px;
    height: 50px;
    min-width: 48px;
    min-height: 48px;
    flex-shrink: 0;
  }

  /* Hero Section Adaptations */
  .hero-portal,
  .hero-electrical,
  .hero-plumbing {
    padding: 2.25rem 0 3.25rem;
  }

  .hero-electrical__title,
  .hero-plumbing__title,
  .hero-portal__title {
    font-size: 1.85rem;
    line-height: 1.3;
    letter-spacing: -0.3px;
  }

  .hero-electrical__lead,
  .hero-plumbing__lead,
  .hero-portal__lead {
    font-size: 1.02rem;
    line-height: 1.65;
    margin-bottom: 1.75rem;
  }

  .hero-portal__split-actions {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .hero-electrical__cta-group,
  .hero-plumbing__cta-group {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .hero-phone-cta,
  .hero-phone-cta--plumb {
    width: 100%;
    justify-content: center;
    font-size: 1.15rem;
    min-height: 52px;
  }

  /* Mobile Hero Stats Grid */
  .hero-electrical__stats,
  .hero-plumbing__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    text-align: center;
  }

  .stat-item__val {
    font-size: 1.15rem;
    font-weight: 800;
  }

  .stat-item__lbl {
    font-size: 0.74rem;
    line-height: 1.35;
  }

  /* Modular Sections Stacking */
  .dual-columns {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .dual-box {
    padding: 2rem 1.5rem;
  }

  .services-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .service-elec-card__body,
  .service-plumb-card__body {
    padding: 1.5rem;
  }

  .service-elec-card__call-link,
  .service-plumb-card__call-link {
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 48px;
    padding: 0.75rem 1rem;
  }

  .problems-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .process-steps {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .trust-grid,
  .features-proof-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .coverage-box {
    padding: 1.75rem 1.25rem;
  }

  .safety-warning-banner {
    padding: 1.25rem 1rem;
    flex-direction: column;
    gap: 0.85rem;
    box-sizing: border-box;
    width: 100%;
  }

  .safety-warning-banner > div {
    width: 100%;
    min-width: 0;
  }

  .safety-warning-banner .btn {
    width: 100%;
    box-sizing: border-box;
  }

  .hero-electrical__badge,
  .hero-plumbing__badge {
    white-space: normal;
    text-align: right;
    max-width: 100%;
  }

  .coverage-pills {
    gap: 0.5rem;
  }

  .coverage-pill {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .cta-banner,
  .conversion-final-electrical,
  .conversion-final-plumbing {
    padding: 3.25rem 1.25rem;
  }

  .conversion-phone-display {
    font-size: 1.75rem;
  }

  .conversion-final__btn-group {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .conversion-final__btn-group .btn {
    width: 100%;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

/* --------------------------------------------------------------------------
   5. SMALL MOBILE & NARROW SCREENS (320px to 380px)
   - Strict Anti-Horizontal-Overflow Guard
   - Compact Touch-Friendly Targets
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
  :root {
    --container-padding: 0.9rem;
    --section-spacing-desktop: 2.75rem;
  }

  .hero-electrical__title,
  .hero-plumbing__title,
  .hero-portal__title {
    font-size: 1.55rem;
    line-height: 1.3;
  }

  .hero-electrical__lead,
  .hero-plumbing__lead,
  .hero-portal__lead {
    font-size: 0.95rem;
  }

  /* Prevent tight stat columns from overflowing */
  .hero-electrical__stats,
  .hero-plumbing__stats {
    gap: 0.4rem;
  }

  .stat-item__val {
    font-size: 1.05rem;
  }

  .stat-item__lbl {
    font-size: 0.68rem;
  }

  .floating-call-btn {
    width: 52px;
    height: 52px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px) + 10px);
    right: 0.75rem;
  }

  .floating-call-btn__icon {
    width: 23px;
    height: 23px;
  }

  .mobile-bottom-call-btn {
    font-size: 0.98rem;
    padding: 0 0.65rem;
    gap: 0.4rem;
  }

  .mobile-bottom-copy-btn {
    width: 48px;
    height: 48px;
  }

  .service-choice-card {
    padding: 1.25rem 1rem;
  }

  .dual-box {
    padding: 1.5rem 1rem;
  }

  .service-card {
    padding: 1.5rem 1rem;
  }

  .coverage-box {
    padding: 1.25rem 0.85rem;
  }

  .safety-warning-banner {
    padding: 1.25rem 1rem;
    flex-direction: column;
    gap: 0.75rem;
  }
}
