/* =====================================================================
 * Horilla HR - RTL (Right-to-Left) overrides
 * Loaded only when the active language is bidirectional (Arabic, etc.)
 * via {% if LANGUAGE_BIDI %} in the base templates.
 *
 * The compiled Bootstrap 5 build shipped with the project is LTR-only,
 * so logical spacing utilities (ms-*, me-*, ps-*, pe-*), text/float
 * alignment helpers and the custom "oh-" components are flipped here.
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * 1. Base direction + Arabic typography
 * ------------------------------------------------------------------- */
[dir="rtl"] body,
[dir="rtl"] .oh-wrapper,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea,
[dir="rtl"] button,
[dir="rtl"] .oh-btn,
[dir="rtl"] .oh-navbar,
[dir="rtl"] .oh-sidebar,
[dir="rtl"] .oh-titlebar,
[dir="rtl"] .oh-modal,
[dir="rtl"] .oh-card,
[dir="rtl"] .oh-table,
[dir="rtl"] .oh-label,
[dir="rtl"] .oh-dropdown {
  font-family: "Cairo", "Poppins", "Open Sans", "Segoe UI", Tahoma, sans-serif;
}

[dir="rtl"] body {
  text-align: right;
}

/* Icon fonts must stay LTR so glyphs are not mirrored */
[dir="rtl"] .material-icons,
[dir="rtl"] .material-icons-outlined,
[dir="rtl"] ion-icon {
  direction: ltr;
}

/* Manually mirror directional icons where it is meaningful */
[dir="rtl"] .flip-rtl {
  transform: scaleX(-1);
}

/* ---------------------------------------------------------------------
 * 2. Bootstrap 5 logical spacing utilities (start = right in RTL)
 * ------------------------------------------------------------------- */
[dir="rtl"] .ms-0 { margin-left: 0 !important; margin-right: 0 !important; }
[dir="rtl"] .ms-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
[dir="rtl"] .ms-2 { margin-left: 0 !important; margin-right: 0.5rem !important; }
[dir="rtl"] .ms-3 { margin-left: 0 !important; margin-right: 1rem !important; }
[dir="rtl"] .ms-4 { margin-left: 0 !important; margin-right: 1.5rem !important; }
[dir="rtl"] .ms-5 { margin-left: 0 !important; margin-right: 3rem !important; }
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }

[dir="rtl"] .me-0 { margin-right: 0 !important; margin-left: 0 !important; }
[dir="rtl"] .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .me-2 { margin-right: 0 !important; margin-left: 0.5rem !important; }
[dir="rtl"] .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }
[dir="rtl"] .me-4 { margin-right: 0 !important; margin-left: 1.5rem !important; }
[dir="rtl"] .me-5 { margin-right: 0 !important; margin-left: 3rem !important; }
[dir="rtl"] .me-auto { margin-right: 0 !important; margin-left: auto !important; }

[dir="rtl"] .ps-0 { padding-left: 0 !important; padding-right: 0 !important; }
[dir="rtl"] .ps-1 { padding-left: 0 !important; padding-right: 0.25rem !important; }
[dir="rtl"] .ps-2 { padding-left: 0 !important; padding-right: 0.5rem !important; }
[dir="rtl"] .ps-3 { padding-left: 0 !important; padding-right: 1rem !important; }
[dir="rtl"] .ps-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
[dir="rtl"] .ps-5 { padding-left: 0 !important; padding-right: 3rem !important; }

[dir="rtl"] .pe-0 { padding-right: 0 !important; padding-left: 0 !important; }
[dir="rtl"] .pe-1 { padding-right: 0 !important; padding-left: 0.25rem !important; }
[dir="rtl"] .pe-2 { padding-right: 0 !important; padding-left: 0.5rem !important; }
[dir="rtl"] .pe-3 { padding-right: 0 !important; padding-left: 1rem !important; }
[dir="rtl"] .pe-4 { padding-right: 0 !important; padding-left: 1.5rem !important; }
[dir="rtl"] .pe-5 { padding-right: 0 !important; padding-left: 3rem !important; }

/* Text + float alignment helpers */
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }
[dir="rtl"] .float-start { float: right !important; }
[dir="rtl"] .float-end { float: left !important; }

/* Dropdown menu alignment */
[dir="rtl"] .dropdown-menu-end { --bs-position: start; right: auto; left: 0; }
[dir="rtl"] .dropdown-menu { text-align: right; }

/* Bootstrap rounded logical corners */
[dir="rtl"] .rounded-start {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-top-right-radius: 0.25rem !important;
  border-bottom-right-radius: 0.25rem !important;
}
[dir="rtl"] .rounded-end {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-top-left-radius: 0.25rem !important;
  border-bottom-left-radius: 0.25rem !important;
}

/* Input groups (prepend/append) need order preserved visually */
[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
  margin-right: -1px;
  margin-left: 0;
}

/* ---------------------------------------------------------------------
 * 3. Layout: sidebar sits on the right, content on the left
 * ------------------------------------------------------------------- */
/* CSS grid tracks already reverse under dir=rtl, so the sidebar column
 * moves to the right automatically. Only directional spacing is fixed. */
[dir="rtl"] .oh-sidebar { left: auto; right: 0; }

[dir="rtl"] .oh-sidebar__menu-items { padding-right: 0; padding-left: 0; }

[dir="rtl"] .oh-sidebar__menu-icon { margin-right: 0; margin-left: 10px; }

[dir="rtl"] .oh-sidebar__menu-link {
  grid-template-columns: auto 1fr;
}

[dir="rtl"] .oh-sidebar__submenu-item { padding-left: 0; padding-right: 15px; }

[dir="rtl"] .oh-sidebar__company div:first-child { margin-right: 0; margin-left: 10px; }

[dir="rtl"] .oh-wrapper-main--closed .oh-sidebar__company-profile { margin-left: 0; }
[dir="rtl"] .oh-wrapper-main--closed .oh-sidebar__menu-icon { margin-left: 0; }

/* Slide-in animations start off-screen from the right */
[dir="rtl"] .oh-sidebar__animation--enter-start { transform: translateX(100%); }
[dir="rtl"] .oh-sidebar__animation--leave-end { transform: translateX(100%); }

/* ---------------------------------------------------------------------
 * 4. Navbar / header
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-navbar__toggle-menu { margin-right: 0; margin-left: 0.35rem; }

[dir="rtl"] .oh-navbar__user-info div:first-child { margin-right: 0; margin-left: 0.5rem; }
[dir="rtl"] .oh-navbar__user-info::after { right: auto; left: -5px; }

[dir="rtl"] .oh-navbar__notification-beacon { right: auto; left: 10px; }
[dir="rtl"] .oh-navbar__notification-tray { right: auto; left: 0; padding-right: 0; padding-left: 15px; }
@media (max-width: 575.98px) {
  [dir="rtl"] .oh-navbar__notification-tray { left: auto; right: 5px; }
}

[dir="rtl"] .oh-navbar__clock { border-left: none; border-right: 1px solid #e4e3e3; }
@media (max-width: 575.98px) {
  [dir="rtl"] .oh-navbar__clock { border-right: none; }
}
[dir="rtl"] .oh-navbar__clock-icon { margin-right: 0 !important; margin-left: 0.35rem; }

/* Breadcrumbs run right-to-left, chevrons point the other way */
[dir="rtl"] .oh-navbar__breadcrumb { padding-left: 0; padding-right: 10px; }
[dir="rtl"] .oh-navbar__breadcrumb-item { margin-right: 0; margin-left: 25px; }
[dir="rtl"] .oh-navbar__breadcrumb-item::after {
  right: auto;
  left: -20px;
  transform: scaleX(-1);
}
[dir="rtl"] .oh-navbar__breadcrumb-item:last-child { margin-left: 0; }

/* ---------------------------------------------------------------------
 * 5. Activity / off-canvas sidebar opens from the left
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-activity-sidebar {
  right: auto;
  left: 0;
  box-shadow: rgba(0, 0, 0, 0.1) 4px 9px 25px -6px;
}

/* ---------------------------------------------------------------------
 * 6. Inner sidebar (settings, profile sub-navigation)
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-inner-sidebar { border-right: none; border-left: 1px solid #e4e3e3; }
@media (max-width: 991.98px) {
  [dir="rtl"] .oh-inner-sidebar { border-left: none; }
}
[dir="rtl"] .oh-inner-sidebar__items { padding-right: 0; }

/* ---------------------------------------------------------------------
 * 7. Tables
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-table th,
[dir="rtl"] .oh-table td,
[dir="rtl"] .oh-sticky-table__th,
[dir="rtl"] .oh-sticky-table__td,
[dir="rtl"] table th,
[dir="rtl"] table td {
  text-align: right;
}

/* Keep first sticky column pinned to the right edge */
[dir="rtl"] .oh-sticky-table__left { left: auto; right: 0; }
[dir="rtl"] .oh-sticky-table__right { right: auto; left: 0; }

/* ---------------------------------------------------------------------
 * 8. Forms, inputs, labels, checkboxes
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-label,
[dir="rtl"] .oh-input,
[dir="rtl"] input.form-control,
[dir="rtl"] textarea.form-control,
[dir="rtl"] .oh-input-group,
[dir="rtl"] .oh-select {
  text-align: right;
}

[dir="rtl"] .form-check { padding-left: 0; padding-right: 1.5em; }
[dir="rtl"] .form-check .form-check-input { float: right; margin-left: 0; margin-right: -1.5em; }

/* Password toggle button positioning */
[dir="rtl"] .oh-password-input--toggle { right: auto; left: 0; }

/* ---------------------------------------------------------------------
 * 9. Select2 widgets
 * ------------------------------------------------------------------- */
[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
  right: auto;
  left: 3px;
}
[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered {
  padding-left: 20px;
  padding-right: 8px;
  text-align: right;
}
[dir="rtl"] .select2-container--default .select2-search--dropdown .select2-search__field { text-align: right; }
[dir="rtl"] .select2-results__option { text-align: right; }
[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
  float: right;
  margin-right: 0;
  margin-left: 5px;
}

/* ---------------------------------------------------------------------
 * 10. Dropdowns (custom oh-dropdown)
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-dropdown__menu { right: auto; left: 0; text-align: right; }
[dir="rtl"] .oh-dropdown__icon { margin-right: 0; margin-left: 0.5rem; }

/* ---------------------------------------------------------------------
 * 11. Modals
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-modal__dialog-header { text-align: right; }
[dir="rtl"] .oh-modal__close { right: auto; left: 1rem; }
[dir="rtl"] .modal-header .btn-close { margin-right: auto; margin-left: 0; }

/* ---------------------------------------------------------------------
 * 12. Cards, kanban, tabs, general helpers
 * ------------------------------------------------------------------- */
[dir="rtl"] .oh-card__title,
[dir="rtl"] .oh-card__body { text-align: right; }

[dir="rtl"] .oh-tabs__tablist { padding-right: 0; }

[dir="rtl"] .oh-general__header,
[dir="rtl"] .oh-titlebar__container { flex-direction: row-reverse; }

/* SweetAlert2 already ships .swal2-rtl; force it on for RTL locales */
[dir="rtl"] .swal2-popup { direction: rtl; text-align: right; }
