/* Shared EN/AR helpers — prefer logical properties over left/right duplicates */
:root {
  --locale-inline-start: left;
  --locale-inline-end: right;
}

html[dir="rtl"] {
  --locale-inline-start: right;
  --locale-inline-end: left;
}

.ms-logical { margin-inline-start: 1rem; }
.me-logical { margin-inline-end: 1rem; }
.ps-logical { padding-inline-start: 1rem; }
.pe-logical { padding-inline-end: 1rem; }
.start-logical { inset-inline-start: 0; }
.end-logical { inset-inline-end: 0; }
.text-start-logical { text-align: start; }
.text-end-logical { text-align: end; }

/* Ensure body inherits document direction from <html dir> */
body {
  text-align: start;
}

/* ------------------------------------------------------------
   Fix Home megamenu overlap (demo cards stacking on top of each other)
   ------------------------------------------------------------ */
@media (min-width: 992px) {
  .header .main-menu-wrapper .main-nav > li.megamenu {
    position: static !important;
  }

  .header .main-menu-wrapper .main-nav > li > ul.mega-submenu {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box;
  }

  html[dir="rtl"] .header .main-menu-wrapper .main-nav > li > ul.mega-submenu {
    left: 0 !important;
    right: 0 !important;
  }
}

.header .megamenu-wrapper .row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: stretch;
  margin-left: -12px !important;
  margin-right: -12px !important;
}

.header .megamenu-wrapper .row > [class*="col-"] {
  position: relative !important;
  float: none !important;
  flex: 0 0 25% !important;
  width: 25% !important;
  max-width: 25% !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
  box-sizing: border-box !important;
}

.header .megamenu-wrapper .single-demo {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  margin: 0 0 20px !important;
  overflow: hidden;
}

.header .megamenu-wrapper .single-demo .demo-img,
.header .megamenu-wrapper .single-demo .demo-img a,
.header .megamenu-wrapper .single-demo .demo-img img {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

.header .megamenu-wrapper .single-demo .demo-info {
  position: relative !important;
  padding: 16px 8px !important;
  text-align: center !important;
}

.header .megamenu-wrapper .single-demo .demo-info a {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: auto !important;
  max-width: 100% !important;
  white-space: normal !important;
  clear: none !important;
  padding: 0 !important;
  line-height: 1.4 !important;
}

.header .megamenu-wrapper .single-demo .demo-info a span {
  position: static !important;
  margin: 0 !important;
  flex: 0 0 auto;
}

@media (max-width: 991.98px) {
  .header .megamenu-wrapper .row > [class*="col-"] {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ------------------------------------------------------------
   RTL: flip directional arrows / chevrons (keep up/down as-is)
   ------------------------------------------------------------ */
html[dir="rtl"] .bx-right-arrow-alt,
html[dir="rtl"] .bx-left-arrow-alt,
html[dir="rtl"] .bx-chevron-right,
html[dir="rtl"] .bx-chevron-left,
html[dir="rtl"] .bx-right-arrow,
html[dir="rtl"] .bx-left-arrow,
html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-arrow-left,
html[dir="rtl"] .fa-arrow-right-long,
html[dir="rtl"] .fa-arrow-left-long,
html[dir="rtl"] .fa-chevron-right,
html[dir="rtl"] .fa-chevron-left,
html[dir="rtl"] .fa-angle-right,
html[dir="rtl"] .fa-angle-left,
html[dir="rtl"] .fa-angle-double-right,
html[dir="rtl"] .fa-angle-double-left,
html[dir="rtl"] .fa-long-arrow-alt-right,
html[dir="rtl"] .fa-long-arrow-alt-left,
html[dir="rtl"] .fas.fa-arrow-right,
html[dir="rtl"] .fas.fa-arrow-left,
html[dir="rtl"] .feather-arrow-right,
html[dir="rtl"] .feather-arrow-left,
html[dir="rtl"] .fe.feather-arrow-right,
html[dir="rtl"] .fe.feather-arrow-left,
html[dir="rtl"] .fe-arrow-right,
html[dir="rtl"] .fe-arrow-left,
html[dir="rtl"] .fe-chevron-right,
html[dir="rtl"] .fe-chevron-left,
html[dir="rtl"] .ti-chevron-right,
html[dir="rtl"] .ti-chevron-left,
html[dir="rtl"] .ti-arrow-right,
html[dir="rtl"] .ti-arrow-left,
html[dir="rtl"] .ti-arrow-narrow-right,
html[dir="rtl"] .ti-arrow-narrow-left,
html[dir="rtl"] .menu-arrow,
html[dir="rtl"] .link-icon i,
html[dir="rtl"] .owl-carousel .owl-nav .owl-prev i,
html[dir="rtl"] .owl-carousel .owl-nav .owl-next i,
html[dir="rtl"] .slick-prev::before,
html[dir="rtl"] .slick-next::before,
html[dir="rtl"] .pagination .previtem i,
html[dir="rtl"] .pagination .nextlink i,
html[dir="rtl"] .blog-pagination .previtem i,
html[dir="rtl"] .blog-pagination .nextlink i {
  display: inline-block;
  transform: scaleX(-1);
}

/* Brands row: keep logos side-by-side in LTR and RTL (no carousel) */
.brand-section .brands-slider.brands-row {
  display: flex !important;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 16px 20px;
  margin-bottom: 24px;
  width: 100%;
  min-height: 0;
}

.brand-section .brands-slider.brands-row .brand-wrap {
  flex: 0 0 auto;
  width: 140px;
  max-width: calc(50% - 20px);
  text-align: center;
  filter: none;
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 16px 12px;
}

.brand-section .brands-slider.brands-row .brand-wrap img {
  max-height: 36px;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 8px;
}

.brand-section .brands-slider.brands-row .brand-wrap p {
  color: #fff;
  margin: 0;
  font-size: 14px;
}

.brand-section .brands-slider.brands-row .brand-empty {
  color: #fff;
  opacity: 0.85;
  width: 100%;
  text-align: center;
  margin: 0 0 8px;
}

.brand-section .brand-img img {
  max-height: 220px;
  object-fit: contain;
  opacity: 0.55;
}

@media (min-width: 768px) {
  .brand-section .brands-slider.brands-row .brand-wrap {
    max-width: calc(16.666% - 18px);
  }
}

/* Submenu caret in header should point inward for RTL */
html[dir="rtl"] .header .main-nav > li .submenu > li.has-submenu > a::after,
html[dir="rtl"] .header .main-menu-wrapper .main-nav > li .submenu > li.has-submenu > a::after {
  content: "\f053" !important; /* chevron-left */
  transform: none;
}

html[dir="rtl"] .sidebar .sidebar-menu .menu-arrow,
html[dir="rtl"] .sidebar-menu .submenu > li > a .menu-arrow {
  transform: scaleX(-1);
}

/* Keep vertical chevrons upright (do not flip) */
html[dir="rtl"] .fa-chevron-down,
html[dir="rtl"] .fa-chevron-up,
html[dir="rtl"] .bx-chevron-down,
html[dir="rtl"] .bx-chevron-up,
html[dir="rtl"] .ti-chevron-down,
html[dir="rtl"] .ti-chevron-up {
  transform: none;
}
