/* ==========================================================
   LAST MOBILE + RTL + SEARCH FIXES
   ========================================================== */

/* 1. Disable product dropdown effect on mobile.
   On phones/tablets, Products should simply open the products page. */
@media (max-width: 980px) {
  body .products-dropdown .products-horizontal-menu,
  body .products-dropdown:hover .products-horizontal-menu,
  body .products-dropdown:focus-within .products-horizontal-menu,
  body .products-dropdown.is-open .products-horizontal-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body .products-dropdown .dropbtn {
    pointer-events: auto !important;
  }
}

/* 2. Search page: show only search results, no category table/sidebar */
body.search-active .products-sidebar,
body.search-active .product-category-view,
body.search-active .product-detail,
body.search-active .product-category-header,
body.search-active .products-breadcrumb {
  display: none !important;
}

body.search-active .products-shell {
  display: block !important;
  width: min(100% - 40px, 1280px) !important;
  margin: 0 auto !important;
}

body.search-active .products-main {
  width: 100% !important;
}

/* 3. Product homepage slideshow: arrows always visible on mobile */
@media (max-width: 980px) {
  body .products-section {
    overflow: hidden !important;
  }

  body .product-home-slider {
    position: relative !important;
    width: 100% !important;
    min-height: 720px !important;
    height: auto !important;
    padding: 0 44px !important;
    box-sizing: border-box !important;
  }

  body .product-home-slider .slide {
    position: relative !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  body .product-home-slider .slide.visible {
    display: block !important;
  }

  body .products-section .product-slide-image-frame,
  html[lang="ar"] body .products-section .product-slide-image-frame {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;

    width: min(92vw, 620px) !important;
    height: min(70vw, 420px) !important;
    max-width: min(92vw, 620px) !important;
    max-height: 420px !important;

    margin: 0 auto 22px !important;
  }

  body .products-section .product-slide-image-frame img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }

  body .products-section .slide .text,
  html[lang="ar"] body .products-section .slide .text {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;

    width: min(92vw, 620px) !important;
    max-width: min(92vw, 620px) !important;
    min-width: 0 !important;

    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;

    margin: 0 auto !important;
  }

  body .products-section .product-slider-arrow {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 999 !important;

    position: absolute !important;
    top: 34% !important;
    transform: translateY(-50%) !important;

    width: 38px !important;
    height: 54px !important;
    font-size: 44px !important;

    background: rgba(0,0,0,0.18) !important;
    border-radius: 4px !important;
  }

  body .products-section .product-slider-arrow.prev {
    left: 4px !important;
    right: auto !important;
  }

  body .products-section .product-slider-arrow.next {
    right: 4px !important;
    left: auto !important;
  }

  html[lang="ar"] body .products-section .product-slider-arrow.prev {
    left: auto !important;
    right: 4px !important;
  }

  html[lang="ar"] body .products-section .product-slider-arrow.next {
    right: auto !important;
    left: 4px !important;
  }
}

/* 4. Arabic footer mobile stacking */
@media (max-width: 980px) {
  html[lang="ar"] body .footer {
    direction: rtl !important;
    overflow: visible !important;
  }

  html[lang="ar"] body .footer-container {
    width: min(100% - 28px, 760px) !important;
    max-width: min(100% - 28px, 760px) !important;
  }

  html[lang="ar"] body .footer-menu {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    row-gap: 28px !important;
    column-gap: 0 !important;
    text-align: right !important;
    direction: rtl !important;
  }

  html[lang="ar"] body .footer-col {
    width: 100% !important;
    max-width: 100% !important;
    text-align: right !important;
  }

  html[lang="ar"] body .footer-map-link {
    text-align: right !important;
  }

  html[lang="ar"] body .footer-bottom {
    width: 100% !important;
    max-width: 100% !important;
    text-align: right !important;
  }
}

/* 5. WhatsApp on the other end on mobile */
@media (max-width: 760px) {
  body .whatsapp-float {
    left: 18px !important;
    right: auto !important;
    bottom: 18px !important;
  }
}

/* 6. Phone/email numbers stay LTR in Arabic */
html[lang="ar"] body .latin-number,
html[lang="ar"] body [dir="ltr"] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  display: inline-block !important;
}

/* 7. Arabic loading popup bullets next to text */
html[lang="ar"] body .loading-popup-content {
  direction: rtl !important;
}

html[lang="ar"] body .loading-popup-content ul {
  direction: rtl !important;
  text-align: right !important;
  list-style-position: outside !important;
  padding-right: 28px !important;
  padding-left: 0 !important;
}

html[lang="ar"] body .loading-popup-content li {
  direction: rtl !important;
  text-align: right !important;
  padding-right: 4px !important;
}

/* 8. Footer full-width protection */
body .footer {
  width: 100vw !important;
  max-width: 100vw !important;
  position: relative !important;
  left: 50% !important;
  margin-left: -50vw !important;
  box-sizing: border-box !important;
}

/* FINAL WhatsApp mobile position:
   Normal languages stay bottom-right.
   Arabic only moves to bottom-left.
*/
@media (max-width: 760px) {
  html:not([lang="ar"]) body .whatsapp-float {
    right: 18px !important;
    left: auto !important;
    bottom: 18px !important;
  }

  html[lang="ar"] body .whatsapp-float {
    left: 18px !important;
    right: auto !important;
    bottom: 18px !important;
  }
}
