/*!
 * fields/toggle.less
 *
 * Copyright 2016 Achraf Chouk
 * Achraf Chouk (https://github.com/crewstyle)
 */

.olz-field-content.toggle {
    &:after {
        clear: both;
        content: "";
        display: block;
    }

    fieldset {
        background-color: fade(@gray, 10%);
        border: 1px solid lighten(@gray, 20%);
        border-radius: 15px;
        box-shadow: 0 0 0 2px fade(@black, 10%), inset 0 1px 2px fade(@black, 20%);
        color: lighten(@gray, 20%);
        display: inline-block;
        height: 30px;
        margin: 0 10px;
        overflow: hidden;
        position: relative;
        vertical-align: middle;
        width: 70px;
        -webkit-transition: all ease .5s;
        -moz-transition: all ease .5s;
        transition: all ease .5s;

        &:after {
            background-color: @white;
            border: 1px solid lighten(@gray, 20%);
            border-radius: 10px;
            content: "";
            display: block;
            height: 15px;
            left: 10%;
            position: absolute;
            top: 7px;
            width: 30%;
            -webkit-transition: all ease .5s;
            -moz-transition: all ease .5s;
            transition: all ease .5s;
        }

        label {
            display: block;
            line-height: 30px;
            padding: 0;
            position: absolute;
            top: 0;
            width: 200%;
            z-index: 1;
            -webkit-transition: all ease .5s;
            -moz-transition: all ease .5s;
            transition: all ease .5s;

            &.on {
                color: @primary;
                left: 0;

                .fa {
                    margin-left: 16px;
                }
            }

            &.off {
                right: 0;
                text-align: right;

                .fa {
                    margin-right: 17px;
                }
            }

            input {
                left: -999px;
                position: absolute;
            }
        }

        &.is-on {
            background-color: fade(@primary, 30%);
            border-color: @primary;
            box-shadow: 0 0 0 2px fade(@primary, 30%),inset 0 1px 2px fade(@black, 20%);

            &:after {
                border-color: @primary;
                left: 56%;
            }

            label.on {
                z-index: 1;
            }

            label.off {
                right: -100%;
                z-index: 2;
            }
        }

        &.is-off {
            &:after {
                left: 10%;
            }

            label.on {
                left: -100%;
                z-index: 2;
            }

            label.off {
                z-index: 1;
            }
        }
    }
}
