@import "../../../style/theme/default/index";
@import "../../../style/mixins/index";

@radio-prefix-cls: ~"@{idoll-prefix}-radio";
@radio-inner-prefix-cls: ~"@{radio-prefix-cls}-inner";
@radio-group-prefix-cls: ~"@{radio-prefix-cls}-group";
@radio-solid-prefix-cls: ~"@{radio-group-prefix-cls}-solid";
@radio-duration: 0.3s;

.@{radio-group-prefix-cls} {
  .reset-component;
  display: inline-block;
  line-height: unset;
  &-vertical {
    .@{radio-prefix-cls}-wrapper {
      display: block
    }
  }
}

.@{radio-prefix-cls}-wrapper {
  .reset-component;
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;
}


.@{radio-prefix-cls} {
  .reset-component;
  white-space: nowrap;
  outline: none;
  display: inline-block;
  position: relative;
  line-height: 1;
  vertical-align: text-bottom;
  cursor: pointer;
  .@{radio-prefix-cls}-wrapper:hover &,
  &:hover,
  &-focused {
    .@{radio-inner-prefix-cls} {
      border-color: @primary-color;
    }
  }
  &-checked:after {
    position:absolute;
    top: 0;
    left: 0;
    width:100%;
    height: 100%;
    border-radius:50%;
    content: '';
    animation-fill-mode: both;
    visibility: hidden;
  }
  &:hover:after,
  .@{radio-prefix-cls}-wrapper:hover &:after {
    visibility: visible;
  }

  &-inner {
    &:after {
      position: absolute;
      width: @radio-radius-sm - 2px;
      height: @radio-radius-sm - 2px;
      left: (@radio-radius-base - @radio-radius-sm)/2 - 1px;
      top: (@radio-radius-base - @radio-radius-sm)/2 - 1px;
      border-radius:50%;
      display: table;
      content: '';
      background-color:@primary-color;
      opacity: 0;
      transform: scale(0);
      transition: all @radio-duration @ease-in-out-circ;
    }

    position: relative;
    top: 0;
    left: 0;
    display: block;
    width: @radio-radius-base - 2px;
    height: @radio-radius-base - 2px;
    border: @border-width-base solid @border;
    border-radius: @radio-radius-base/2;
    background-color: @radio-button-bg;
    transition:all @radio-duration;

  }

  &-input {
    position: absolute;
    left: 0;
    z-index: 1;
    cursor: pointer;
    opacity: 0;
    top: 0;
    bottom: 0;
    right: 0;
  }
}
#@{radio-prefix-cls}-readOnly,#@{radio-prefix-cls}-button-readOnly {
  color: @text-color;
}
// 选中状态
.@{radio-prefix-cls}-checked {
  .@{radio-inner-prefix-cls} {
    border-color: @primary-color;
    &:after {
      transform: scale(1);
      opacity: 1;
      transition:all @radio-duration @ease-in-out-circ;
    }
  }
}

.@{radio-prefix-cls}-disabled {
  cursor:not-allowed;
  .@{radio-inner-prefix-cls} {
    border-color: @border !important;
    cursor:not-allowed;
    background-color: @input-disabled-bg;
    &:after {
      cursor:not-allowed;
      border-color: @border;
      background-color: @input-disabled-bg;
    }
  }

  &:hover {
    background-color:none;
  }

  .@{radio-prefix-cls}-input {
    cursor: not-allowed;
  }

  & + span {
    cursor: not-allowed;
    color: @text-color-disable;
    cursor: not-allowed;
  }
}

span.@{radio-prefix-cls} + * {
  padding-left: @padding-xs;
  padding-right: @padding-xs;
}

.@{radio-prefix-cls}-button-wrapper {
  margin: 0;
  height: @btn-height-base + 4px;
  line-height: @btn-height-base + 2px;
  color: @text-color;
  display: inline-block;
  transition:all 0.3s ease;
  cursor: pointer;
  border: @border-width-base @border-style-base @border;
  border-left: 0;
  background: @radio-button-bg;
  padding: 0 @padding-md - 2px;
  position: relative;

  a {
    color: @text-color;
  }

  .@{radio-prefix-cls}-button {
    margin-left: 0;
    display: block;
    width: 0;
    height: 0;
  }

  .@{radio-group-prefix-cls}-large & {
    height: @input-height-lg;
    line-height: @input-height-lg - 2px;
  }

  .@{radio-group-prefix-cls}-small & {
    font-size: @radio-size-sm;
    height: @input-height-sm;
    line-height: @input-height-sm - 2px;
    padding: 0  @padding-xs - 1px;
  }

  &:not(:first-child) {
    &::before {
      content: '';
      display: block;
      top: 0;
      left: -1px;
      height: 100%;
      position: absolute;
      background-color: @border;
    }
  }

  &:first-child {
    border-radius: @border-radius-base 0 0 @border-radius-base;
    border-left: @border-width-base @border-style-base @border;
  }

  &:last-child {
    border-radius: 0 @border-radius-base @border-radius-base 0;
  }

    &:first-child:last-child {
      border-radius: @border-radius-base;
    }

  &:hover,
  &-focused {
    color: @primary-color;
    position: relative;
  }

  .@{radio-prefix-cls}-inner,
  input[type='checkbox'],
  input[type='radio'] {
    opacity: 0;
    width: 0;
    height: 0;
  }

  &-checked {
    background: @radio-button-bg;
    border-color: @primary-color;
    color: @primary-color;
    box-shadow: -1px 0 0 0 @primary-color;
    z-index: 1;
    &::before {
      background-color: @primary-color !important;
      opacity: 0.1;
    }
    &:first-child {
      border-color: @primary-color;
      box-shadow: none !important;
    }
    &:hover {
      border-color:@primary-hover;
      box-shadow: -1px 0 0 0 @primary-hover;
      color: @primary-hover;
    }
    &:active {
      border-color: @primary-color;
      box-shadow: -1px 0 0 0 @primary-color;
      color: @primary-hover;
    }
  }

  &:disabled {
    border-color: @border;
    background-color: @input-disabled-bg;
    cursor: not-allowed;
    color: @text-color-disable;

    &-first-child,
    &:hover {
      cursor: not-allowed;
      border-color: @border;
      background-color: @input-disabled-bg;
      color: @text-color-disable;
    }

    &:first-child {
      border-left-color: @border;
    }
  }

  &-disabled,&-disabled:hover {
    cursor: not-allowed;
    color:@shadow-color;
    background-color: @radio-disabled-bg;
    .@{radio-inner-prefix-cls} {
      border-color: @primary-color;
    }
  }

  &-disabled&-checked {
    color: @radio-checked-disabled;
    background-color: @radio-disabled-checked-bg;
    border-color: @border;
    box-shadow: none;
    cursor: not-allowed;
  }
}

.@{radio-prefix-cls}-button-wrapper-disabled:hover{
  border-color: @border;
}

.@{radio-solid-prefix-cls} {
  .@{radio-prefix-cls}-button-wrapper {
    margin: 0;
    height: @btn-height-base + 4px;
    line-height: @btn-height-base + 2px;
    color: @text-color;
    display: inline-block;
    transition:all 0.3s ease;
    cursor: pointer;
    border: @border-width-base @border-style-base @border;
    border-left: 0;
    background: @radio-bg ;
    padding: 0 @padding-md - 2px;
    position: relative;
  
    .@{radio-prefix-cls}-button {
      margin-left: 0;
      display: block;
      width: 0;
      height: 0;
    }
  
    &:not(:first-child) {
      &::before {
        content: '';
        display: block;
        top: 0;
        left: -1px;
        height: 100%;
        position: absolute;
        background-color: @primary-color;
      }
    }
  
    &:first-child {
      border-radius: @border-radius-base 0 0 @border-radius-base;
      border-left: @border-width-base @border-style-base @border;
    }
  
    &:last-child {
      border-radius: 0 @border-radius-base @border-radius-base 0;
    }
  
    &:first-child:last-child {
      border-radius: @border-radius-base;
    }
  
    &:hover,
    &-focused {
      color: @primary-color;
      border:-1px @border-style-base @border;
      position: relative;
    }
  
    .@{radio-prefix-cls}-inner,
    input[type='checkbox'],
    input[type='radio'] {
      opacity: 0;
      width: 0;
      height: 0;
    }
  
    &-checked {
      background: @primary-color;
      border-color: @primary-color;
      color: @radio-bg ;
      box-shadow: -1px 0 0 0 @primary-color;
      z-index: 1;
      &::before {
        background-color: @primary-color !important;
        opacity: 0.1;
      }
      &:first-child {
        border-color: @primary-color;
        box-shadow: none !important;
      }
      &:hover {
        border-color:@primary-hover;
        box-shadow: -1px 0 0 0 @primary-hover;
        background-color: @primary-hover;
        color: @radio-bg ;
      }
      &:active {
        border-color: @primary-color;
        box-shadow: -1px 0 0 0 @primary-color;
        color: @primary-color;
      }
    }
  
    &:disabled {
      border-color: @border;
      background-color: @input-disabled-bg;
      cursor: not-allowed;
      color: @text-color-disable;
  
      &-first-child,
      &:hover {
        cursor: not-allowed;
        border-color: @border;
        background-color: @input-disabled-bg;
        color: @text-color-disable;
      }
  
      &:first-child {
        border-left-color: @border;
      }
    }
  
    &-disabled,&-disabled:hover {
      cursor: not-allowed;
      color:@shadow-color;
      background-color: @radio-disabled-bg;
      .@{radio-inner-prefix-cls} {
        border-color: @primary-color;
      }
    }
    &-disabled&-checked {
      color: @radio-checked-disabled;
      background-color: @radio-disabled-checked-bg;
      border-color: @border;
      box-shadow: none;
      cursor: not-allowed;
    }
  }
}
.@{radio-solid-prefix-cls}-large {
  .@{radio-prefix-cls}-button-wrapper {
    margin: 0;
    height: @input-height-lg;
    line-height: @input-height-lg - 2px;
    color: @text-color;
    display: inline-block;
    transition:all 0.3s ease;
    cursor: pointer;
    border: @border-width-base @border-style-base @border;
    border-left: 0;
    background: @radio-bg ;
    padding: 0 @padding-md - 2px;
    position: relative;
  
    .@{radio-prefix-cls}-button {
      margin-left: 0;
      display: block;
      width: 0;
      height: 0;
    }
  
    &:not(:first-child) {
      &::before {
        content: '';
        display: block;
        top: 0;
        left: -1px;
        height: 100%;
        position: absolute;
        background-color: @primary-color;
      }
    }
  
    &:first-child {
      border-radius: @border-radius-base 0 0 @border-radius-base;
      border-left: @border-width-base @border-style-base @border;
    }
  
    &:last-child {
      border-radius: 0 @border-radius-base @border-radius-base 0;
    }
  
    &:first-child:last-child {
      border-radius: @border-radius-base;
    }
  
    &:hover,
    &-focused {
      color: @primary-color;
      border:-1px @border-style-base @border;
      position: relative;
    }
  
    .@{radio-prefix-cls}-inner,
    input[type='checkbox'],
    input[type='radio'] {
      opacity: 0;
      width: 0;
      height: 0;
    }
  
    &-checked {
      background: @primary-color;
      border-color: @primary-color;
      color: @radio-bg ;
      box-shadow: -1px 0 0 0 @primary-color;
      z-index: 1;
      &::before {
        background-color: @primary-color !important;
        opacity: 0.1;
      }
      &:first-child {
        border-color: @primary-color;
        box-shadow: none !important;
      }
      &:hover{
        border-color:@primary-hover;
        box-shadow: -1px 0 0 0 @primary-hover;
        background-color: @primary-hover;
        color: @radio-bg ;
      }
      &:active {
        border-color: @primary-color;
        box-shadow: -1px 0 0 0 @primary-color;
        color:@radio-bg ;
      }
    }
  
    &:disabled {
      border-color: @border;
      background-color: @input-disabled-bg;
      cursor: not-allowed;
      color: @text-color-disable;
  
      &-first-child,
      &:hover {
        cursor: not-allowed;
        border-color: @border;
        background-color: @input-disabled-bg;
        color: @text-color-disable;
      }
  
      &:first-child {
        border-left-color: @border;
      }
    }
  
    &-disabled,&-disabled:hover {
      cursor: not-allowed;
      color:@shadow-color;
      background-color: @radio-disabled-bg ;
      .@{radio-inner-prefix-cls} {
        border-color: @primary-color;
      }
    }
  }
}
.@{radio-solid-prefix-cls}-small {
  .@{radio-prefix-cls}-button-wrapper {
    margin: 0;
    font-size: @radio-size-sm;
    height: @input-height-sm;
    line-height: @input-height-sm - 2px;
    padding: 0  @padding-xs - 1px;
    color: @text-color;
    display: inline-block;
    transition:all 0.3s ease;
    cursor: pointer;
    border: @border-width-base @border-style-base @border;
    border-left: 0;
    background: @radio-bg ;
    position: relative;
  
    .@{radio-prefix-cls}-button {
      margin-left: 0;
      display: block;
      width: 0;
      height: 0;
    }
  
    &:not(:first-child) {
      &::before {
        content: '';
        display: block;
        top: 0;
        left: -1px;
        height: 100%;
        position: absolute;
        background-color: @primary-color;
      }
    }
  
    &:first-child {
      border-radius: @border-radius-base 0 0 @border-radius-base;
      border-left: @border-width-base @border-style-base @border;
    }
  
    &:last-child {
      border-radius: 0 @border-radius-base @border-radius-base 0;
    }
  
    &:first-child:last-child {
      border-radius: @border-radius-base;
    }
  
    &:hover,
    &-focused {
      color: @primary-color;
      border:-1px solid @border;
      position: relative;
    }
  
    .@{radio-prefix-cls}-inner,
    input[type='checkbox'],
    input[type='radio'] {
      opacity: 0;
      width: 0;
      height: 0;
    }
  
    &-checked {
      background: @primary-color;
      border-color: @primary-color;
      color: @radio-bg ;
      box-shadow: -1px 0 0 0 @primary-color;
      z-index: 1;
      &::before {
        background-color: @primary-color !important;
        opacity: 0.1;
      }
      &:first-child {
        border-color: @primary-color;
        box-shadow: none !important;
      }
      &:hover {
        border-color:@primary-hover;
        box-shadow: -1px 0 0 0 @primary-hover;
        background-color: @primary-hover;
        color: @radio-bg ;
      }
      &:active {
        border-color: @primary-color;
        box-shadow: -1px 0 0 0 @primary-color;
        color: @radio-bg ;
      }
    }
  
    &:disabled {
      border-color: @border;
      background-color: @input-disabled-bg;
      cursor: not-allowed;
      color: @text-color-disable;
  
      &-first-child,
      &:hover {
        cursor: not-allowed;
        border-color: @border;
        background-color: @input-disabled-bg;
        color: @text-color-disable;
      }
  
      &:first-child {
        border-left-color: @border;
      }
    }
  
    &-disabled,&-disabled:hover {
      cursor: not-allowed;
      color:@shadow-color;
      background-color: @radio-disabled-bg ;
      .@{radio-inner-prefix-cls} {
        border-color: @primary-color;
      }
    }
    &-disabled&-checked {
      color: @radio-checked-disabled;
      background-color: @radio-disabled-checked-bg;
      border-color: @border;
      box-shadow: none;
      cursor: not-allowed;
    }
  }
}

.@{radio-solid-prefix-cls} {
  .@{radio-prefix-cls}-button-wrapper-disabled-checked,.@{radio-prefix-cls}-button-wrapper-disabled-checked:hover {
    color: @radio-checked-disabled;
    background-color: @radio-disabled-checked-bg;
    border-color: @border;
    box-shadow: none;
    cursor: not-allowed;
  }
}

.@{radio-prefix-cls}.@{radio-prefix-cls}-checked.@{radio-prefix-cls}-disabled {
  .@{radio-inner-prefix-cls} {
    &:after {
      background-color: @border
    }
  }
}