/* ── Font families with Arabic support ─────────────────────────────────── */

[dir="rtl"] {
    --font-body: 'Noto Sans Arabic', 'Avenir Roman', 'Avenir', 'Helvetica Neue', sans-serif;
    --font-display: 'Noto Sans Arabic', 'Aiglon Wide Demi', 'Arial Black', sans-serif;
}

/* ── Base text direction ─────────────────────────────────────────────────── */

[dir="rtl"] { text-align: right; }

[dir="rtl"] .skip-link {
    left: auto;
    right: 0;
    border-radius: 0 0 4px 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

[dir="rtl"] #app-header { flex-direction: row-reverse; }

/* ── Nav tabs ────────────────────────────────────────────────────────────── */

[dir="rtl"] .nav-tabs { flex-direction: row-reverse; }

/* lang-toggle button sits next to nav tabs; flip margin in RTL */
[dir="rtl"] .lang-toggle { margin-left: 0; margin-right: 8px; }

/* ── Dashboard: content layout ───────────────────────────────────────────── */

/* Panel moves from right to left side; map stays on the right */
[dir="rtl"] #content-wrapper { flex-direction: row-reverse; }

/* Panel border flips from left edge to right edge */
[dir="rtl"] #panel {
    border-left: none;
    border-right: 1px solid #ddd;
}

/* ── Controls overlay ────────────────────────────────────────────────────── */

/* Float to right side of the map instead of left */
[dir="rtl"] #controls {
    left: auto;
    right: 20px;
    text-align: right;
}

[dir="rtl"] .control-section { text-align: right; }

[dir="rtl"] .styled-select { text-align: right; }

[dir="rtl"] .year-toggle { flex-direction: row-reverse; }

/* ── Panel content ───────────────────────────────────────────────────────── */

[dir="rtl"] #panel-content { text-align: right; }

[dir="rtl"] .region-tag { text-align: right; }

[dir="rtl"] .filter-description { text-align: right; }

[dir="rtl"] .action-buttons { flex-direction: row-reverse; }

/* Flag margin: sits to the right of text in LTR, to the left in RTL */
[dir="rtl"] .flag-panel { margin-right: 0; margin-left: 6px; }

/* ── Bar charts ──────────────────────────────────────────────────────────── */

/* Bars grow from right in RTL */
[dir="rtl"] .bar-track { direction: rtl; }

[dir="rtl"] .bar-fill { float: right; }


[dir="rtl"] .chart-label,
[dir="rtl"] .bar-label { text-align: right; }

[dir="rtl"] .simple-bar-label { text-align: right; }

/* ── Profile: bar chart row layout ──────────────────────────────────────── */

[dir="rtl"] .bar-row { flex-direction: row-reverse; }

[dir="rtl"] .bar-group-label { flex-direction: row-reverse; }

[dir="rtl"] .bar-gender-label { text-align: left; }

[dir="rtl"] .simple-bar-row { flex-direction: row-reverse; }

/* ── Map legend ──────────────────────────────────────────────────────────── */

[dir="rtl"] #map-legend { text-align: right; }

/* Interval labels reverse order to match RTL reading direction */
[dir="rtl"] .legend-intervals { direction: rtl; }

/* ── Country search ──────────────────────────────────────────────────────── */

[dir="rtl"] #country-search { text-align: right; direction: rtl; }

/* ── Embed modal ─────────────────────────────────────────────────────────── */

[dir="rtl"] .embed-modal-content { text-align: right; }

[dir="rtl"] .embed-modal-header { flex-direction: row-reverse; }

/* ── Mobile bottom sheet ─────────────────────────────────────────────────── */

[dir="rtl"] .mobile-sheet-header { flex-direction: row-reverse; }

[dir="rtl"] .mobile-sheet-peek-content { text-align: right; }

[dir="rtl"] .mobile-sheet-full-content { text-align: right; }

/* ── Profile: hero section ───────────────────────────────────────────────── */

[dir="rtl"] .country-hero { text-align: right; }

[dir="rtl"] .hero-stats { text-align: right; }

/* ── Profile: sections grid ──────────────────────────────────────────────── */

[dir="rtl"] .section-header { text-align: right; }

/* Section title description text */
[dir="rtl"] .section-title p { text-align: right; }

/* ── Profile: view toggles ───────────────────────────────────────────────── */

[dir="rtl"] .view-toggle { flex-direction: row-reverse; }

/* ── Profile: frequency filter ───────────────────────────────────────────── */

[dir="rtl"] .freq-filter { flex-direction: row-reverse; }

/* ── Footer ──────────────────────────────────────────────────────────────── */

[dir="rtl"] #app-footer { direction: rtl; }

[dir="rtl"] .footer-nav { direction: rtl; }

[dir="rtl"] .footer-nav-col { text-align: right; }

[dir="rtl"] .footer-bottom { direction: rtl; }

[dir="rtl"] .footer-credits { text-align: right; }

/* ── Profile: gender legend ──────────────────────────────────────────────── */

[dir="rtl"] .gender-legend { direction: rtl; }

[dir="rtl"] .legend-item { flex-direction: row-reverse; }

[dir="rtl"] .compare-legend-row { flex-direction: row-reverse; }

/* ── Profile: treemap ───────────────────────────────────────────────────── */

[dir="rtl"] .treemap-cell { text-align: center; }

[dir="rtl"] .treemap-value,
[dir="rtl"] .treemap-label {
    direction: rtl;
}

/* ── Profile: donut charts ──────────────────────────────────────────────── */

[dir="rtl"] .donut-item-label { direction: rtl; }

[dir="rtl"] .donut-legend { direction: rtl; }

[dir="rtl"] .donut-legend-item { flex-direction: row-reverse; }

[dir="rtl"] .donut-container { direction: rtl; }

/* ── Profile: stacked bar ───────────────────────────────────────────────── */

[dir="rtl"] .stacked-bar { flex-direction: row-reverse; }

[dir="rtl"] .stacked-legend { flex-direction: row-reverse; flex-wrap: wrap; }

[dir="rtl"] .stacked-legend-item { flex-direction: row-reverse; }
