/* ===========================================================
   PERFECTED RTL OVERRIDES (rtl.css)
   Applied when html has dir="rtl"
=========================================================== */

/* --- GLOBAL RTL SETTINGS --- */
[dir="rtl"] body {
  direction: rtl;
  text-align: right;
  font-family: 'Tajawal', "Montserrat", sans-serif;
}

/* Force text alignment for all main headings and content blocks */
[dir="rtl"] .section-title,
[dir="rtl"] .hero-content,
[dir="rtl"] .hero-content p,
[dir="rtl"] .about-text p,
[dir="rtl"] .licenses-text {
  text-align: right !important; 
}

/* --- HEADER & NAV --- */
[dir="rtl"] .logo {
  margin-right: 0;
  margin-left: auto; /* Logo moves to the right */
}

[dir="rtl"] .menu-links {
  margin-left: 0;
  margin-right: auto; /* Menu aligns to the right */
}

[dir="rtl"] .arrow {
  margin-left: 0;
  margin-right: 4px;
  transform: scaleX(-1); /* Flip icon direction for LTR appearance */
}

[dir="rtl"] .info {
  flex-direction: row-reverse; /* Reverses order of top bar items */
}

/* --- HERO SECTION --- */
[dir="rtl"] .hero-buttons {
  /* Aligns buttons to the right */
  justify-content: flex-end; 
}

/* --- ABOUT SECTION & LISTS --- */
[dir="rtl"] .about-grid {
  /* Reverse column order: Image (1fr) | Text (1.2fr) */
  grid-template-columns: 1fr 1.2fr;
  direction: rtl;
}

[dir="rtl"] .about-text {
  order: 2; /* Text block moves to the right */
}

[dir="rtl"] .about-image {
  order: 1; /* Image block moves to the left */
}

/* Flips the Vision/Mission box border from left to right */
[dir="rtl"] .vision-mission-box {
  border-left: none;
  border-right: 4px solid var(--gold);
}

[dir="rtl"] .about-why-leadership ul li {
  padding-left: 0;
  padding-right: 24px; /* Space for the bullet on the right */
}

[dir="rtl"] .about-why-leadership ul li::before {
  left: auto;
  right: 0; /* Move bullet to the right */
}

/* --- SERVICES --- */
[dir="rtl"] .service-card {
  text-align: right;
  direction: rtl;
}

/* --- LICENSES SECTION MIRRORING --- */
[dir="rtl"] .licenses-grid {
  /* Reverse column order: Image (1.1fr) | Text (1fr) */
  grid-template-columns: 1.1fr 1fr;
  direction: rtl;
}

[dir="rtl"] .licenses-text {
  order: 2; /* Text block moves to the right */
}

[dir="rtl"] .licenses-image-shuffle {
  order: 1; /* Image block moves to the left */
}

/* --- CONTRACTING & MINING EFFECTS (Hover & CTA) --- */
[dir="rtl"] .content-column h2::after {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, #ffcc67, transparent); /* Flip gradient direction */
}

[dir="rtl"] .content-column::after {
  left: auto;
  right: -100%;
  transition: right 0.6s ease;
}

[dir="rtl"] .content-column:hover::after {
  left: auto;
  right: 100%; /* Flip hover animation direction */
}

[dir="rtl"] .cta-link {
  flex-direction: row;
}

[dir="rtl"] .cta-link .arrow {
  transform: rotate(180deg); /* Flip arrow icon direction */
}

[dir="rtl"] .cta-link:hover .arrow {
  transform: rotate(180deg) translateX(8px); /* Adjust hover movement to the left */
}

/* --- FLIPBOOK SLIDER --- */
[dir="rtl"] .kg-slider-btn.kg-slider-prev {
  right: 15px;
  left: auto;
  transform: scaleX(-1);
}

[dir="rtl"] .kg-slider-btn.kg-slider-next {
  left: 15px;
  right: auto;
  transform: scaleX(-1);
}

/* --- CONTACT FORM & BACK TO TOP --- */
[dir="rtl"] .contact-form label,
[dir="rtl"] .contact-form input,
[dir="rtl"] .contact-form textarea {
  text-align: right;
}

[dir="rtl"] .info-item {
  flex-direction: row;
}

[dir="rtl"] #backToTop {
  right: auto;
  left: 30px; /* Move to the bottom-left corner */
}

/* --- FOOTER --- */
[dir="rtl"] .kg-footer-inner {
  flex-direction: row-reverse; /* Reverses column order for desktop */
}

[dir="rtl"] .kg-footer-col {
  text-align: right;
  align-items: flex-start;
}

[dir="rtl"] .kg-footer-right {
  /* The column that was on the right in LTR is now on the left */
  text-align: left; 
  align-items: flex-end;
}

[dir="rtl"] .kg-footer-heading::after {
  left: auto;
  right: 0;
}

[dir="rtl"] .kg-footer-right .kg-footer-heading::after {
  left: 0;
  right: auto;
}

/* ===========================================================
   MEDIA QUERIES (MOBILE FIXES)
=========================================================== */
@media (max-width: 900px) {

  /* --- GRID RESET (ABOUT/LICENSES) --- */
  [dir="rtl"] .about-grid,
  [dir="rtl"] .licenses-grid {
    grid-template-columns: 1fr;
    direction: rtl;
  }

  [dir="rtl"] .about-text,
  [dir="rtl"] .about-image,
  [dir="rtl"] .licenses-text,
  [dir="rtl"] .licenses-image-shuffle {
    order: unset; /* Revert to default HTML flow on mobile */
  }

  /* --- MOBILE HEADER & MENU --- */
  [dir="rtl"] .mobile-toggle {
    margin-left: 0;
    margin-right: 14px;
  }
  
  [dir="rtl"] .menu-links {
    align-items: flex-start; /* Right aligned in RTL */
    padding-right: 0;
    direction: rtl;
    text-align: right;
  }
  
  [dir="rtl"] .menu-links a,
  [dir="rtl"] .dropdown-toggle {
    padding: 12px 18px 12px 10px !important;
    text-align: right !important;
  }

  [dir="rtl"] .mobile-services li a {
    padding: 10px 18px 10px 10px !important;
    text-align: right !important;
  }

  [dir="rtl"] .dropdown-toggle .arrow {
    margin-left: 0;
    margin-right: 8px;
    transform: rotate(0deg) scaleX(-1);
  }

  [dir="rtl"] #mobileLangBtn {
    right: auto;
    left: 20px !important; /* Language button moves to top-left */
  }

  [dir="rtl"] #mobileToggle {
    margin-left: 0;
    margin-right: 14px !important; /* Hamburger moves to top-right */
  }
  
  /* --- FOOTER --- */
  [dir="rtl"] .kg-footer-inner {
    text-align: center;
    flex-direction: column; 
  }
  
  [dir="rtl"] .kg-footer-col {
    align-items: center;
    text-align: center;
  }
  
  [dir="rtl"] .kg-footer-heading::after {
    right: 50%;
    transform: translateX(50%); /* Center the heading line */
  }

  /* --- BACK TO TOP --- */
  [dir="rtl"] #backToTop {
    left: 20px;
    right: auto;
  }
}