/**
 * @license chowa v1.1.3
 *
 * Copyright (c) Chowa Techonlogies Co.,Ltd.(http://www.chowa.cn).
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
@import "../../styles/variables.scss";
@import "../../styles/mixin.scss";

.#{$prefix}checkbox-wrapper {
    color: $text-color-gray;
    display: inline-block;
    margin: 0;
    padding: 0;
    cursor: pointer;
    height: $io-height-base;
    line-height: $io-height-base;
    font-size: $font-size-base;
    outline: none;
    white-space: nowrap;

    + .#{$prefix}checkbox-wrapper {
        margin-left: $base-padding * 1.8;
    }

    &:not(.#{$prefix}checkbox-disabled):hover .#{$prefix}checkbox-inner {
        @include io-hover();
    }

    &:not(.#{$prefix}checkbox-disabled):focus .#{$prefix}checkbox-inner {
        @include io-focus();
    }

    &.#{$prefix}has-error .#{$prefix}checkbox-inner {
        @include has-error();
    }
}

.#{$prefix}checkbox {
    display: inline-block;
    position: relative;
    margin: 0;
    padding: 0;
    vertical-align: top;
    width: 16px;
    height: 16px;
    margin-top: ($io-height-base - 16px) / 2;
}

.#{$prefix}checkbox-inner {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    display: block;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid $border-color;
    border-radius: $border-radius-base;
    transition: all $anim-duration ease-in;
    background-color: $background-color-light;

    &:before {
        content: '';
        margin: 1px auto;
        padding: 0;
        border: 2px solid transparent;
        transform: rotate(-45deg) scale(0);
        transition: all $anim-duration ease-in-out;
        transform-origin: center;
        width: 8px;
        height: 4px;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        display: block;
    }

    &:after {
        content: '';
        margin: auto;
        padding: 0;
        transition: all $anim-duration ease-in-out;
        height: 2px;
        width: 12px;
        background-color: transparent;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        display: block;
    }
}

.#{$prefix}checkbox-input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.#{$prefix}checkbox-label {
    padding: 0;
    margin: 0 0 0 6px;
}

.#{$prefix}checkbox-checked .#{$prefix}checkbox-inner {
    background-color: lighten($primary-color, 5%);
    border-color: $primary-color;

    &:before {
        display: block;
        border-left-color: $dark-text-color-base;
        border-bottom-color: $dark-text-color-base;
        transform: rotate(-45deg) scale(1);
    }
}

.#{$prefix}checkbox-indeterminate .#{$prefix}checkbox-inner {
    background-color: lighten($primary-color, 5%);
    border-color: $primary-color;

    &:after {
        background-color: $background-color-light;
    }
}

.#{$prefix}checkbox-disabled {
    cursor: not-allowed;

    .#{$prefix}checkbox-inner {
        background-color: $disabled-color;
        border-color: $border-color;
    }

    .#{$prefix}checkbox-label {
        color: $text-color-light;
    }

    .#{$prefix}checkbox-inner:before {
        border-left-color: $text-color-light;
        border-bottom-color: $text-color-light;
    }
}
