/*
 * WooCommerce Multi Market Pro – RTL & Arabic Translation Compatibility
 * Designed specifically for WoodMart Theme + Elementor + GTranslate
 * Safely scoped to prevent layout distortion and slider displacement.
 */

/* 1. Root Containers: Clean direction without breaking sticky headers or full-width geometry */
html[dir="rtl"],
html.translated-rtl,
html.mm-rtl-active,
html.mm-dir-rtl {
  direction: rtl;
}

body.rtl,
body.translated-rtl,
body.mm-rtl-active,
body.mm-dir-rtl {
  direction: rtl;
}

/* 2. Sliders & Carousels (WoodMart Owl Carousel, Swiper, Slick)
 * IMPORTANT: Native RTL sliders (.owl-rtl, .swiper-rtl, .slick-rtl) require direction: rtl
 * for their positive translate3d math. Only force direction: ltr on sliders that initialized in LTR!
 */
html[dir="rtl"] .owl-carousel:not(.owl-rtl),
html.mm-rtl-active .owl-carousel:not(.owl-rtl),
html[dir="rtl"] .owl-carousel:not(.owl-rtl) .owl-stage-outer,
html.mm-rtl-active .owl-carousel:not(.owl-rtl) .owl-stage-outer,
html[dir="rtl"] .swiper:not(.swiper-rtl),
html.mm-rtl-active .swiper:not(.swiper-rtl),
html[dir="rtl"] .swiper-container:not(.swiper-container-rtl),
html.mm-rtl-active .swiper-container:not(.swiper-container-rtl),
html[dir="rtl"] .swiper:not(.swiper-rtl) .swiper-wrapper,
html.mm-rtl-active .swiper:not(.swiper-rtl) .swiper-wrapper,
html[dir="rtl"] .slick-slider:not(.slick-rtl),
html.mm-rtl-active .slick-slider:not(.slick-rtl),
html[dir="rtl"] .slick-slider:not(.slick-rtl) .slick-list,
html.mm-rtl-active .slick-slider:not(.slick-rtl) .slick-list,
html[dir="rtl"] .slick-slider:not(.slick-rtl) .slick-track,
html.mm-rtl-active .slick-slider:not(.slick-rtl) .slick-track {
  direction: ltr !important;
}

html[dir="rtl"] .owl-carousel.owl-rtl,
html[dir="rtl"] .owl-carousel.owl-rtl .owl-stage-outer,
html[dir="rtl"] .swiper.swiper-rtl,
html[dir="rtl"] .swiper-container.swiper-container-rtl,
html[dir="rtl"] .swiper.swiper-rtl .swiper-wrapper,
html[dir="rtl"] .slick-slider.slick-rtl,
html[dir="rtl"] .slick-slider.slick-rtl .slick-list {
  direction: rtl;
}

html[dir="rtl"] .owl-item,
html.mm-rtl-active .owl-item,
html[dir="rtl"] .swiper-slide,
html.mm-rtl-active .swiper-slide,
html[dir="rtl"] .slick-slide,
html.mm-rtl-active .slick-slide {
  direction: rtl;
}

/* 3. Header, Topbar & Dropdowns in RTL */
html[dir="rtl"] .whb-header,
html.mm-rtl-active .whb-header {
  width: 100%;
  max-width: 100%;
}

html[dir="rtl"] .mm-topbar,
html.mm-rtl-active .mm-topbar,
html[dir="rtl"] .mm-market-switcher,
html.mm-rtl-active .mm-market-switcher {
  direction: rtl;
}

html[dir="rtl"] select.mm-market-select,
html.mm-rtl-active select.mm-market-select {
  text-align: right;
  direction: rtl;
}

/* 4. Footer Newsletter & Mobile Containment (Theme-agnostic safe scoping) */
@media (max-width: 768px) {
  html[dir="rtl"] footer,
  html[dir="rtl"] .footer-container,
  html[dir="rtl"] .wd-footer,
  html[dir="rtl"] .woodmart-footer,
  html.mm-rtl-active footer,
  html.mm-rtl-active .footer-container,
  html.mm-rtl-active .wd-footer,
  html.mm-rtl-active .woodmart-footer {
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Apply bottom clearance only when theme renders a sticky WoodMart bottom toolbar */
  html[dir="rtl"] .wd-toolbar-on .footer-container,
  html[dir="rtl"] .wd-toolbar-on .wd-footer,
  html[dir="rtl"] .wd-toolbar-on .woodmart-footer,
  html.mm-rtl-active .wd-toolbar-on .footer-container,
  html.mm-rtl-active .wd-toolbar-on .wd-footer,
  html.mm-rtl-active .wd-toolbar-on .woodmart-footer {
    padding-bottom: 75px !important;
  }

  /* Constrain footer widgets & columns cleanly on mobile */
  html[dir="rtl"] .footer-container .container,
  html[dir="rtl"] .wd-footer .container,
  html[dir="rtl"] footer .elementor-container,
  html.mm-rtl-active .footer-container .container,
  html.mm-rtl-active .wd-footer .container,
  html.mm-rtl-active footer .elementor-container {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Newsletter form on mobile: ensure full-width adaptive flex */
  html[dir="rtl"] footer .mc4wp-form,
  html[dir="rtl"] .footer-container .mc4wp-form,
  html[dir="rtl"] .wd-footer .mc4wp-form,
  html.mm-rtl-active footer .mc4wp-form,
  html.mm-rtl-active .footer-container .mc4wp-form,
  html.mm-rtl-active .wd-footer .mc4wp-form {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  html[dir="rtl"] footer .mc4wp-form-fields,
  html[dir="rtl"] .footer-container .mc4wp-form-fields,
  html[dir="rtl"] .wd-footer .mc4wp-form-fields,
  html.mm-rtl-active footer .mc4wp-form-fields,
  html.mm-rtl-active .footer-container .mc4wp-form-fields,
  html.mm-rtl-active .wd-footer .mc4wp-form-fields {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  html[dir="rtl"] footer .mc4wp-form-fields input[type="email"],
  html[dir="rtl"] .footer-container .mc4wp-form-fields input[type="email"],
  html[dir="rtl"] .wd-footer .mc4wp-form-fields input[type="email"],
  html.mm-rtl-active footer .mc4wp-form-fields input[type="email"],
  html.mm-rtl-active .footer-container .mc4wp-form-fields input[type="email"],
  html.mm-rtl-active .wd-footer .mc4wp-form-fields input[type="email"] {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    direction: rtl !important;
    text-align: right !important;
    box-sizing: border-box !important;
  }

  html[dir="rtl"] footer .mc4wp-form-fields input[type="submit"],
  html[dir="rtl"] footer .mc4wp-form-fields button,
  html[dir="rtl"] .footer-container .mc4wp-form-fields input[type="submit"],
  html[dir="rtl"] .footer-container .mc4wp-form-fields button,
  html[dir="rtl"] .wd-footer .mc4wp-form-fields input[type="submit"],
  html[dir="rtl"] .wd-footer .mc4wp-form-fields button,
  html.mm-rtl-active footer .mc4wp-form-fields input[type="submit"],
  html.mm-rtl-active footer .mc4wp-form-fields button {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }

  /* Wrap footer text properly on mobile */
  html[dir="rtl"] footer h1,
  html[dir="rtl"] footer h2,
  html[dir="rtl"] footer h3,
  html[dir="rtl"] footer h4,
  html[dir="rtl"] footer p,
  html[dir="rtl"] .footer-container h1,
  html[dir="rtl"] .footer-container h2,
  html[dir="rtl"] .footer-container h3,
  html[dir="rtl"] .footer-container h4,
  html[dir="rtl"] .footer-container p,
  html[dir="rtl"] .wd-footer h1,
  html[dir="rtl"] .wd-footer h2,
  html[dir="rtl"] .wd-footer h3,
  html[dir="rtl"] .wd-footer h4,
  html[dir="rtl"] .wd-footer p,
  html.mm-rtl-active footer h1,
  html.mm-rtl-active footer h2,
  html.mm-rtl-active footer h3,
  html.mm-rtl-active footer h4,
  html.mm-rtl-active footer p,
  html.mm-rtl-active .footer-container p,
  html.mm-rtl-active .wd-footer p {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    text-align: right !important;
    direction: rtl !important;
  }

  /* Scroll to top button in mobile RTL */
  html[dir="rtl"] .scrollToTop,
  html.mm-rtl-active .scrollToTop,
  html[dir="rtl"] .wd-back-to-top,
  html.mm-rtl-active .wd-back-to-top {
    left: 15px !important;
    right: auto !important;
    bottom: 70px !important;
  }
}
