$radio-prefix: #{$css-prefix}radio;
$radio-group-prefix:#{$radio-prefix}-group;
$radio-inner-prefix: #{$radio-prefix}-inner;
$radio-group-button-prefix: #{$radio-prefix}-group-button;

.#{$radio-prefix} {
    display: inline-block;
    font-size: $font-size-small;
    vertical-align: middle;
}
.#{$radio-group-prefix}{
    &-vertical{
        .#{$radio-prefix}-wrapper {
            display: block;
            height: $radio-vertical-height;
            line-height: $radio-vertical-height;
        }
    }

}

// 普通状态
.#{$radio-prefix}-wrapper {
    font-size: $font-size-small;
    vertical-align: middle;
    display: inline-block;
    position: relative;
    white-space: nowrap;
    margin:$radio-item-margin;
    cursor: pointer;
    &-disabled{
        cursor: $cursor-disabled;
        color: $radio-disabled-bg-color;
    }
}

.#{$radio-prefix} {
    display: inline-block;
    margin: $radio-margin;
    white-space: nowrap;
    outline: none;
    position: relative;
    line-height: 1;
    vertical-align: middle;
    cursor: pointer;
    &:hover {
        .#{$radio-inner-prefix} {
            border-color: $radio-border-hover-color;
        }
    }
    &-text {
        display:inline-block;
        vertical-align: middle;
    }
    &-inner {
        display: inline-block;
        width: $radio-height-base;
        height: $radio-height-base;
        position: relative;
        top: 0;
        left: 0;
        background-color: $radio-bg-base;
        border: 1px solid $radio-border-color;
        border-radius: 50%;
        transition: all $transition-time $ease-in-out;

        &:after {
            position: absolute;
            width: $radio-inner-height-base;
            height: $radio-inner-height-base;
            left: $radio-inner-left-base;
            top: $radio-inner-left-base;
            border-radius: $border-radius-base;
            display: block;
            border-top: 0;
            border-left: 0;
            content: ' ';
            background-color: $primary-color;
            opacity: 0;
            transition: all $transition-time $ease-in-out;
            transform: scale(0);
        }
    }
    &-large{
        font-size: $font-size-base;
        & .#{$radio-inner-prefix}{
            width: $radio-height-large;
            height: $radio-height-large;
            &:after{
                width: $radio-inner-height-large;
                height: $radio-inner-height-large;
            }
        }
        &.#{$radio-prefix}-wrapper, & .#{$radio-prefix}-wrapper{
            font-size: $font-size-base;
        }
    }
    &-small{
        & .#{$radio-inner-prefix}{
            width: $radio-height-small;
            height: $radio-height-small;
            &:after{
                width: $radio-inner-height-small;
                height: $radio-inner-height-small;
            }
        }
    }

    &-input {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1;
        opacity: 0;
        cursor: pointer;
    }
}

// 选中状态
.#{$radio-prefix}-checked {
    .#{$radio-inner-prefix} {
        border-color: $primary-color;
        &:after {
            opacity: 1;
            transform: scale(1);
            transition: all $transition-time $ease-in-out;
        }
    }
    &:hover {
        .#{$radio-inner-prefix} {
            border-color: $primary-color;
        }
    }
}

.#{$radio-prefix}-disabled {
    cursor: $cursor-disabled;
    .#{$radio-prefix}-input {
        cursor: $cursor-disabled;
    }

    &:hover {
        .#{$radio-inner-prefix} {
            border-color: $border-color-base;
        }
    }
    .#{$radio-inner-prefix} {
        border-color: $radio-border-color;
        background-color: $radio-bg-disabled;
        &:after {
            background-color: $border-color-base;
        }
    }

    .#{$radio-prefix}-disabled + span {
        color: $border-color-base;
    }
}

span.#{$radio-prefix} + * {
    margin-left: 2px;
    margin-right: 2px;
}

// 按钮样式
.#{$radio-group-button-prefix} {
    font-size: 0;
    -webkit-text-size-adjust:none;

    .#{$radio-prefix}{
        width: 0;
        margin-right: 0;
        &-text{
            vertical-align: top;
        }
    }

    .#{$radio-prefix}-wrapper {
        display: inline-block;
        vertical-align: top;
        height: $btn-circle-size;
        line-height: $btn-circle-size - 2px;
        margin: 0;
        padding: $radio-button-padding;
        font-size: $font-size-base;
        color: $btn-default-color;
        transition: all $transition-time ease-in-out;
        cursor: pointer;
        border: 1px solid $border-color-base;
        border-left: 0;
        background: #fff;

        > span {
            margin-left: 0;
        }

        &:before {
            content: '';
            position: absolute;
            width: 1px;
            height: 100%;
            left: -1px;
            background: $border-color-base;
            visibility: hidden;
            transition: all $transition-time ease-in-out;
        }

        &:first-child {
            border-radius: $btn-border-radius 0 0 $btn-border-radius;
            border-left: 1px solid $border-color-base;
            &:before {
                display: none;
            }
        }

        &:last-child {
            border-radius: 0 $btn-border-radius $btn-border-radius 0;
        }

        &:first-child:last-child {
            border-radius: $btn-border-radius;
        }

        &:hover {
            position: relative;
            color: $primary-color;
        }

        .#{$radio-prefix}-inner,
        input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        &-checked {
            background: #fff;
            border-color: $primary-color;
            color: $primary-color;
            box-shadow: -1px 0 0 0 $primary-color;

            &:first-child {
                border-color: $primary-color;
                box-shadow: none!important;
            }

            &:hover {
                border-color: tint($primary-color, 20%);
                box-shadow: -1px 0 0 0 tint($primary-color, 20%);
                color: tint($primary-color, 20%);
            }

            &:active {
                border-color: shade($primary-color, 5%);
                box-shadow: -1px 0 0 0 shade($primary-color, 5%);
                color: shade($primary-color, 5%);
            }
        }

        &-disabled {
            border-color: $border-color-base;
            background-color: $background-color-base;
            cursor: $cursor-disabled;
            color: $border-color-base;

            &:first-child,
            &:hover {
                border-color: $border-color-base;
                background-color: $background-color-base;
                color: $border-color-base;
            }
            &:first-child {
                border-left-color: $border-color-base;
            }
        }

        &-disabled.#{$radio-prefix}-wrapper-checked {
            color: #fff;
            background-color: $radio-bg-disabled;
            border-color: $border-color-base;
            box-shadow: none!important;
        }
    }
}
.#{$radio-group-button-prefix}{
    &.#{$radio-prefix}-large{
        .#{$radio-prefix}-wrapper{
            height: $btn-circle-size-large;
            line-height: $btn-circle-size-large - 2px;
            font-size: $font-size-base;
        }
    }
    &.#{$radio-prefix}-small{
        .#{$radio-prefix}-wrapper{
            height: $btn-circle-size-small;
            line-height: $btn-circle-size-small - 2px;
            padding: 0 12px;
            font-size: $font-size-small;
            &:first-child {
                border-radius: $btn-border-radius-small 0 0 $btn-border-radius-small;
            }
            &:last-child {
                border-radius: 0 $btn-border-radius-small $btn-border-radius-small 0;
            }
        }
    }
}