@import url(../var.less);
@import url(../mixins/_checkbox.less);

@checkbox-prefix: ~"@{prefix}checkbox";

.@{checkbox-prefix}{
  color: @checkbox-font-color;
  font-weight: @checkbox-font-weight;
  font-size: @checkbox-font-size;
  position: relative;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  user-select: none;
  margin-right: 30px;

  &.is-bordered {
    padding: @checkbox-bordered-padding;
    border-radius: @checkbox-bordered-border-radius;
    border: @checkbox-bordered-border;
    box-sizing: border-box;
    line-height: normal;
    height: @checkbox-bordered-height;

    &.is-checked {
      border-color: @checkbox-checked-border-color;
    }

    &.is-disabled {
      border-color: @checkbox-disabled-border-color;
      cursor: not-allowed;
    }

    & + .w-checkbox.is-bordered {
      margin-left: 10px;
    }

    &.@{checkbox-prefix}--medium {
      .checkbox-size(@chekcbox-bordered-medium-padding, @button-radius, 
      @chekcbox-bordered-medium-height, @chekcbox-bordered-medium-line-height,
      @chekcbox-bordered-medium-font-size, @chekcbox-bordered-medium-input-height,
      @chekcbox-bordered-medium-input-width,0,0);

      .@{checkbox-prefix}__inner::after {
        height: 7px;
        width: 4px;
        top: 1px;
        left: 4px
      }
    }

    &.@{checkbox-prefix}--small {
      .checkbox-size(@chekcbox-bordered-small-padding, @button-radius, 
      @chekcbox-bordered-small-height,@chekcbox-bordered-small-line-height,
      @chekcbox-bordered-small-font-size, @chekcbox-bordered-small-input-height,
      @chekcbox-bordered-small-input-width, @checkbox-bordered-small-after-height,@checkbox-bordered-small-after-width);
      
      .@{checkbox-prefix}__inner::after {
        height: 6px;
        width: 3px;
        top: 1px;
        left: 3px
      }
    }
  }

  &__input {
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-block;
    line-height: 1;
    position: relative;
    vertical-align: middle;

    &.is-disabled {
      .@{checkbox-prefix}__inner {
        background-color: @checkbox-disabeld-input-fill;
        border-color: @checkbox-disabled-border-color;
        cursor: not-allowed;

        &::after {
          cursor: not-allowed;
          border-color: @checkbox-disabled-icon-color;
        }

        & + .@{checkbox-prefix}__label {
          cursor: not-allowed;
        }
      }

      &.is-checked {
        .@{checkbox-prefix}__inner {
          background-color: @checkbox-disabled-checked-input-fill;
          border-color: @checkbox-disabled-checked-input-border-color;

          &::after {
            border-color: @checkbox-disabled-checked-icon-color;
          }
        }
      }

      &.is-indeterminate {
        .@{checkbox-prefix}__inner {
          background-color: @checkbox-disabled-checked-input-fill;
          border-color: @checkbox-disabled-checked-input-border-color;

          &::before {
            background-color: @checkbox-disabled-checked-icon-color;
            border-color: @checkbox-disabled-checked-icon-color;
          }
        }
      }

      & + span.@{checkbox-prefix}__label {
        color: @disabled-font-color;
        cursor: not-allowed;
      }
    }

    &.is-checked {
      .@{checkbox-prefix}__inner {
        background-color: @checkbox-checked-background-color;
        border-color: @checkbox-checked-input-border-color;

        &::after {
          transform: rotate(45deg) scaleY(1);
        }
      }

      & + .@{checkbox-prefix}__label {
        color: @checkbox-checked-font-color;
      }
    }

    &.is-focus {
      .@{checkbox-prefix}__inner {
        border-color: @checkbox-input-border-color-hover;
      }
    }

    &.is-indeterminate {
      .@{checkbox-prefix}__inner {
        background-color: @checkbox-checked-background-color;
        border-color: @checkbox-checked-input-border-color;

        &::before {
          content: '';
          position: absolute;
          display: block;
          background-color: @checkbox-checked-icon-color;
          height: 2px;
          transform: scale(0.5);
          left: 0;
          right: 0;
          top: 5px;
        }

        &::after {
          display: none;
        }
      }
    }
  }

  &__inner {
    display: inline-block;
    position: relative;
    border: @checkbox-input-border;
    border-radius: @checkbox-border-radius;
    box-sizing: border-box;
    width: @checkbox-input-width;
    height: @checkbox-input-height;
    background-color: @checkbox-background-color;
    z-index: @z-index-normal;
    transition: border-color .25s cubic-bezier(.71,-.46,.29,1.46),
    background-color .25s cubic-bezier(.71,-.46,.29,1.46);

    &:hover {
      border-color: @checkbox-input-border-color-hover;
    }

    &::after {
      box-sizing: content-box;
      content: "";
      border: 1px solid @checkbox-checked-icon-color;
      border-left: 0;
      border-top: 0;
      height: 8px;
      left: 5px;
      position: absolute;
      top: 1px;
      transform: rotate(45deg) scaleY(0);
      width: 4px;
      transition: transform .15s ease-in .05s;
      transform-origin: center;
    }
  }

  &__original {
    opacity: 0;
    outline: none;
    position: absolute;
    margin: 0;
    width: 0;
    height: 0;
    z-index: -1;
  }

  &__label {
    display: inline-block;
    padding-left: 10px;
    line-height: 19px;
    font-size: @checkbox-font-size;
  }

  &__position {
    &--right {
      padding-left: 0;
      padding-right: 10px;
    }
  }

  &:last-of-type {
    margin-right: 0;
  }
}