/*
 * RTL-only corrections for third-party widgets (ApexCharts, flatpickr, select2,
 * daterangepicker). These scripts position their popups with physical inline
 * offsets, so the fixes here are physical on purpose; everything else in the
 * project uses logical properties (see main.css). Loaded only when the page is RTL.
 */

/*
 * The RTL bundle mirrors `left` into `right` for widgets whose scripts set an
 * inline `left`. With both sides set the box stretches across the page, so the
 * mirrored side is released again.
 */
html[dir="rtl"] .apexcharts-tooltip,
html[dir="rtl"] .apexcharts-xaxistooltip,
html[dir="rtl"] .apexcharts-yaxistooltip,
html[dir="rtl"] .apexcharts-menu,
html[dir="rtl"] .flatpickr-calendar,
html[dir="rtl"] .daterangepicker {
    right: auto !important;
}

/* select2 positions its dropdown with a `left` offset from script; undo the mirror. */
html[dir="rtl"] .select2-dropdown {
    right: auto;
    left: -100000px;
}

html[dir="rtl"] .select2-container--open .select2-dropdown {
    right: auto;
    left: 0;
}

/* Date picker header arrows: previous on the right, next on the left in RTL. */
html[dir="rtl"] .flatpickr-months .flatpickr-prev-month {
    right: 0 !important;
    left: auto !important;
}

html[dir="rtl"] .flatpickr-months .flatpickr-next-month {
    left: 0 !important;
    right: auto !important;
}

html[dir="rtl"] .flatpickr-months .flatpickr-prev-month svg,
html[dir="rtl"] .flatpickr-months .flatpickr-next-month svg {
    transform: scaleX(-1);
}
