@import "../common/variables.less";

@radio-prefix-cls: ~"@{css-prefix}-radio";
@radio-group-prefix-cls: ~"@{radio-prefix-cls}-group";
@radio-inner-prefix-cls: ~"@{radio-prefix-cls}__inner";
@radio-group-button-prefix-cls: ~"@{radio-group-prefix-cls}-button";

.@{radio-group-prefix-cls} {
  display: inline-block;
  font-size: 0;
  line-height: 1;
  vertical-align: middle;
  &--vertical {
    .@{radio-prefix-cls} {
      display: block;
      height: 30px;
      line-height: 30px;
    }
  }
}

// 普通状态
.@{radio-prefix-cls} {
  font-size: @font-size-small;
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;

  & + & {
    margin-left: 16px;
  }

  &--disabled {
    cursor: @cursor-disabled;
  }
}

.@{radio-prefix-cls} {
  &__input {
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-block;
    line-height: 1;
    position: relative;
    vertical-align: middle;
  }

  &__inner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #c3c3c3;
    border-radius: 100%;
    background-color: #fff;
    position: relative;
    cursor: pointer;
    white-space: nowrap;
    outline: none;

    &:hover {
      .@{radio-inner-prefix-cls} {
        border-color: #bcbcbc;
      }
    }

    &:after {
      position: absolute;
      width: 6px;
      height: 6px;
      left: 50%;
      top: 50%;
      border-radius: @border-radius-base;
      display: table;
      border-top: 0;
      border-left: 0;
      content: " ";
      background-color: #fff;
      opacity: 0;
      transition: all @transition-time @ease-in-out;
      transform: scale(0);
    }
  }

  &__original-input {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    opacity: 0;
    cursor: pointer;
  }
}

.@{radio-prefix-cls}__label {
  font-size: 14px;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

// 选中状态
.@{radio-prefix-cls}--checked,
.@{radio-prefix-cls}.is-checked {
  .@{radio-inner-prefix-cls} {
    border-color: @primary-color;
    background-color: @primary-color;
    &:after {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
      transition: all @transition-time @ease-in-out;
    }
  }
  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @primary-color;
    }
  }
}

.@{radio-prefix-cls}--disabled,
.@{radio-prefix-cls}.is-disabled {
  cursor: @cursor-disabled;

  .@{radio-prefix-cls}__input {
    cursor: @cursor-disabled;
  }

  .@{radio-prefix-cls}__original-input {
    cursor: @cursor-disabled;
  }

  &:hover {
    .@{radio-inner-prefix-cls} {
      border-color: @border-color-base;
    }
  }

  .@{radio-inner-prefix-cls} {
    border-color: @border-color-base;
    background-color: #f3f3f3;
    cursor: @cursor-disabled;

    &:after {
      background-color: #cccccc;
    }
  }

  .@{radio-prefix-cls}--disabled + span {
    color: #ccc;
  }
}



// 按钮样式
.@{radio-group-button-prefix-cls} {
  font-size: 0;
  -webkit-text-size-adjust: none;

  .@{radio-prefix-cls} {
    display: inline-block;
    height: @btn-circle-size;
    line-height: @btn-circle-size - 2px;
    margin: 0;
    padding: 0 16px;

    color: @btn-default-color;
    transition: all @transition-time ease-in-out;
    cursor: pointer;
    border: 1px solid @border-color-base;
    border-left: 0;
    background: #fff;
    position: relative;
    font-size: 0;

    > span {
      margin-left: 0;
    }

    &:before {
      content: "";
      position: absolute;
      width: 1px;
      height: 100%;
      left: -1px;
      background: @border-color-base;
      visibility: hidden;
      transition: all @transition-time ease-in-out;
    }

    &:first-child {
      border-radius: @btn-border-radius 0 0 @btn-border-radius;
      border-left: 1px solid @border-color-base;
      &:before {
        display: none;
      }
    }

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

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

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

    .@{radio-prefix-cls}__inner,
    input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    &--checked,
    &.is-checked {
      background: #fff;
      border-color: @primary-color;
      color: @primary-color;
      box-shadow: -1px 0 0 0 @primary-color;

      &:first-child {
        border-color: @primary-color;
        box-shadow: none !important;
      }

      &:hover {
        border-color: tint(@primary-color, 20%);
        box-shadow: -1px 0 0 0 tint(@primary-color, 20%);
        color: tint(@primary-color, 20%);
      }

      &:active {
        border-color: shade(@primary-color, 5%);
        box-shadow: -1px 0 0 0 shade(@primary-color, 5%);
        color: shade(@primary-color, 5%);
      }
    }

    &--disabled,
    &.is-disabled {
      border-color: @border-color-base;
      background-color: @background-color-base;
      cursor: @cursor-disabled;
      color: #ccc;

      &:first-child,
      &:hover {
        border-color: @border-color-base;
        background-color: @background-color-base;
        color: #ccc;
      }
      &:first-child {
        border-left-color: @border-color-base;
      }
    }

    &--disabled.@{radio-prefix-cls}--checked {
      color: #fff;
      background-color: #e6e6e6;
      border-color: @border-color-base;
      box-shadow: none !important;
    }
  }

  .@{radio-inner-prefix-cls} {
    border: none;
    &:after {
      display: none;
    }
  }
}

.@{radio-group-button-prefix-cls}.@{radio-group-prefix-cls}--large
  .@{radio-prefix-cls} {
  height: @btn-circle-size-large;
  line-height: @btn-circle-size-large - 2px;
  font-size: @font-size-base;
}

.@{radio-group-button-prefix-cls}.@{radio-group-prefix-cls}--small
  .@{radio-prefix-cls} {
  height: @btn-circle-size-small;
  line-height: @btn-circle-size-small - 2px;
  padding: 0 12px;
  font-size: @font-size-small;
  &:first-child {
    border-radius: @btn-border-radius-small 0 0 @btn-border-radius-small;
  }
  &:last-child {
    border-radius: 0 @btn-border-radius-small @btn-border-radius-small 0;
  }
}
