@import '../settings/base';

$checkbox_css_prefix: #{$css_prefix}_c_checkbox;
$checkbox_inner_css_prefix: #{$css_prefix}_c_checkbox__inner;
$checkbox_group_css_prefix: #{$css_prefix}_c_checkbox_group;

.#{$checkbox_group_css_prefix} {
  display: inline-block;
  vertical-align: middle;
  //outline: none;
  &--vertical {
    .#{$checkbox_css_prefix}__wrapper {
      display: block;
    }
  }
}


// 普通状态
.#{$checkbox_css_prefix} {
  display: inline-block;
  vertical-align: middle;
  white-space: nowrap;
  cursor: pointer;
  //outline: none;
  line-height: 1;
  position: relative;

  &--disabled {
    cursor: default;
  }

  &:not(.#{$checkbox_css_prefix}--checked):not(.#{$checkbox_css_prefix}--disabled):hover {
    .#{$checkbox_inner_css_prefix} {
      border-color: #bcbcbc;
    }
  }

  &__inner {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
    top: 0;
    left: 0;
    border: 1px solid #ccc;
    border-radius: 2px;
    background-color: #fff;
    transition: border-color $transition-time $ease-in-out, background-color $transition-time $ease-in-out, box-shadow $transition-time $ease-in-out;

    &::after {
      content: '';
      display: table;
      width: 6px;
      height: 12px;
      position: absolute;
      top: 50%;
      left: 50%;
      border: 2px solid #fff;
      border-top: 0;
      border-left: 0;
      transform: translate(-50%, -60%) rotate(45deg) scale(0);
      transition: all $transition-time $ease-in-out;
    }
  }

  &--default {
    .#{$checkbox_inner_css_prefix} {
      width: 20px;
      height: 20px;

      &::after {
        width: 6px;
        height: 12px;
      }
    }
  }

  &--small {
    .#{$checkbox_inner_css_prefix} {
      width: 16px;
      height: 16px;

      &::after {
        width: 5px;
        height: 10px;
      }
    }
  }

  &__input {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    cursor: pointer;
    opacity: 0;

    &[disabled] {
      cursor: default;
    }
  }
}

// 选中状态
.#{$checkbox_css_prefix}--checked {

  .#{$checkbox_inner_css_prefix} {
    border-color: $color_primary;
    background-color: $color_primary;

    &::after {
      transform: translate(-50%, -60%) rotate(45deg) scale(1);
    }
  }
}

// 禁用
.#{$checkbox_css_prefix}--disabled {
  &.#{$checkbox_css_prefix}--checked {

    .#{$checkbox_inner_css_prefix} {
      background-color: #eee;
      border-color: #ccc;

      &::after {
        animation-name: none;
        border-color: #ccc;
      }
    }
  }

  .#{$checkbox_inner_css_prefix} {
    border-color: #ccc;
    background-color: #eee;

    &::after {
      animation-name: none;
      border-color: #ccc;
    }
  }

  .#{$checkbox_inner_css_prefix}__input {
    cursor: default;
  }

  & + span {
    color: #ccc;
    cursor: default;
  }
}


.#{$checkbox_css_prefix}__wrapper {
  cursor: pointer;
  font-size: $fontsize_base;
  display: inline-block;
  margin-right: 8px;
  //outline: none;

  &--disabled {
    cursor: default;
  }
}

.#{$checkbox_css_prefix}__wrapper + span,
.#{$checkbox_css_prefix} + span {
  //margin-left: 4px;
  margin-right: 4px;
}

