@import "mixins/mixins";
@import "mixins/utils";
@import "mixins/button";
// @import "common/var";

@include b(radio) {
  color: $--radio-font-color;
  font-weight: $--radio-font-weight;
  line-height: 1;
  position: relative;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  outline: none;
  font-size: $--font-size-base;
  margin-right: 16px;
  @include utils-user-select(none);

  @include when(bordered) {
    padding: $--radio-bordered-padding;
    // border-radius: $--border-radius-base;
    border-radius: $--border-radius-medium;
    border: $--border-base;
    box-sizing: border-box;
    height: $--radio-bordered-height;

    &:hover {
      border: $--border-1 solid $--color-text-3;
      background: $--color-white;
      .el-radio__input:hover {
        background: none;
        &:not(.is-disabled) {
          background: $--checkbox-input-background-hover;
          // border-radius: $--checkbox-input-border-radius-hover;
          border-radius: $--border-radius-circle;
        }
      }
      // .is-checked, .is-checked:hover {
      //   background:  $--checkbox-input-background-hover;
      // }
      // .is-disabled, .is-disabled:hover {
      //   background: $--checkbox-input-background-hover;
      // }
    }
    &.is-checked {
      border-color: $--color-primary;
      &:hover {
        background: $--primary-1;
      }
    }

    &.is-disabled {
      cursor: not-allowed;
      border-color: $--border-color-lighter;
      // &:hover{
      //   background: $--checkbox-input-background-hover;
      // }
      &.is-checked {
        border-color: $--primary-3;
      }
    }

    & + .el-radio.is-bordered {
      // margin-left: 10px;
    }
  }

  @include m(medium) {
    &.is-bordered {
      padding: $--radio-bordered-medium-padding;
      // border-radius: $--button-medium-border-radius;
      border-radius: $--border-radius-medium;
      height: $--checkbox-bordered-medium-height;
      .el-radio__label {
        // line-height: 17px;
        font-size: $--button-medium-font-size;
        font-weight: $--font-weight-400;
        // margin-left: 4px;
      }
      .el-radio__inner {
        height: $--checkbox-bordered-medium-input-height;
        width: $--checkbox-bordered-medium-input-width;
      }
    }
  }
  @include m(small) {
    &.is-bordered {
      padding: $--radio-bordered-small-padding;
      // border-radius: $--button-small-border-radius;
      border-radius: $--border-radius-medium;
      height: $--checkbox-bordered-small-height;
      .el-radio__label {
        line-height: 15px;
        font-size: $--button-small-font-size;
      }
      .el-radio__inner {
        height: $--checkbox-bordered-small-input-height;
        width: $--checkbox-bordered-small-input-width;
      }
    }
  }
  @include m(mini) {
    &.is-bordered {
      padding: $--checkbox-bordered-mini-padding;
      // border-radius: $--button-mini-border-radius;
      border-radius: $--border-radius-small;
      height: $--checkbox-bordered-mini-height;
      .el-radio__label {
        line-height: 12px;
        font-size: $--button-mini-font-size;
      }
      .el-radio__inner {
        height: $--checkbox-bordered-mini-input-height;
        width: $--checkbox-bordered-mini-input-width;
      }
    }
  }

  &:last-child {
    margin-right: 0;
  }
  .icon-initial{
    color: initial;
    font-size: $--font-size-title-2;
  }

  @include e(input) {
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-block;
    position: relative;
    vertical-align: middle;
    line-height: 1;
    top: 1px;
    // width: $--checkbox-input-width-hover;
    // height: $--checkbox-input-height-hover;
    // line-height: 21px;
    // text-align: center;
    // top: -1px;
    &:hover {
      background: none;
      // border-radius: $--checkbox-input-border-radius-hover;
      border-radius: $--border-radius-circle;
      // bottom: 2px;
      // width: 24px;
      // height: 24px;
      // line-height: 28px;

      &:not(.is-disabled) {
        background: $--checkbox-input-background-hover;
        // border-radius: $--checkbox-input-border-radius-hover;
        border-radius: $--border-radius-circle;
        // top:-1px;
        // line-height: 27px;
      }
      &:not(.is-checked):not(.is-disabled)::before{
        background: $--checkbox-input-background-hover;
      }
    }
    &:hover .el-radio__inner {
      border: $--border-2 solid $--color-border-4;
    }

    &::before {
      position: absolute;
      display: block;
      box-sizing: border-box;
      background-color: transparent;
      // border-radius: $--checkbox-input-border-radius-hover;
      border-radius: $--border-radius-circle;
      transition: background-color 0.1s cubic-bezier(0, 0, 1, 1);
      content: "";
      top: 50%;
      left: 50%;
      width: 24px;
      height: 24px;
      transform: translate(-50%, -50%);
    }

    
  
  // &.is-readable{
  //   .el-radio__input{
  //     cursor: pointer;
  //   }
  //   .el-radio__label{
  //     cursor: pointer;
  //     color: $--color-text-1 !important;
  //   }
  // }

    @include when(disabled) {
      &:hover {
        &::before{
          background-color: transparent;
        }
      }
      &:not(.is-readable){
        .el-radio__inner {
          background-color: $--color-secondary;
          border-color: $--color-disabled-border;
          cursor: not-allowed;
          &::after {
            cursor: not-allowed;
            background-color: $--radio-disabled-icon-color;
          }
          & + .el-radio__label {
            cursor: not-allowed;
          }
        }
        &.is-checked {
          .el-radio__inner {
            background-color: $--radio-disabled-checked-input-fill;
            border-color: $--radio-disabled-checked-input-fill;
  
            &::after {
              background-color: $--radio-disabled-checked-icon-color;
            }
          }
        }
        & + span.el-radio__label {
          color: $--color-secondary-active;
          cursor: not-allowed;
        }

      }
    }

    @include when(checked) {
      .el-radio__inner {
        border-color: $--radio-checked-input-border-color;
        background: $--radio-checked-icon-color;

        &::after {
          transform: translate(-50%, -50%) scale(1);
        }
      }

      & + .el-radio__label {
        // color: $--radio-checked-font-color;
      }
      &:hover {
        background: none;
      }
    }

    @include when(focus) {
      .el-radio__inner {
        border-color: $--radio-input-border-color-hover;
      }
    }
  }
  @include e(inner) {
    border: $--border-2 solid $--color-border-3;
    // border-radius: $--radio-input-border-radius;
    border-radius: $--border-radius-circle;
    width: $--radio-input-width;
    height: $--radio-input-height;
    background-color: $--radio-input-background-color;
    position: relative;
    cursor: pointer;
    display: inline-block;
    box-sizing: border-box;
    top: 1px;
    // margin-top: 5px;
    &::after {
      width: 4px;
      height: 4px;
      // border-radius: $--radio-input-border-radius;
      border-radius: $--border-radius-circle;
      background-color: $--color-white;
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%) scale(0);
      transition: transform 0.15s ease-in;
    }
    // &:hover {
    //   border: 2px solid #C9CDD4;
    // }
  }

  @include e(original) {
    opacity: 0;
    outline: none;
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
  }

  &:focus:not(.is-focus):not(:active):not(.is-disabled) {
    /*获得焦点时 样式提醒*/
    .el-radio__inner {
      box-shadow: 0 0 2px 2px $--radio-input-border-color-hover;
    }
  }

  @include e(label) {
    font-size: $--size-base;
    padding-left: 4px;
    font-weight: $--font-weight-400;
    position: relative;
    top: 2px;
    line-height: 22px;
  }
  @include e(extra) {
    margin-top: 4px;
    margin-left: 22px;
    font-size: $--font-size-body-1;
    color: $--color-text-3;
    line-height: 18px;
    // padding-top: 4px;
    &.is-disabled {
      color: $--color-secondary-active;
      cursor: not-allowed;
    }
  }
}

@include b(radio-card) {
  width: 252px;
  margin-bottom: 10px;
  .el-radio {
    width: 100%;
    min-height: 119px;
    white-space: normal;
    padding: 16px;
  }

  &:hover {
    background: $--color-bg-3;
  }

  label.is-disabled {
    background: #ffffff;
    border: $--border-1 solid #ffffff;
    color: $--color-text-4;

    // TODO has的兼容性太差，需要换成其他的方式
    &:has(.is-checked) {
      background: $--primary-1;
      border: $--border-1 solid $--primary-3;
    }
  }

  label.is-checked {
    background: $--primary-1;
    border: $--border-1 solid $--primary-6;
  }
  @include e(extra) {
    margin-left: 32px;
    font-size: $--font-size-body-1;
    color: $--color-text-3;
    border: $--border-1 solid $--danger-6;

    &.is-disabled {
      color: $--color-secondary-active;
      cursor: not-allowed;
    }
  }
}
.el-radio-card_horizontal {
  display: inline-block;
  margin-left: $--radio-card-margin;
}
