/* =============================================================================
 * RTL residuals.
 *
 * The bulk of the LTR→RTL flipping (margins, paddings, floats, text-align,
 * Bootstrap utilities, sidebar/page-TOC positioning, search button, footer
 * gutters, etc.) is performed automatically by rtlcss on the compiled
 * `style.css`. See `scripts/build_offline.sh` — the rtlcss step runs after
 * `make html` whenever `CURRENT_LANG` is one of {fa, ar, he, ur}.
 *
 * This stylesheet covers ONLY the things rtlcss cannot infer:
 *
 *   1. Base `direction: rtl` on the document — rtlcss flips direction
 *      *values* but never inserts a new direction declaration.
 *   2. Code regions (code/pre/kbd/sig/etc.) staying LTR — those should
 *      always read left-to-right regardless of the surrounding language.
 *   3. Physical rotation of directional icon glyphs. An icon's `content:`
 *      is a Unicode codepoint pointing geometrically left or right; rtlcss
 *      doesn't know what character it is, so a horizontal flip via
 *      `transform: rotate(180deg)` is the only way to make it visually
 *      match the new reading order.
 *
 * Selectors are scoped to `html[lang|="fa"]`. Sphinx emits the matching
 * `lang` attribute via `language=fa`, and our `__init__.py` only loads
 * this stylesheet when the build language is in the RTL set, so the
 * scope is belt-and-suspenders.
 * ============================================================================= */

/* 1. Document direction. ----------------------------------------------------- */
html[lang|="fa"],
html[lang|="fa"] body {
    direction: rtl;
}

/* 2. Keep code regions LTR. ------------------------------------------------- */
html[lang|="fa"] code,
html[lang|="fa"] pre,
html[lang|="fa"] samp,
html[lang|="fa"] tt,
html[lang|="fa"] .literal,
html[lang|="fa"] .literal-block,
html[lang|="fa"] .highlight,
html[lang|="fa"] .highlight pre,
html[lang|="fa"] .doctest,
html[lang|="fa"] .traceback,
html[lang|="fa"] .sig,
html[lang|="fa"] .sig-prename,
html[lang|="fa"] .sig-name,
html[lang|="fa"] .sig-paren,
html[lang|="fa"] .sig-param,
html[lang|="fa"] .property {
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}
html[lang|="fa"] kbd{
    direction: rtl;
    text-align: left;
    unicode-bidi: embed;
}
/* Inline code in the middle of an RTL paragraph: isolate so neighbouring
   characters don't bleed into its bidi context. */
html[lang|="fa"] :not(pre) > code {
    unicode-bidi: isolate;
}

/* 3. Directional icon glyphs — physically rotate by 180°. ------------------ */
/* Covers the upstream `icomoon` family (.i-…), Font Awesome (.fa-…) and
   Odoo's UI icon set (.oi-arrow-…). Rotate ONLY icons that point left or
   right by design — chevrons, arrows, angles, carets. Non-directional
   icons like .i-edit, .fa-pencil, .fa-trash, etc. must never be rotated:
   the user can still read "edit" on a pencil whichever way the page
   flows. If you adopt another icon font that ships paired left/right
   glyphs, append its selectors below. */
html[lang|="fa"] .i-arrow-right::before,
html[lang|="fa"] .i-arrow-left::before,
html[lang|="fa"] .fa-chevron-right::before,
html[lang|="fa"] .fa-chevron-left::before,
html[lang|="fa"] .fa-arrow-right::before,
html[lang|="fa"] .fa-arrow-left::before,
html[lang|="fa"] .fa-angle-right::before,
html[lang|="fa"] .fa-angle-left::before,
html[lang|="fa"] .fa-caret-right::before,
html[lang|="fa"] .fa-caret-left::before,
html[lang|="fa"] .fa-long-arrow-right::before,
html[lang|="fa"] .fa-long-arrow-left::before,
html[lang|="fa"] [class^="oi-arrow-"]::before {
    display: inline-block;
    transform: rotate(180deg);
}

.chart-of-accounts table td{
    direction: ltr;
}

/* Accounting-entries cheat-sheet (valuation-accounting.fa.js): keep numeric
   columns left-aligned and LTR even on fa builds, so digits/signs read in
   their native order. */
html[lang|="fa"] .accounting-entries thead th,
html[lang|="fa"] .accounting-entries tr > td {
    padding-left: 12px;
    direction: ltr;
}

/* Tighter row padding for the configuration matrix on fa builds — Persian
   glyphs sit taller than Latin, so the upstream vertical padding makes
   .config-table rows feel airy. Trims top/bottom only, leaving horizontal
   padding to the upstream rule. */
html[lang|="fa"] .config-table th,
html[lang|="fa"] .config-table td {
    padding-top: 3px !important;
    padding-bottom: 2px !important;
}