/* Fenix Command Center — bidirectional text                      21-Sep-2026
   ==========================================================================
   Almost every field in this system mixes Persian with English: a Persian
   sentence containing "PartsBase", a part number, an e-mail address, a phone
   number, a time like 15:15. The pages were all declared dir="ltr", so the
   browser gave every paragraph an LTR base direction and reordered the Persian
   runs around it — which is why a calendar note read back-to-front.

   The fix is one CSS property. `unicode-bidi: plaintext` tells the browser to
   take each paragraph's base direction from its OWN first strong character,
   exactly as a chat client does, instead of inheriting it from the page. A
   Persian line then reads right-to-left with its English fragments left-to-
   right inside it, and an English line is untouched.

   Loaded BEFORE each page's own <style> block on purpose, so any page-specific
   rule still wins.
   ========================================================================== */

/* 1 — direction per paragraph, for anything that carries written text. */
.bidi,
[dir="auto"],
p, li, dd, dt, blockquote, figcaption, label, summary,
td, th,
textarea,
input[type="text"], input[type="search"], input[type="email"], input:not([type]),
.desc, .ttl, .title, .subject, .summary, .note, .notes, .body, .text,
.msg, .message, .bubble, .content, .preview, .snippet, .detail, .details,
.outcome, .follow-up, .agenda, .reason, .evidence, .comment {
  unicode-bidi: plaintext;
}

/* 2 — alignment follows the text's own direction, not the page's.
   Kept off table cells so existing right-aligned number columns are safe. */
.bidi,
[dir="auto"],
p, li, dd, dt, blockquote, figcaption,
textarea,
input[type="text"], input[type="search"], input[type="email"], input:not([type]),
.desc, .ttl, .title, .subject, .summary, .note, .notes, .body, .text,
.msg, .message, .bubble, .content, .preview, .snippet, .detail, .details,
.outcome, .follow-up, .agenda, .reason, .evidence, .comment {
  text-align: start;
}

/* 3 — keep technical strings in one piece inside a Persian sentence.
   A part number, reference, address or phone number must never be split or
   reversed: isolate it and force it left-to-right. */
bdi, code, kbd, samp, var,
.ltr, .mono, .num, .pn, .ref, .email, .phone, .amount, .code {
  unicode-bidi: isolate;
  direction: ltr;
}

/* 3b — preformatted blocks are terminal output, JSON and code in this system.
   They are laid out by column position, so they must stay left-to-right even
   when a Persian word appears inside them. */
pre, pre * {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

/* 4 — Persian and Arabic read better with a little more line height and a
   font that actually has the glyphs. */
:lang(fa), :lang(ar), .rtl {
  line-height: 1.85;
}

/* 5 — a block explicitly marked RTL still behaves. */
[dir="rtl"], .rtl {
  direction: rtl;
  text-align: start;
}
