/* ==========================================================================
   dallelha admin — RTL corrections
   Loaded LAST, and only when the active language is bidi
   (templates/admin/base_site.html, {% if LANGUAGE_BIDI %}).

   Its two siblings in this directory are machine-generated full flips of the
   vendor CSS (see the header of each). This file is the hand-written layer for
   the things RTLCSS structurally cannot do — icon glyphs, content strings —
   and for any mis-flip found during visual verification. It loads after them,
   so an equal-specificity rule here always wins.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar disclosure chevron
   Jazzmin's sidebar renders <i class="nav-arrow fas fa-chevron-right"> for a
   collapsible app group. RTLCSS flipped the arrow's position and its open-state
   rotate(90deg) → rotate(-90deg), but the glyph itself comes from a Font
   Awesome class whose `content` codepoint is data, not geometry — no stylesheet
   transform can mirror it. Swap it for fa-chevron-left (\f053) so a collapsed
   group points into the page instead of off the edge.
   -------------------------------------------------------------------------- */
.nav-arrow::before {
  content: "\f053";
}

/* --------------------------------------------------------------------------
   Login page
   admin/login.html extends registration/base.html, not base_site.html, so it
   gets the RTL sheets only because templates/admin/login.html re-declares the
   same extrastyle block. Input groups are the one visibly wrong thing there:
   Bootstrap welds the addon and the control together by zeroing the adjacent
   corner radii, and those are physical properties RTLCSS flips per-rule but
   Bootstrap's `.input-group > :not(:first-child)` selectors still select by
   DOM order, not visual order.
   -------------------------------------------------------------------------- */
[dir="rtl"] .login-box .input-group > .form-control:not(:last-child),
[dir="rtl"] .login-box .input-group > .form-select:not(:last-child) {
  border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0;
}

[dir="rtl"] .login-box .input-group > .input-group-text:last-child {
  border-radius: var(--bs-border-radius) 0 0 var(--bs-border-radius);
}

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

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

/* --------------------------------------------------------------------------
   Breadcrumbs
   Bootstrap's separator is injected via ::before content, so the "/" keeps its
   LTR reading order regardless of the flip. Isolate it so a trailing Arabic
   crumb cannot pull it out of place.
   -------------------------------------------------------------------------- */
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
  unicode-bidi: isolate;
}

/* --------------------------------------------------------------------------
   Changelist / form odds and ends
   -------------------------------------------------------------------------- */

/* Django's own admin JS writes inline `style="..."` on the object-tools and
   filter column in some views; keep the results table itself honest. */
[dir="rtl"] #changelist table thead th {
  text-align: right;
}

/* The action-checkbox column must stay narrow and leading-edge aligned. */
[dir="rtl"] #changelist table td.action-checkbox,
[dir="rtl"] #changelist table th.action-checkbox-column {
  text-align: center;
}

/* Help text sits under its field; align it with the label, not the viewport. */
[dir="rtl"] .form-text,
[dir="rtl"] .help-block,
[dir="rtl"] .helptext {
  text-align: right;
}

/* Inline formsets: the delete checkbox column and the "add another" link. */
[dir="rtl"] .inline-related .inline-deletelink,
[dir="rtl"] .add-row a {
  float: right;
}
