@import 'common/var';
@import "mixins/mixins";
@import "mixins/_button";
@import "mixins/utils";

@include b(checkbox){
  $size-base:16px;

  font-size: $--font-size-base;
  color: $--color-text-content;
  position: relative;
  user-select: none;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  margin-right: 30px;

  &:hover{
    @include e(inner) {
      @include theme-border-color;
    }
  }

  @include e(input){
    display: inline-block;
    vertical-align: middle;
    width: $size-base;
    height: $size-base;
    margin-top:-2px;
    @include e(inner){
      display: block;
      position: relative;
      border:$--checkbox-disabled-border;
      border-radius: 2px;
      box-sizing: border-box;
      width: $size-base;
      height: $size-base;
      background-color: #fff;
      z-index: 1;
      transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),background-color .25s cubic-bezier(.71,-.46,.29,1.46);
      &:hover {
        @include theme-border-color;
      }
      &::after{
        box-sizing: content-box;
        content: "";
        border: 1px solid #fff;
        border-left: 0;
        border-top: 0;
        height: 9px;
        left: 5px;
        position: absolute;
        top: 1px;
        transform: rotate(45deg) scaleY(0);
        width: 3px;
        transition: transform .15s ease-in .05s;
        transform-origin: center;
      }
      &:focus{
        outline: none;
      }
    }
    @include e(original){
      opacity: 0;
      outline: none;
      position: absolute;
      margin: 0;
      width: 0;
      height: 0;
      z-index: -1;
      @include when(checked){
        .xb-checkbox__inner {
          background-color: #409eff;
          border-color: #409eff;
          &::after{
            transform: rotate(45deg) scaleY(1);
          }
        }
      }
    }
    @include when(checked){
      .xb-checkbox__inner {
        @include theme-bg-color;
        @include theme-border-color;
        &::after{
          transform: rotate(45deg) scaleY(1);
        }
      }
    }
    @include when(indeterminate){
      @include e(inner){
        @include theme-bg-color;
        @include theme-border-color;
        &:before{
          content: "";
          position: absolute;
          display: block;
          background-color: $--color-white;
          height: 1px;
          transform: scale(.75);
          left: 0;
          right: 0;
          top: 7px;
        }
      }
    }
  }
  @include when(bordered){
    padding: 12px 13px;
    border-radius: $--border-radius-base;
    border: $--border-base;
    box-sizing: border-box;
    line-height: normal;
    height: 40px;
    .xb-checkbox__input{
      margin-top: -4px;
    }
    .xb-checkbox__label{
      line-height: 1;
    }
  }
  @include when(disabled){
    cursor:not-allowed;
    .xb-checkbox__inner {
      [data-theme*="-symbol"] & {
        background:rgba(0,0,0,0.04);
        border:$--checkbox-disabled-border;
      }
      &::after{
        cursor: not-allowed;
      }
    }
    .xb-checkbox__label{
      color: $--color-text-disabled;
      cursor: not-allowed;
    }
  }
  &.is-disabled.is-checked{
    .xb-checkbox__inner{
      background-color:$--radio-disabled-bg;
      border:1px solid rgba(0,0,0,0);
    }
  }
  &.is-bordered.is-disabled{
    cursor: not-allowed;
    [data-theme*="-symbol"] & {
      border-color: #ebeef5;
    }
  }
  @include e(label){
    display: inline-block;
    line-height: 1.4em;
    padding-left: 10px;
  }
  &:last-of-type{
    margin-right: 0;
  }
}

@include b(checkbox-group){
  font-size: 0;
}
@include b(checkbox-button) {
  position: relative;
  display: inline-block;
  @include e(inner){
    line-height: 1;
    font-weight: $--font-weight-base;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    background: #fff;
    border: 1px solid #dcdfe6;
    border-left: 0;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin: 0;
    transition: all .3s cubic-bezier(.645,.045,.355,1);
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 0;
    @include utils-user-select(none);
    &:hover {
      color: red;
    }

    & [class*="xb_icon_"] {
      line-height: 0.9;

      & + span {
        margin-left: 5px;
      }
    }
  }
  @include e(original) {
    opacity: 0;
    outline: none;
    position: absolute;
    margin: 0;
    z-index: -1;
  }
  &.is-checked {
    & .xb-checkbox-button__inner {
      color: $--color-white;
      @include theme-bg-color;
      @include theme-border-color;
    }
    &:first-child .xb-checkbox-button__inner {
      border-left-color: red;
    }
  }

  &.is-disabled {
    & .xb-checkbox-button__inner {
      color: $--color-text-disabled;
      cursor: not-allowed;
      background-image: none;
      background-color: #edf2fc;
      border-color: #dcdfe6;
      box-shadow: none;
    }
    &:first-child .xb-checkbox-button__inner {
      border-left-color: red;
    }
  }

  &:first-child {
    .xb-checkbox-button__inner {
      border-left: $--border-base;
      border-radius: $--border-radius-base 0 0 $--border-radius-base;
      box-shadow: none !important;
    }
  }

  &.is-focus {
    & .xb-checkbox-button__inner {
      border-color: $--color-border;
    }
  }

  &:last-child {
    .xb-checkbox-button__inner {
      border-radius: 0 $--border-radius-base $--border-radius-base 0;
    }
  }
}
