/*
 * Right-to-left fixes for MUI fields in Arabic.
 *
 * The app switches MUI to direction "rtl" but does not install the emotion
 * RTL plugin that mirrors MUI's left/right rules. Everything that flows with
 * the text flipped on its own; everything MUI places with left/right or a
 * translateX did not:
 *   - floating labels stayed at the LEFT while the gap cut in the border for
 *     them moved to the RIGHT, so the border ran through the label text;
 *   - the dropdown arrow stayed at the right edge, on top of the selected
 *     text, which now starts there too;
 *   - helper text stayed left-aligned;
 *   - an icon inside a field kept its spacing on the wrong side.
 * These rules mirror MUI v5's defaults. They only apply under dir="rtl", so
 * the English layout is untouched.
 */

/* --- floating labels ---------------------------------------------------- */
[dir="rtl"] .MuiInputLabel-root.MuiInputLabel-formControl {
    left: auto !important;
    right: 0 !important;
    transform-origin: top right !important;
}
/* outlined */
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-outlined { transform: translate(-14px, 16px) scale(1) !important; }
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-outlined.MuiInputLabel-sizeSmall { transform: translate(-14px, 9px) scale(1) !important; }
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-outlined.MuiInputLabel-shrink { transform: translate(-14px, -9px) scale(0.75) !important; }
/* filled */
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-filled { transform: translate(-12px, 16px) scale(1) !important; }
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-filled.MuiInputLabel-sizeSmall { transform: translate(-12px, 13px) scale(1) !important; }
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-filled.MuiInputLabel-shrink { transform: translate(-12px, 7px) scale(0.75) !important; }
[dir="rtl"] .MuiInputLabel-formControl.MuiInputLabel-filled.MuiInputLabel-shrink.MuiInputLabel-sizeSmall { transform: translate(-12px, 4px) scale(0.75) !important; }
/* standard - no horizontal offset, only the corner it scales from changes */

/* --- helper text -------------------------------------------------------- */
[dir="rtl"] .MuiFormHelperText-root { text-align: right; }

/* --- dropdowns (Select) ------------------------------------------------- */
[dir="rtl"] .MuiSelect-icon { right: auto !important; left: 0; }
[dir="rtl"] .MuiSelect-icon.MuiSelect-iconOutlined,
[dir="rtl"] .MuiSelect-icon.MuiSelect-iconFilled { left: 7px; }
[dir="rtl"] .MuiSelect-select.MuiOutlinedInput-input { padding-right: 14px !important; padding-left: 32px !important; }
[dir="rtl"] .MuiSelect-select.MuiFilledInput-input { padding-right: 12px !important; padding-left: 32px !important; }
[dir="rtl"] .MuiSelect-select.MuiInputBase-input:not(.MuiOutlinedInput-input):not(.MuiFilledInput-input) { padding-right: 0 !important; padding-left: 24px !important; }

/* --- Autocomplete: clear / open buttons -------------------------------- */
[dir="rtl"] .MuiAutocomplete-endAdornment { right: auto !important; left: 9px; }
[dir="rtl"] .MuiAutocomplete-hasPopupIcon .MuiOutlinedInput-root,
[dir="rtl"] .MuiAutocomplete-hasClearIcon .MuiOutlinedInput-root { padding-right: 9px !important; padding-left: 39px !important; }
[dir="rtl"] .MuiAutocomplete-hasPopupIcon.MuiAutocomplete-hasClearIcon .MuiOutlinedInput-root { padding-left: 65px !important; }
[dir="rtl"] .MuiAutocomplete-hasPopupIcon .MuiOutlinedInput-root.MuiInputBase-sizeSmall,
[dir="rtl"] .MuiAutocomplete-hasClearIcon .MuiOutlinedInput-root.MuiInputBase-sizeSmall { padding-right: 6px !important; }

/* --- icons inside a field (InputAdornment); Autocomplete has its own above */
[dir="rtl"] .MuiInputAdornment-positionStart { margin-right: 0 !important; margin-left: 8px !important; }
[dir="rtl"] .MuiInputAdornment-positionEnd { margin-left: 0 !important; margin-right: 8px !important; }
[dir="rtl"] .MuiOutlinedInput-root.MuiInputBase-adornedStart:not(.MuiInputBase-adornedEnd):not(.MuiAutocomplete-inputRoot) { padding-left: 0 !important; padding-right: 14px !important; }
[dir="rtl"] .MuiOutlinedInput-root.MuiInputBase-adornedEnd:not(.MuiInputBase-adornedStart):not(.MuiAutocomplete-inputRoot) { padding-right: 0 !important; padding-left: 14px !important; }
[dir="rtl"] .MuiOutlinedInput-input.MuiInputBase-inputAdornedStart:not(.MuiInputBase-inputAdornedEnd):not(.MuiAutocomplete-input) { padding-right: 0 !important; padding-left: 14px !important; }
[dir="rtl"] .MuiOutlinedInput-input.MuiInputBase-inputAdornedEnd:not(.MuiInputBase-inputAdornedStart):not(.MuiAutocomplete-input) { padding-left: 0 !important; padding-right: 14px !important; }
