@use 'ej2-base/styles/common/mixin' as *;
@mixin fluent-focus-border {
  @if $skin-name == 'FluentUI' {
    border: 1px solid transparent;
  }
}

@mixin fluent-label-border {
  @if $skin-name == 'FluentUI' {
    border: 1px solid $radio-btn-border-color;
  }
}

@include export-module('radiobutton-layout') {
  .e-radio-wrapper {
    display: inline-block;
    line-height: $radio-btn-wrapper-line-height;
    position: relative;
  }

  /* stylelint-disable property-no-vendor-prefix */
  .e-radio {
    -webkit-appearance: none;
    height: $radio-btn-radio-height;
    opacity: 0;
    position: absolute;
    width: $radio-btn-radio-width;

    &:not(:checked):not(:disabled):hover {
      +label,
      +label.e-rtl,
      +label.e-right {
        @if $skin-name == 'FluentUI' {
          &::after {
            background-color: $radio-btn-uncheck-background-color;
            border: 1px solid;
            border-radius: 50%;
            box-sizing: border-box;
            color: $radio-btn-uncheck-color;
            content: '';
            height: $radio-btn-icon-height;
            left: $radio-btn-icon-left;
            position: absolute;
            top: $radio-btn-icon-top;
            transform: scale(1);
            width: $radio-btn-icon-width;
          }
        }
      }

      +label.e-rtl,
      +label.e-right {
        &::after {
          left: $radio-auto-position;
        }
      }
    }

    &:focus-visible {
      +label {
        @if $skin-name == 'fluent2' {
          box-shadow: $switch-box-shadow;
          border-radius: $radio-focus-border-radius;
        }
      }
    }

    +label {
      -webkit-tap-highlight-color: transparent;
      cursor: pointer;
      display: inline-block;
      margin: $radio-btn-zero-padding;
      position: relative;
      user-select: none;
      vertical-align: middle;
      white-space: nowrap;
      @if $skin-name == 'FluentUI' {
        border: 1px solid transparent;
        height: 24px;
      }
      @if $skin-name == 'fluent2' {
        margin: $radio-btn-focus-margin;
      }

      & .e-label {
        display: inline-block;
        font-family: $font-family;
        font-size: $radio-btn-font-size;
        font-weight: $radio-label-font-weight;
        line-height: $radio-btn-line-height;
        padding-left: $radio-btn-padding-left;
        vertical-align: text-top;
        white-space: normal;
      }

      &:focus,
      &.e-focus {
        @include fluent-focus-border;
      }

      &::before {
        border: $radio-btn-border;
        border-radius: $radio-button-border-radius;
        box-sizing: border-box;
        content: '';
        height: $radio-btn-height;
        @if $skin-name == 'FluentUI' {
          left: 1px;
          top: 1px;
        }
        @else {
          left: $radio-btn-zero-padding;
        }
        position: absolute;
        width: $radio-btn-width;
      }

      &:focus {
        &::before {
          box-shadow: $radio-btn-focussed-box-shadow;
          @if $skin-name == 'bootstrap5.3' {
            border-color: $border-selected;
          }
        }
      }

      &:active {
        &::before {
          @if $skin-name == 'bootstrap5.3' {
            box-shadow: $radio-btn-focussed-box-shadow;
            border-color: $border-selected !important; /* stylelint-disable-line declaration-no-important */
            background-color: $content-bg-color-pressed;
          }
          @if $skin-name == 'tailwind3' {
            box-shadow: $radio-btn-focussed-box-shadow;
          }
        }
      }

      &::after {
        border: $radio-btn-after-border;
        border-radius: $radio-button-border-radius;
        box-sizing: border-box;
        content: '';
        height: $radio-btn-icon-height;
        left: $radio-btn-icon-left;
        position: absolute;
        top: $radio-btn-icon-top;
        transform: scale(0);
        width: $radio-btn-icon-width;
      }

      & .e-ripple-container {
        border-radius: $radio-button-border-radius;
        height: $radio-btn-ripple-size;
        left: $radio-btn-ripple-position;
        position: absolute;
        top: $radio-btn-ripple-position;
        width: $radio-btn-ripple-size;
        z-index: 1;

        & .e-ripple-element {
          @if $skin-name == 'Material3' {
            border-radius: $radio-btn-ripple-border-radius;
          }
        }
      }

      &.e-right,
      &.e-rtl {
        & .e-label {
          padding-left: $radio-btn-zero-padding;
          padding-right: $radio-btn-padding-left;
        }

        &::before {
          left: $radio-auto-position;
          right: $radio-btn-zero-padding;
        }

        &::after {
          left: $radio-auto-position;
          right: $radio-btn-icon-right;
        }

        & .e-ripple-container {
          left: $radio-auto-position;
          right: $radio-btn-ripple-position;
        }
      }

      &.e-right {
        &.e-rtl {
          & .e-label {
            padding-left: $radio-btn-padding-left;
            padding-right: $radio-btn-zero-padding;
          }

          &::before {
            left: $radio-btn-zero-padding;
            right: $radio-auto-position;
          }

          &::after {
            left: $radio-btn-icon-right;
            right: $radio-auto-position;
          }

          & .e-ripple-container {
            left: $radio-nrml-ripple-rtl-container-left;
            right: $radio-auto-position;
          }
        }
      }

      &.e-small {

        & .e-label {
          line-height: $radio-btn-small-line-height;
          padding-left: $radio-btn-small-padding;
        }

        &::before {
          height: $radio-btn-small-height;
          width: $radio-btn-small-width;
        }

        &::after {
          height: $radio-btn-small-icon-height;
          left: $radio-btn-small-icon-left;
          top: $radio-btn-small-icon-top;
          width: $radio-btn-small-icon-width;
        }

        & .e-ripple-container {
          left: $radio-btn-small-ripple-position;
          top: $radio-btn-small-ripple-position;
        }

        &.e-right,
        &.e-rtl {
          & .e-label {
            padding-left: $radio-btn-zero-padding;
            padding-right: $radio-btn-small-padding;
          }

          &::after {
            left: $radio-auto-position;
            right: $radio-btn-small-icon-right;
          }

          & .e-ripple-container {
            left: $radio-auto-position;
            right: $radio-btn-small-ripple-position;
          }
        }

        &.e-right {
          &.e-rtl {
            & .e-label {
              padding-left: $radio-btn-small-padding;
              padding-right: $radio-btn-zero-padding;
            }

            &::after {
              left: $radio-btn-small-icon-right;
              right: $radio-auto-position;
            }

            & .e-ripple-container {
              left: $radio-ripple-left;
              right: $radio-auto-position;
            }
          }
        }
      }
    }

    &:focus,
    .e-focus {
      +label,
      & .e-label {
        @include fluent-label-border;
      }
    }

    &:focus:not(:focus-visible) {
      +label,
      & .e-label {
        @include fluent-focus-border;
      }
    }

    &:focus-visible {
      +label,
      & .e-label {
        @include fluent-label-border;
      }
    }

    &:checked {
      +label {
        &::after {
          transform: scale(1);
          transition: $radio-btn-check-transition;
        }
      }
    }
  }

  .e-small .e-radio + label,
  .e-radio + label.e-small {
    @if $skin-name == 'fluent2' {
      margin: $radio-small-btn-label-margin;
    }
    & .e-label {
      line-height: $radio-btn-small-line-height;
      padding-left: $radio-btn-small-padding;
      @if $skin-name == 'fluent2' or $skin-name == 'tailwind3' {
        font-size: $text-xs;
      }
    }

    &::before {
      height: $radio-btn-small-height;
      width: $radio-btn-small-width;
    }

    &::after {
      height: $radio-btn-small-icon-height;
      left: $radio-btn-small-icon-left;
      top: $radio-btn-small-icon-top;
      width: $radio-btn-small-icon-width;
    }

    & .e-ripple-container {
      left: $radio-btn-small-ripple-position;
      top: $radio-btn-small-ripple-position;
    }

    &.e-right,
    &.e-rtl {
      & .e-label {
        padding-left: $radio-btn-zero-padding;
        padding-right: $radio-btn-small-padding;
      }

      &::after {
        left: $radio-auto-position;
        right: $radio-btn-small-icon-right;
      }

      & .e-ripple-container {
        left: $radio-auto-position;
        right: $radio-btn-small-ripple-position;
      }
    }

    &.e-right {
      &.e-rtl {
        & .e-label {
          padding-left: $radio-btn-small-padding;
          padding-right: $radio-btn-zero-padding;
        }

        &::after {
          left: $radio-btn-small-icon-right;
          right: $radio-auto-position;
        }

        & .e-ripple-container {
          left: $radio-ripple-left;
          right: $radio-auto-position;
        }
      }
    }
  }
  .e-radio-wrapper.e-error .e-radio + label::before {
    border-color: $radio-btn-border-error-color;
  }
}
