@import "../../../style/mixins/index";
@import "../../../style/theme/default/index";

.idollCheckboxFn(@checkbox-prefix-cls: ~"@{idoll-prefix}-checkbox") {
    @checkbox-inner-prefix-cls: ~"@{checkbox-prefix-cls}-inner";

    .@{checkbox-prefix-cls}-wrapper {
        .reset-component;
        line-height: unset;
        cursor: pointer;
        display: inline-block;
        & + & {
            margin-left: 8px;
        }
    }

    .@{checkbox-prefix-cls}-wrapper + span,
        .@{checkbox-prefix-cls} + span {
        padding-left: 8px;
        padding-right: 8px;
    }

    .@{checkbox-prefix-cls}-group {
        .reset-component;
        display: inline-block;
        &-item {
            display: inline-block;
            margin-right: @checkbox-marigin-right;
            &:last-child {
            margin-right: 0;
            }
        }
        &-item + &-item {
            margin-left: 0;
        }
    }

    #@{checkbox-prefix-cls}-text {
        color: @text-color;
    }
    .@{checkbox-prefix-cls} {
        .reset-component;
        white-space: nowrap;
        cursor: pointer;
        outline: none;
        display: inline-block;
        line-height: 1;
        position: relative;
        vertical-align: middle;
        top: -1px;

        .@{checkbox-prefix-cls}-wrapper:hover &-inner,
        &:hover &-inner,
        &-input:focus + &-inner {
            border-color: @primary-color;
        }

        &-checked:after {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 2px;
            content: '';
            visibility: hidden;
        }

        &:hover:after,
        .@{checkbox-prefix-cls}-wrapper:hover &:after {
            visibility: visible;
        }

        &-inner {
            position: relative;;
            top: 0;
            left: 0;
            display: block;
            width: @checkbox-size;
            height: @checkbox-size;
            border: @border-width-base @border-style-base @border;
            border-radius: 2px;
            background-color: @white;
            transition: all @animation-duration-slow;

            &:after {
                @check-width: (@checkbox-size / 14) * 5px;
                @check-height: (@checkbox-size / 14) * 8px;
                transform: rotate(45deg) scale(0);
                position: absolute;
                left: (@checkbox-size - @check-width) / 2 - 0.5px * (@checkbox-size / 14);
                top: (@checkbox-size - @check-height) / 2 - 2px *(@checkbox-size / 14);
                display: table;
                width: @check-width;
                height: @check-height;
                border: (@border-width-base + 1px) @border-style-base @checkbox-color;
                border-top: 0;
                border-left: 0;
                content: '';
                transition: all @animation-duration-fast @ease-in-back;
            }
        }

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

    .@{checkbox-prefix-cls}-indeterminate .@{checkbox-prefix-cls}-inner:after {
    @indeterminate-width: (@checkbox-size / 14) * 8px;
    @indeterminate-height: (@checkbox-size / 14) * 1px;
    content: ' ';
    transform: scale(1);
    position: absolute;
    left: (@checkbox-size - 2 - @indeterminate-width) / 2;
    top: (@checkbox-size - 3 - @indeterminate-height) / 2;
    width: @indeterminate-width;
    height: @indeterminate-height;
    }

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

    .@{checkbox-prefix-cls}-checked .@{checkbox-prefix-cls}-inner:after {
    transform: rotate(45deg) scale(1);
    position: absolute;
    display: table;
    border: (@border-width-base + 1px) @border-style-base @checkbox-color;
    border-top: 0;
    border-left: 0;
    content: ' ';
    transition: all @animation-duration-base @ease-out-back @animation-duration-fast;
    }

    .@{checkbox-prefix-cls}-checked,
    .@{checkbox-prefix-cls}-indeterminate {
    .@{checkbox-prefix-cls}-inner {
        background-color: @primary-color;
        border-color: @primary-color;
    }
    }

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

        &.@{checkbox-prefix-cls}-checked {
            .@{checkbox-prefix-cls}-inner:after {
            animation-name: none;
            border-color: @text-color-disable;
            }
        }

        .@{checkbox-prefix-cls}-input {
            cursor: not-allowed;
        }
        //
        .@{checkbox-prefix-cls}-inner {
            border-color: @border !important;
            background-color: @input-disabled-bg;
            &:after {
            animation-name: none;
            border-color: @input-disabled-bg;
            }
        }
        //
        & + span {
            color: @text-color-disable;
            cursor: not-allowed;
        }
    }
}