.max-length-indicator {
  position: absolute;
  right: 0.75rem;
  bottom: -0.5625rem;

  padding: 0 0.25rem;
  border-radius: 0.25rem;

  font-size: 0.75rem;
  color: var(--color-text-secondary);

  background: var(--color-background);
}

.input-group {
  position: relative;
  margin-bottom: 1.125rem;

  label {
    pointer-events: none;
    cursor: var(--custom-cursor, text);

    position: absolute;
    top: 0.6875rem;
    left: 1rem;
    transform-origin: left center;

    display: block;

    padding: 0 0.3125rem;

    font-size: 1rem;
    font-weight: var(--font-weight-normal);
    color: var(--color-placeholders);
    white-space: nowrap;

    background-color: var(--color-background);

    transition: transform 0.15s ease-out, color 0.15s ease-out;
  }

  &.with-arrow {
    &::after {
      content: "";

      position: absolute;
      top: 1rem;
      right: 2rem;
      transform: rotate(-45deg);

      width: 0.75rem;
      height: 0.75rem;
      border-bottom: 1px var(--color-text-secondary) solid;
      border-left: 1px var(--color-text-secondary) solid;
    }
  }

  &.touched label,
  &.error label,
  &.success label,
  .form-control:focus + label,
  .form-control.focus + label {
    transform: scale(0.75) translate(0, -2rem);
  }

  input::placeholder,
  .form-control::placeholder {
    color: var(--color-placeholders);
  }

  &.touched label {
    color: var(--color-text-secondary);
  }

  &.error label {
    color: var(--color-error) !important;
  }

  &.success label {
    color: var(--color-text-green) !important;
  }

  &.disabled {
    pointer-events: none;
    opacity: 0.5;
  }

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

    label {
      right: 0.75rem;
      left: auto;
    }

    &.with-arrow {
      &::after {
        right: auto;
        left: 2rem;
        border-right: 1px var(--color-text-secondary) solid;
        border-left: none;
      }
    }

    &.touched label,
    &.error label,
    &.success label,
    .form-control:focus + label,
    .form-control.focus + label {
      transform: scale(0.75) translate(1.5rem, -2.25rem);
    }
  }
}

.form-control {
  --border-width: 1px;

  display: block;

  width: 100%;
  height: 3rem;
  padding: calc(0.75rem - var(--border-width)) calc(1.1875rem - var(--border-width)) 0.6875rem;
  border: var(--border-width) solid var(--color-borders-input);
  border-radius: var(--border-radius-default);

  font-size: 1rem;
  line-height: 1.25rem;
  color: var(--color-text);
  overflow-wrap: anywhere;

  -webkit-appearance: none;
  background-color: var(--color-background);
  outline: none;

  transition: border-color 0.15s ease;

  // Hide hint for Safari password strength meter
  &::-webkit-strong-password-auto-fill-button {
    position: absolute;

    overflow: hidden !important;

    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;

    opacity: 0;
    clip: rect(0, 0, 0, 0);
  }

  &::-ms-clear,
  &::-ms-reveal {
    display: none;
  }

  &[dir] {
    text-align: initial;
  }

  &:hover {
    border-color: var(--color-primary);

    & + label {
      color: var(--color-primary);
    }
  }

  &:focus,
  &.focus {
    border-color: var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--color-primary);
    caret-color: var(--color-primary);

    & + label {
      color: var(--color-primary);
    }
  }

  &:disabled {
    background: none !important;
  }

  .error & {
    border-color: var(--color-error);
    box-shadow: inset 0 0 0 1px var(--color-error);
    caret-color: var(--color-error);
  }

  .success & {
    border-color: var(--color-text-green);
    box-shadow: inset 0 0 0 1px var(--color-text-green);
    caret-color: var(--color-text-green);
  }

  // Disable yellow highlight on autofill
  &:autofill,
  &:-webkit-autofill-strong-password,
  &:-webkit-autofill-strong-password-viewable,
  &:-webkit-autofill-and-obscured {
    box-shadow: inset 0 0 0 10rem var(--color-background);

    -webkit-text-fill-color: var(--color-text);
  }
}

select.form-control {
  option {
    line-height: 2rem;
  }
}

textarea.form-control {
  resize: none;

  overflow: hidden;

  padding-top: calc(0.8125rem - var(--border-width));
  padding-bottom: calc(1rem - var(--border-width));

  line-height: 1.3125rem;
}

.input-group.password-input {
  position: relative;

  .form-control {
    padding-right: 3.375rem;
  }

  .toggle-password {
    cursor: var(--custom-cursor, pointer);

    position: absolute;
    top: 0;
    right: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 3rem;
    height: 3rem;

    font-size: 1.5rem;
    color: var(--color-text-secondary);

    opacity: 0.7;
    outline: none !important;

    &:hover,
    &:focus {
      opacity: 1;
    }
  }

  &[dir="rtl"] {
    .form-control {
      padding-right: calc(0.9rem - var(--border-width));
      padding-left: 3.375rem;
    }

    .toggle-password {
      right: auto;
      left: 0;
    }
  }
}
