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

  position: relative;

  display: flex;
  align-items: center;

  width: 100%;
  min-height: 3rem;
  margin: 0;
  padding-inline-start: 4.25rem;

  text-align: left;

  &:hover {
    border-radius: var(--border-radius-default);
    background-color: var(--color-chat-hover);
  }

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

  &.with-icon {
    padding-inline-start: 1rem;
    .Radio-main {
      &::before,
      &::after {
        right: 1.1875rem;
        left: auto;
      }

      &::after {
        right: 1.5rem;
      }
    }
  }

  &.withSubLabel .Radio-main {
    padding: 0.4375rem 0 0.5625rem 0;
  }

  &.hidden-widget {
    cursor: var(--custom-cursor, default);
    .Radio-main {
      &::before,
      &::after {
        visibility: hidden;
      }
    }

    &:hover {
      background-color: transparent;
    }
  }

  &.canCheckedInDisabled {
    .Radio-main {
      &::before {
        visibility: visible;
      }
    }
  }

  > input {
    position: absolute;
    z-index: var(--z-below);
    opacity: 0;
  }

  .Radio-main {
    &::before,
    &::after {
      content: "";

      position: absolute;
      top: 50%;
      transform: translateY(-50%);

      display: block;
    }

    &::before {
      left: 1.125rem; // 1 + ((1.5 - 1.25) / 2)

      width: 1.25rem;
      height: 1.25rem;
      border: 2px solid var(--color-borders-input);
      border-radius: 50%;

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

      transition: border-color 0.1s ease, opacity 0.1s ease;
    }

    &::after {
      left: 1.4375rem; // 1 + ((1.5 - 0.625) / 2)

      width: 0.625rem;
      height: 0.625rem;
      border-radius: 50%;

      opacity: 0;
      background: var(--color-primary);

      transition: opacity 0.1s ease;
    }

    .label {
      unicode-bidi: plaintext;
      display: block;

      line-height: 1.5rem;
      text-align: left;
      overflow-wrap: anywhere;
    }

    .subLabel {
      unicode-bidi: plaintext;
      display: block;

      margin-top: 0.25rem;

      font-size: 0.875rem;
      line-height: 1rem;
      color: var(--color-text-secondary);
    }

    .subLabelLink {
      cursor: pointer;
    }
  }

  input:checked ~ .Radio-main {
    &::before {
      border-color: var(--color-primary);
    }

    &::after {
      opacity: 1;
    }
  }

  &.loading {
    .Radio-main::before,
    .Radio-main::after {
      opacity: 0 !important;
    }

    .Spinner {
      --spinner-size: 1.25rem;

      position: absolute;
      top: 50%;
      left: 1rem;
      transform: translateY(-50%);

      opacity: 0;

      animation: fade-in 0.2s ease forwards;
    }
  }

  &[dir="rtl"] {
    .Radio-main {
      text-align: right;

      &::before {
        right: 1.0625rem;
        left: auto;
      }

      &::after {
        right: 1.375rem;
        left: auto;
      }
    }

    .label,
    .subLabel {
      text-align: right;
    }

    &.loading .Spinner {
      right: 1.0625rem;
      left: auto;
    }

    &.onlyInput .Radio-main::after {
      right: 0.3125rem;
      left: auto;
    }
  }

  &.onlyInput {
    position: relative;

    min-height: auto;
    margin-block: 0 1.25rem;
    padding-inline-start: 1.25rem;

    line-height: 1.25rem;

    .Radio-main {
      &::before {
        top: 0;
        right: 0;
        left: 0;
        transform: none;
      }
      &::after {
        top: 0;
        left: 0.3125rem;
        transform: translateY(50%);
      }
    }

    .Spinner {
      inset: 0 !important;
      transform: none;
    }
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
