@checkboxWidth: 16px;
@checkboxHeight: 16px;

.umb-form-check {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    padding: 0;
    margin: 0;
    min-height: 22px;
    line-height: 22px;
    cursor: pointer !important;

    &__text {
        margin: 0 0 0 26px;
        position: relative;
        top: 0;
        user-select: none;
    }

    &__input {
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0;
        
        &:hover ~ .umb-form-check__state .umb-form-check__check {
            border-color: @inputBorderFocus;
        }
        &:checked ~ .umb-form-check__state .umb-form-check__check {
            border-color: @ui-option-type;
        }
        &:checked:hover ~ .umb-form-check__state .umb-form-check__check {
            &::before {
                background: @ui-option-type-hover;
            }
        }
        
        &:checked ~ .umb-form-check__state {
            .umb-form-check__check {
                // This only happens if the state has a radiobutton modifier
                .umb-form-check--radiobutton & {
                    &:before {
                        opacity: 1;
                        transform: scale(1);
                    }
                }
                // This only happens if state has the checkbox modifier
                .umb-form-check--checkbox & {
                    &:before {
                        width: @checkboxWidth;
                        height: @checkboxHeight;
                    }
                }
            }
            // This only happens if state has the checkbox modifier
            .umb-form-check--checkbox & {
                .umb-form-check__icon {
                    opacity: 1;
                }
            }
        }
    }
    
    
    .tabbing-active &.umb-form-check--radiobutton &__input:focus ~ .umb-form-check__state .umb-form-check__check {
        //outline: 2px solid @inputBorderTabFocus;
        border: 2px solid @inputBorderTabFocus;
        margin: -1px;
    }
    .tabbing-active &.umb-form-check--checkbox &__input:focus ~ .umb-form-check__state .umb-form-check__check {
        outline: 2px solid @inputBorderTabFocus;
    }
    .tabbing-active &.umb-form-check--checkbox &__input:checked:focus ~ .umb-form-check__state .umb-form-check__check {
        border-color: white;
    }

    &__state {
        display: flex;
        height: 18px;
        margin-top: 2px;
        position: absolute;
        top: 0;
        left: 0;
    }

    &__check {
        display: flex;
        position: relative;
        background: @white;
        border: 1px solid @inputBorder;
        width: @checkboxWidth;
        height: @checkboxHeight;

        &:before {
            content: "";
            background: @ui-option-type;
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
        }
        // This only happens if state has the radiobutton modifier
        .umb-form-check--radiobutton & {
            border-radius: 100%;

            &:before {
                width: 10px;
                height: 10px;
                border-radius: 100%;
                opacity: 0;
                transform: scale(0);
                transition: .15s ease-out;
            }
        }
        // This only happens if state has the checkbox modifier
        .umb-form-check--checkbox & {
            &:before {
                width: 0;
                height: 0;
                transition: .05s ease-out;
            }
        }
    }

    &__icon {
        color: @white;
        text-align: center;
        font-size: 12px;
        opacity: 0;
        transition: .2s ease-out;

        &:before {
            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: 0;
            right: 0;
            left: 0;
            bottom: 0;
            margin: auto;
        }
    }

    &.umb-form-check--disabled {
        cursor: not-allowed !important;
        opacity: 0.5;
    }
}
