@checkbox-prefix-cls: ~'@{css-prefix}checkbox';
@checkbox-group-prefix-cls: ~'@{checkbox-prefix-cls}-group';
@checkbox-inner-prefix-cls: ~'@{checkbox-prefix-cls}-inner';
@checkbox-group-button-prefix-cls: ~'@{checkbox-group-prefix-cls}-button';

.@{checkbox-prefix-cls}-focus {
  // box-shadow: 0 0 0 2px fade(@color-brand-primary, 20%);
  z-index: 1;
}

.@{checkbox-group-prefix-cls} {
  display: inline-block;
  font-size: @font-size-middle;
  vertical-align: middle;

  //outline: none;
  &-vertical {
    .@{checkbox-prefix-cls}-wrapper {
      display: block;
      height: 30px;
      line-height: 30px;
    }
  }
}

// 普通状态 - Normal state
.@{checkbox-prefix-cls}-wrapper {
  font-size: @font-size-middle;
  vertical-align: middle;
  display: inline-block;
  position: relative;
  white-space: nowrap;
  margin-right: 8px;
  cursor: pointer;

  &-disabled {
    cursor: @cursor-disabled;
    color: @checkbox-disabled-text-color;
  }

  &:not(&-disabled):hover {
    .@{checkbox-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }

    .@{checkbox-prefix-cls}-disabled {
      .@{checkbox-inner-prefix-cls} {
        border-color: @color-border-disable;
      }
    }
  }
}

.@{checkbox-prefix-cls} {
  display: inline-block;
  margin-right: 8px;
  white-space: nowrap;
  position: relative;
  vertical-align: middle;
  cursor: pointer;

  &:hover {
    .@{checkbox-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }
  }

  &-inner {
    display: inline-block;
    width: 16px;
    height: 16px;
    position: relative;
    top: 0;
    left: 0;
    // background-color: @color-complementary-7;
    border: 1px solid @color-border-normal1;
    border-radius: 2px;
    transition: all @transition-time @ease-in-out;

    &:after {
      content: '';
      display: table;
      width: 5px;
      height: 9px;
      position: absolute;
      top: 1px;
      left: 4.5px;
      border-top: 0;
      border-left: 0;
      transform: rotate(45deg) scale(0);
      transition: all 0.2s ease-in-out;
    }
  }

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


// 选中状态 - Selected state
.@{checkbox-prefix-cls}-checked {
  .@{checkbox-inner-prefix-cls} {
    border-color: @color-brand-primary;
    background-color: @color-brand-primary;

    &:after {
      content: '';
      display: table;
      position: absolute;
      border: 1.5px solid @color-functional-white;
      border-top: 0;
      border-left: 0;
      transform: rotate(45deg) scale(1);
      transition: all 0.2s ease-in-out;
    }
  }

  &:hover {
    .@{checkbox-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }
  }
}
    // 半选状态
.@{checkbox-prefix-cls}-indeterminate {
  .@{checkbox-inner-prefix-cls}:after {
    content: '';
    width: 9px;
    height: 1px;
    background-color: @color-functional-white;
    transform: scale(1);
    position: static;
    margin: 7px auto;
  }

  &:hover {
    .@{checkbox-inner-prefix-cls} {
      border-color: @color-brand-primary;
    }
  }

  .@{checkbox-inner-prefix-cls} {
    background-color: @color-brand-primary;
    border-color: @color-brand-primary;
  }
}

.@{checkbox-prefix-cls}-disabled {
  cursor: @cursor-disabled;


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

  &:hover {
    .@{checkbox-inner-prefix-cls} {
      border-color: @color-border-normal1;
    }
  }

  .@{checkbox-inner-prefix-cls} {
    border-color: @checkbox-default-disabled-border-color;
    background-color: @checkbox-default-disabled-bg-color;
  }

  .@{checkbox-prefix-cls}-disabled + span {
    color: @color-complementary-6;
  }

  &.@{checkbox-prefix-cls}-checked .@{checkbox-inner-prefix-cls} {
    background-color: @color-border-normal1;
  }
}

.@{checkbox-prefix-cls}-checked.@{checkbox-prefix-cls}-disabled {
  .@{checkbox-inner-prefix-cls} {
    background-color: @checkbox-checked-disabled-bg-color;
    border-color: @checkbox-checked-disabled-bg-color;
  }
}

.@{checkbox-prefix-cls}-disabled.@{checkbox-prefix-cls}-indeterminate {
  .@{checkbox-inner-prefix-cls}:after {
    background-color: @color-functional-white;
  }
  .@{checkbox-inner-prefix-cls} {
    background-color: @checkbox-checked-disabled-bg-color;
    border-color: @checkbox-checked-disabled-bg-color;
  }
}
span.@{checkbox-prefix-cls} + * {
  // margin-left: 2px;
  // margin-right: 2px;
}

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

  .@{checkbox-prefix-cls} {
    width: 0;
    margin-right: 0;
  }

  .@{checkbox-prefix-cls}-wrapper {
    display: inline-block;
    height: @height-base;
    line-height: @height-base - 2px;
    margin: 0;
    margin-right: 12px;
    padding: 0 20px;
    font-size: @font-size-middle;
    transition: all @transition-time ease-in-out;
    cursor: pointer;
    border: 1px solid @color-border-normal1;
    background: @color-bg-select-tag;
    position: relative;
    border-radius: @border-radius-base;

    >span {
      margin-left: 0;
    }

    &:before,
    &:after {
      content: '';
      display: block;
      position: absolute;
    }

    &:first-child {
      // border-radius: @btn-border-radius 0 0 @btn-border-radius;
      // border-left: 1px solid @color-border-normal1;
    }

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

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

    // &:not(&-disabled):hover {
    &:not(.@{checkbox-prefix-cls}-wrapper-disabled):hover {  
      position: relative;
      color: @color-brand-hover;
      border-color: @color-brand-primary;

      & .@{checkbox-prefix-cls} {
        background-color: black;
      }
    }

    .@{checkbox-prefix-cls}-inner,
    input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    &-checked {
      background-color: @color-bg-normal;
      border-color: @color-brand-primary;
      color: @color-brand-primary;
      box-shadow: @checkbox-button-checked-shadow;
      z-index: 1;

      &:before {
        content: '';
        top: 0;
        left: 0;
        margin-right: 0px;
        border-width: 0 0 20px 20px;
        border-style: solid;
        border-color: transparent @color-brand-primary;
        border-radius: 3px 0 0 0;
      }
      &:after {
        content: '';
        display: table;
        position: absolute;
        border: 1px solid @color-functional-white;
        top: 1px;
        left: 3px;
        width: 5px;
        height: 9px;
        border-top: 0;
        border-left: 0;
        transform: rotate(45deg) scale(0.9);
        transition: all 0.1s ease-in-out;
      }

      &:first-child {
        // border-color: @color-brand-primary;
        // box-shadow: none;
      }

      &:hover {
        border-color: tint(@color-brand-primary, 20%);
      }

      &:active {
        border-color: shade(@color-brand-primary, 5%);
        color: shade(@color-brand-primary, 5%);
      }
    }

    &-disabled {
      border-color: @checkbox-default-disabled-border-color;
      background-color: @checkbox-default-disabled-bg-color;
      cursor: @cursor-disabled;
      color: @color-complementary-6;

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

    &-disabled.@{checkbox-prefix-cls}-wrapper-checked {
      color: @checkbox-checked-disabled-bg-color;
      background-color: @checkbox-checked-bg-color;
      border-color: @checkbox-checked-disabled-bg-color;
      box-shadow: none !important;
      &:before {
        border-color: transparent @checkbox-checked-disabled-bg-color;
      }
    }
  }
}

.@{checkbox-prefix-cls}-middle {
  .@{checkbox-prefix-cls}-wrapper{
    height: @height-middle;
    line-height: @height-middle - 2px;
    font-size: @font-size-middle;
  }
}

.@{checkbox-prefix-cls}-small{
  .@{checkbox-prefix-cls}-wrapper{
      height: @height-small;
      line-height: @height-small - 2px;
      font-size: @font-size-middle;

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

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

