/* RTL adjustments — loaded only on Arabic pages (html[dir="rtl"]).
   Bootstrap 5.3 logical utilities (ms-*, me-*, text-start/end, float-*)
   flip automatically; the rules below cover the physical-property leftovers. */

/* frontend.css forces body{direction:ltr} — override so dir="rtl" takes effect. */
[dir="rtl"] body {
  direction: rtl;
}

/* ------- Modern Arabic typeface (Tajawal — geometric, pairs with Jost) ------- */
/* Route every Odoo font variable through the Arabic stack so headings,
   buttons, body copy, and form controls all pick it up. */
[dir="rtl"] {
  --sagco-ar-font: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --body-font-family: var(--sagco-ar-font);
  --font-sans-serif: var(--sagco-ar-font);
  --headings-font: var(--sagco-ar-font);
  --buttons-font: var(--sagco-ar-font);
  --font: var(--sagco-ar-font);
}

[dir="rtl"] body,
[dir="rtl"] .btn,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] .nav-link,
[dir="rtl"] .dropdown-item,
[dir="rtl"] label {
  font-family: var(--sagco-ar-font);
}

/* frontend.css hardcodes Jost on these selectors — swap to Tajawal. */
[dir="rtl"] h1, [dir="rtl"] .h1,
[dir="rtl"] h2, [dir="rtl"] .h2,
[dir="rtl"] h3, [dir="rtl"] .h3,
[dir="rtl"] h4, [dir="rtl"] .h4,
[dir="rtl"] h5, [dir="rtl"] .h5,
[dir="rtl"] h6, [dir="rtl"] .h6 {
  font-family: var(--sagco-ar-font);
}

/* Arabic is cursive — letter-spacing disconnects the glyphs. Neutralize the
   decorative tracking used on EN kickers/labels. */
[dir="rtl"] * {
  letter-spacing: normal;
}

/* .navbar-brand uses physical margin-right — move it to the mirrored side. */
[dir="rtl"] .navbar-brand {
  margin-right: 0;
  margin-left: 1rem;
}

/* Carousel slide direction */
[dir="rtl"] .carousel-item-next:not(.carousel-item-start),
[dir="rtl"] .active.carousel-item-end {
  transform: translateX(-100%);
}
[dir="rtl"] .carousel-item-prev:not(.carousel-item-end),
[dir="rtl"] .active.carousel-item-start {
  transform: translateX(100%);
}

/* Mirror carousel prev/next controls and their icons */
[dir="rtl"] .carousel-control-prev {
  left: auto;
  right: 0;
}
[dir="rtl"] .carousel-control-next {
  right: auto;
  left: 0;
}
[dir="rtl"] .carousel-control-prev .fa,
[dir="rtl"] .carousel-control-next .fa,
[dir="rtl"] .carousel-control-prev-icon,
[dir="rtl"] .carousel-control-next-icon {
  transform: scaleX(-1);
}

/* RFQ nav button: pinned to the far end (left in RTL) */
@media (min-width: 992px) {
  [dir="rtl"] .sagco-nav-rfq-item {
    margin-left: 0 !important;
    margin-right: auto !important;
  }
}

/* Off-canvas sidebar slides from the left in RTL.
   The parked transform must NOT match while open — this file loads
   after mega-menu.css, so an unguarded rule would pin the sidebar
   off-screen forever (equal specificity, later wins). */
@media (max-width: 991.98px) {
  [dir="rtl"] #top_menu_collapse {
    right: auto;
    left: 0;
    box-shadow: 0.5rem 0 2rem rgba(15, 23, 42, 0.18);
  }

  [dir="rtl"] #top_menu_collapse:not(.sagco-open):not(.show) {
    transform: translateX(-105%);
  }

  [dir="rtl"] #top_menu_collapse.sagco-open,
  [dir="rtl"] #top_menu_collapse.show {
    transform: translateX(0);
    visibility: visible;
  }

  [dir="rtl"] .sagco-nav-close {
    right: auto;
    left: 0.5rem;
  }

  [dir="rtl"] .sagco-mega-grid {
    border-left: 0;
    border-right: 2px solid #e8ecf1;
  }

  [dir="rtl"] .sagco-mega-footer {
    text-align: right;
  }
}

/* Mega-menu grid flows right-to-left automatically via direction,
   but keep card text aligned start (right) */
[dir="rtl"] .sagco-mega-card {
  text-align: start;
}

/* Latin-script inputs (email, phone, URLs) stay LTR inside RTL forms */
[dir="rtl"] input[name="email"],
[dir="rtl"] input[name="phone"],
[dir="rtl"] input[name="download_link"] {
  direction: ltr;
  text-align: right;
}

/* Phone links: keep the "+" before the digits in RTL context */
[dir="rtl"] a[href^="tel:"] {
  direction: ltr;
  unicode-bidi: isolate;
}

/* Contact/RFQ form labels hug the right edge of their column
   (must out-specify contact-page.css's #id rules) */
[dir="rtl"] #contactus_form .s_website_form_label,
[dir="rtl"] #rfq_form .s_website_form_label {
  text-align: right;
  padding: 0.55rem 0 0 1rem;
}

/* Submit button stays aligned under the fields (label col is on the right) */
[dir="rtl"] #contactus_form .sagco-form-submit-row,
[dir="rtl"] #rfq_form .sagco-form-submit-row {
  padding-left: 0;
  padding-right: 200px;
}

@media (max-width: 991.98px) {
  [dir="rtl"] #contactus_form .sagco-form-submit-row,
  [dir="rtl"] #rfq_form .sagco-form-submit-row {
    padding-right: 0;
  }
}

/* Contact info column: UA padding-inline-start sits on the right in RTL;
   keep the intended small indent there */
[dir="rtl"] #SAGCO-CONTRACTING .o_grid_item ul.list-unstyled {
  padding-inline-start: 0.5rem;
}

/* Footer social icons row mirrors automatically via flex + logical margins */
[dir="rtl"] .o_footer_copyright_name {
  margin-right: 0;
  margin-inline-start: 0.5rem;
}

/* ------- Footer columns right-aligned in RTL ------- */
/* .list-unstyled only clears physical padding-LEFT; the UA's
   padding-inline-start still indents lists from the right. */
[dir="rtl"] #bottom .footer-link,
[dir="rtl"] #bottom .footer-address {
  padding-right: 0 !important;
  padding-inline-start: 0 !important;
}

[dir="rtl"] #bottom .footer-title,
[dir="rtl"] #bottom .footer-top li,
[dir="rtl"] #bottom .footer-top p,
[dir="rtl"] #bottom .s_social_media {
  text-align: right !important;
}

/* Contact rows: icon sits at the right, so the gap must move to the
   text's right side (the source rule uses physical padding-left). */
[dir="rtl"] #bottom .footer-address .f-text {
  padding-left: 0;
  padding-right: 15px;
}

/* Link underline grows from the right in RTL */
[dir="rtl"] #bottom .footer-link a::after {
  left: auto;
  right: 0;
}

[dir="rtl"] #bottom .footer-link a:hover::after {
  left: 0;
  right: auto;
}

/* ------- polish.css RTL companions ------- */

/* Nav underline grows from the right */
@media (min-width: 992px) {
  [dir="rtl"] #top_menu .nav-link:not(.dropdown-toggle)::after {
    transform-origin: right;
  }
}

/* Hero overlay gradient reverses for RTL reading */
[dir="rtl"] .s_carousel_wrapper .carousel-item .o_we_bg_filter {
  background: linear-gradient(-100deg,
      rgba(13, 20, 40, 0.78) 0%,
      rgba(13, 20, 40, 0.55) 45%,
      rgba(13, 20, 40, 0.18) 75%,
      rgba(13, 20, 40, 0.05) 100%) !important;
}

/* Card carousel arrow glyphs mirror (prev sits on the right, points right) */
[dir="rtl"] .sagco-hc-btn svg {
  transform: scaleX(-1);
}

/* Mega-card "Learn more" arrow: border-inline-end already mirrors the
   chevron; only the hover nudge direction needs flipping. */
[dir="rtl"] .sagco-mega-card:hover .sagco-mega-card-link::after,
[dir="rtl"] .sagco-mega-card:focus .sagco-mega-card-link::after {
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Partners/vendors marquee direction is handled by the JS driver in
   site.js (RTL pages scroll right→left; the strip is draggable). */

/* Newsletter subscribe: offset-lg-5 uses margin-left, which pushes the form
   right in RTL too — mirror it so the field+button sit at the left edge. */
@media (min-width: 992px) {
  [dir="rtl"] .as_s_newsletter_2.offset-lg-5,
  [dir="rtl"] .as_s_newsletter_5.offset-lg-5 {
    margin-left: 0;
    margin-right: 41.66666667%;
  }
}
