/* ==========================================
 * BOOTSTRAP RTL OVERRIDES
 * ========================================== */

/* Flip Bootstrap's LTR utilities to work with RTL */

[dir="rtl"] .col-auto,
[dir="rtl"] .col-sm-auto,
[dir="rtl"] .col-md-auto,
[dir="rtl"] .col-lg-auto,
[dir="rtl"] .col-xl-auto,
[dir="rtl"] .col-xxl-auto,
html.rtl .col-auto,
html.rtl .col-sm-auto,
html.rtl .col-md-auto,
html.rtl .col-lg-auto,
html.rtl .col-xl-auto,
html.rtl .col-xxl-auto {
  margin-left: auto;
  margin-right: 0;
}

/* Padding & Spacing for RTL */
[dir="rtl"] [class*="ps-"],
html.rtl [class*="ps-"] {
  padding-left: 0 !important;
}

[dir="rtl"] [class*="pe-"],
html.rtl [class*="pe-"] {
  padding-right: 0 !important;
}

[dir="rtl"] [class*="ms-"],
html.rtl [class*="ms-"] {
  margin-left: 0 !important;
}

[dir="rtl"] [class*="me-"],
html.rtl [class*="me-"] {
  margin-right: 0 !important;
}

/* Display utilities */
[dir="rtl"] .d-flex,
html.rtl .d-flex {
  display: flex;
}

[dir="rtl"] .flex-row-reverse,
html.rtl .flex-row-reverse {
  flex-direction: row-reverse;
}

/* Button groups for RTL */
[dir="rtl"] .btn-group,
html.rtl .btn-group {
  margin-left: 0.25rem;
  margin-right: 0;
}

/* Form alignment */
[dir="rtl"] .form-check,
html.rtl .form-check {
  padding-left: 0;
  padding-right: 1.5em;
}

[dir="rtl"] .form-check-input,
html.rtl .form-check-input {
  margin-left: 0;
  margin-right: -1.5em;
}

[dir="rtl"] .form-switch .form-check-input,
html.rtl .form-switch .form-check-input {
  margin-left: -2.5em;
  margin-right: 0;
}

/* List items */
[dir="rtl"] .list-group-item,
html.rtl .list-group-item {
  padding-left: 0;
  padding-right: 1rem;
}

/* Badges */
[dir="rtl"] .badge,
html.rtl .badge {
  margin-left: auto;
  margin-right: 0;
}

/* Breadcrumbs */
[dir="rtl"] .breadcrumb,
html.rtl .breadcrumb {
  text-align: right;
}

[dir="rtl"] .breadcrumb li:not(:last-child)::after,
html.rtl .breadcrumb li:not(:last-child)::after {
  content: " / ";
  margin: 0 0.5rem;
}

/* Cards */
[dir="rtl"] .card-header,
[dir="rtl"] .card-footer,
html.rtl .card-header,
html.rtl .card-footer {
  text-align: right;
}

/* Alerts */
[dir="rtl"] .alert-dismissible .btn-close,
html.rtl .alert-dismissible .btn-close {
  position: absolute;
  right: auto;
  left: 1rem;
  top: 0.5rem;
}

/* Modal */
[dir="rtl"] .modal-header .btn-close,
html.rtl .modal-header .btn-close {
  margin-left: 0;
  margin-right: auto;
}

/* Navbar for Bootstrap */
[dir="rtl"] .navbar-nav .nav-link,
html.rtl .navbar-nav .nav-link {
  padding-right: 1rem;
  padding-left: 0;
}

[dir="rtl"] .navbar-expand-lg .navbar-nav,
html.rtl .navbar-expand-lg .navbar-nav {
  flex-direction: row-reverse;
}

/* Pagination */
[dir="rtl"] .page-link,
html.rtl .page-link {
  margin-left: -1px;
  margin-right: 0;
}

[dir="rtl"] .pagination,
html.rtl .pagination {
  justify-content: center;
}

/* Tooltips and Popovers */
[dir="rtl"] .tooltip-inner,
[dir="rtl"] .popover,
html.rtl .tooltip-inner,
html.rtl .popover {
  text-align: right;
}

/* Spinners */
[dir="rtl"] .spinner-border,
[dir="rtl"] .spinner-grow,
html.rtl .spinner-border,
html.rtl .spinner-grow {
  margin-left: 0;
  margin-right: auto;
}

/* Tables */
[dir="rtl"] table,
[dir="rtl"] thead,
[dir="rtl"] tbody,
[dir="rtl"] tfoot,
[dir="rtl"] tr,
[dir="rtl"] td,
[dir="rtl"] th,
html.rtl table,
html.rtl thead,
html.rtl tbody,
html.rtl tfoot,
html.rtl tr,
html.rtl td,
html.rtl th {
  text-align: right;
}

/* Close button style adjustments */
[dir="rtl"] .btn-close,
html.rtl .btn-close {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
}

/* Offcanvas for RTL */
[dir="rtl"] .offcanvas-start,
html.rtl .offcanvas-start {
  left: auto;
  right: 0;
}

[dir="rtl"] .offcanvas-end,
html.rtl .offcanvas-end {
  right: auto;
  left: 0;
}

/* Dropdown for RTL */
[dir="rtl"] .dropdown-menu,
html.rtl .dropdown-menu {
  margin-left: 0;
  margin-right: 0.1rem;
  text-align: right;
  left: auto;
  right: 0;
}

/* Button positioning */
[dir="rtl"] .position-absolute,
html.rtl .position-absolute {
  right: auto;
  left: 0;
}

/* Image responsiveness */
[dir="rtl"] img,
html.rtl img {
  max-width: 100%;
  height: auto;
}
