/* RTL (default) - label shrinks to the right */
.MuiFormControl-root:focus-within > label[data-shrink="false"],
.MuiFormControl-root:has(input:not(:placeholder-shown)) > label[data-shrink="false"] {
  transform: translate(-14px, -9px) scale(0.75) !important;
  pointer-events: auto;
  user-select: none;
  max-width: calc(133% - 32px);
}

/* LTR (English) - label shrinks to the left */
[dir="ltr"] .MuiFormControl-root:focus-within > label[data-shrink="false"],
[dir="ltr"] .MuiFormControl-root:has(input:not(:placeholder-shown)) > label[data-shrink="false"] {
  transform: translate(14px, -9px) scale(0.75) !important;
  pointer-events: auto;
  user-select: none;
  max-width: calc(133% - 32px);
}

/* LTR - fix label resting position (inside field, left side) */
[dir="ltr"] label.MuiInputLabel-root[data-shrink="false"] {
  right: auto !important;
  left: 0 !important;
  transform-origin: top left !important;
}

/* LTR - fix the label that uses top:50% + translateY(-50%) centering */
[dir="ltr"] .muirtl-1m7xc33 {
  right: auto !important;
  left: 0 !important;
  transform-origin: top left !important;
}

/* LTR - ensure shrunk label doesn't overflow the field border */
[dir="ltr"] label.MuiInputLabel-root {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  max-width: calc(100% - 28px) !important;
}

/* LTR - when label is shrunk (focused/filled), limit width to field width */
[dir="ltr"] .MuiFormControl-root:focus-within > label,
[dir="ltr"] .MuiFormControl-root:has(input:not(:placeholder-shown)) > label {
  max-width: calc(133% - 40px) !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.MuiFormControl-root:focus-within legend,
.MuiFormControl-root:has(input:not(:placeholder-shown)) legend {
  max-width: 100% !important;
}

/* LTR - fix legend (notch) width to not exceed fieldset */
[dir="ltr"] .MuiOutlinedInput-notchedOutline legend {
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
