/* ===================================================
   VigiAMS — right-to-left (Arabic) overrides
   Loaded only when the interface language is RTL (templates/_partials/
   _i18n_head.html). Bootstrap itself is swapped for bootstrap.rtl.min.css
   in base.html; this file mirrors VigiAMS's own physical left/right rules.
   =================================================== */

html[dir="rtl"] {
    --font-sans: 'Inter', 'IBM Plex Sans Arabic', 'Geeza Pro', 'Segoe UI', Tahoma, sans-serif;
}
html[dir="rtl"] body { letter-spacing: 0; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] h4, html[dir="rtl"] h5, html[dir="rtl"] h6 { letter-spacing: 0; }

/* ---------------------------------------------------
   Clinical safety: data keeps its own direction.
   Identifiers, results, drug/organism names and anything typed into a field
   are laid out by their own content, so "ESBL+", "≤0.5 mg/L", "MRN-0042/7"
   or "E. coli (CRE)" never have punctuation moved to the wrong end inside an
   Arabic page. Arabic text in the same places still reads right-to-left.
   --------------------------------------------------- */
html[dir="rtl"] td,
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select,
html[dir="rtl"] option,
html[dir="rtl"] .badge,
html[dir="rtl"] .chip-name,
html[dir="rtl"] .user-text b { unicode-bidi: plaintext; }
html[dir="rtl"] code,
html[dir="rtl"] pre,
html[dir="rtl"] kbd,
html[dir="rtl"] .mono,
html[dir="rtl"] .font-monospace,
html[dir="rtl"] [translate="no"]:not([lang="ar"]) { direction: ltr; unicode-bidi: isolate; }
/* Fields that only ever hold Latin data stay left-to-right. */
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="datetime-local"],
html[dir="rtl"] input[type="time"],
html[dir="rtl"] input[type="password"] { direction: ltr; text-align: right; }

/* Arrows and chevrons point the reading direction. */
html[dir="rtl"] .bi-chevron-right,
html[dir="rtl"] .bi-chevron-left,
html[dir="rtl"] .bi-arrow-right,
html[dir="rtl"] .bi-arrow-left,
html[dir="rtl"] .bi-arrow-right-short,
html[dir="rtl"] .bi-arrow-left-short,
html[dir="rtl"] .bi-box-arrow-right,
html[dir="rtl"] .bi-box-arrow-in-right,
html[dir="rtl"] .bi-caret-right-fill,
html[dir="rtl"] .bi-caret-left-fill { display: inline-block; transform: scaleX(-1); }

/* ---------------------------------------------------
   App frame: rail + panel on the right, top bar and content to its left.
   --------------------------------------------------- */
html[dir="rtl"] .app-nav { left: auto; right: 0; }
html[dir="rtl"] .rail { border-right: 0; border-left: 1px solid var(--rail-line); }
html[dir="rtl"] .rail-btn::after { left: auto; right: calc(100% + 10px); }
html[dir="rtl"] .nav-panel { border-right: 0; border-left: 1px solid var(--border-subtle); }
html[dir="rtl"] .topbar { left: 0; right: var(--nav-width); }
html[dir="rtl"] .main-content { margin-left: 0; margin-right: var(--nav-width); }
html[dir="rtl"] .topbar-search { margin-left: 0; margin-right: 8px; }
html[dir="rtl"] .topbar-search > .bi-search { left: auto; right: 15px; }
html[dir="rtl"] .topbar-search input { padding-left: 14px; padding-right: 40px; }
html[dir="rtl"] .topbar-search kbd { right: auto; left: 14px; }
html[dir="rtl"] .topbar-right { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .skip-link { left: auto; right: 8px; }

@media (max-width: 1199.98px) {
    html[dir="rtl"] .topbar-search { margin-right: 0; }
}
@media (max-width: 991.98px) {
    html[dir="rtl"] .app-nav { transform: translateX(100%); }
    html[dir="rtl"].nav-open .app-nav,
    html[dir="rtl"] .nav-open .app-nav { transform: none; }
}

/* Buttons: icon gap sits on the other side. */
html[dir="rtl"] .btn .me-1, html[dir="rtl"] .btn .me-2 { margin-left: 0 !important; }
html[dir="rtl"] .form-select { padding-right: 12px; padding-left: 32px; }
html[dir="rtl"] .form-select-sm { padding-right: 10px; padding-left: 28px; }

/* Card tables: outer padding mirrors. */
html[dir="rtl"] .card > .table-responsive > .table > :not(caption) > tr > :first-child { padding-left: 8px; padding-right: 16px; }
html[dir="rtl"] .card > .table-responsive > .table > :not(caption) > tr > :last-child { padding-right: 8px; padding-left: 16px; }
html[dir="rtl"] .work-table th:first-child, html[dir="rtl"] .work-table td:first-child { padding-left: 8px; padding-right: 16px; }
html[dir="rtl"] .work-table th:last-child, html[dir="rtl"] .work-table td:last-child { padding-right: 8px; padding-left: 16px; }

/* Alerts carry their accent on the start edge. */
html[dir="rtl"] .alert { border-left-width: 1px !important; }
html[dir="rtl"] .alert-dismissible { padding-right: 1rem; padding-left: 3rem; }

/* Header cells that were left-aligned align to the start edge. */
html[dir="rtl"] th,
html[dir="rtl"] .heatmap-grid th.heatmap-corner,
html[dir="rtl"] .heatmap-grid th.heatmap-row-head { text-align: right; }
html[dir="rtl"] .row-act,
html[dir="rtl"] .attn-age,
html[dir="rtl"] .data-card > div b { text-align: left; }

/* Sticky first columns stick to the right edge. */
html[dir="rtl"] #matrixTable tbody td.sticky-col,
html[dir="rtl"] .stratified-table tbody td.sticky-col,
html[dir="rtl"] .combination-table tbody td.sticky-col,
html[dir="rtl"] #matrixTable thead th.sticky-col,
html[dir="rtl"] .stratified-table thead th.sticky-col,
html[dir="rtl"] .combination-table thead th.sticky-col,
html[dir="rtl"] .heatmap-grid th.heatmap-corner,
html[dir="rtl"] .heatmap-grid th.heatmap-row-head {
    left: auto;
    right: 0;
    border-right: 0 !important;
    border-left: 1px solid var(--border-strong) !important;
}

/* Margin-auto pushes that right-align an item. */
html[dir="rtl"] .fresh-strip .fresh-hint { margin-left: 0; margin-right: auto; }

/* ---------------------------------------------------
   Language switcher (login, landing)
   --------------------------------------------------- */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
}
.lang-switch a { text-decoration: none; }
.lang-switch .lang-current { font-weight: 600; }
