@import (once) "vars";
@import (once) "utils";
@import (once) "scheme-builder";


.app-bar {
    display: block;
    width: 100%;
    position: relative;
    background-color: @appBarBackground;
    color: @white;
    height: 3.125rem;
    .no-user-select;
    .clear-float;

    .app-bar-element {
        line-height: 3.125rem;
        padding: 0 .625rem;
        font-size: 1rem;
        cursor: pointer;
        color: inherit;
        display: block;
        float: left;
        position: relative;
        vertical-align: middle;
        height: 3.125rem;

        &:hover, &:active {
            background-color: @appBarBackgroundActive;
        }

        &.branding {
            padding-left: 1rem;
            padding-right: 1rem;
        }

        .d-menu {
            top: 100%;
            border: 2px solid @appBarBackgroundActive;
            li:not(.disabled):hover {
                background-color: #eee;
                & > a {
                    color: @dark;
                }
            }

            .d-menu {
                top: -.625rem;
                left: 100%;
            }
            .dropdown-toggle {
                &:before {
                    border-color: @dark;
                }
            }
        }

    }

    .app-bar-divider {
        display: block;
        float: left;
        line-height: 3.125rem;
        height: 3.125rem;
        width: 1px;
        background-color: @appBarDividerColor;
        padding: 0;
    }

    .dropdown-toggle {
        &:before {
            border-color: @white;
        }
    }

    .app-bar-menu {
        display: block;
        float: left;
        margin: 0;
        padding: 0;

        & > li, & > li > a {
            .app-bar > .app-bar-element;

            &.dropdown-toggle {
                padding-right: 1.5rem;
                &:before {
                    border-color: @white;
                    display: block;
                }
            }
        }

        & > li {
            padding: 0;
        }

        & > li .d-menu {
            top: 100%;
            border: 2px solid @appBarBackgroundActive;
            li:not(.disabled):hover {
                background-color: #eee;
                & > a {
                    color: @dark;
                }
            }

            .d-menu {
                top: -.625rem;
                left: 100%;
            }
            .dropdown-toggle {
                &:before {
                    border-color: @dark;
                }
            }
        }

        &.small-dropdown {
            .d-menu {
                li > a {
                    font-size: .8em;
                    padding: .325rem 1.2rem .325rem 1.8rem;
                }
            }
        }
    }

    .app-bar-pullbutton {
        float: right;
        &.automatic {
            display: none;
            float: right;
            color: #fff;
            cursor: pointer;
            font: 2rem sans-serif;
            height: 3.125rem;
            width: 3.125rem;
            line-height: 1.25rem;
            vertical-align: middle;
            text-align: center;
            margin: 0;

            &:before {
                content: "\2261";
                position: absolute;
                top: .875rem;
                left: .875rem;
            }
        }
    }
}

.app-bar {
    .app-bar-drop-container {
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 10px;
        border: 2px solid @appBarBackgroundActive;
        background: @white;

        &:before {
            content: '';
            position: absolute;
            background-color: @white;
            width: 10px;
            height: 10px;
            border: 2px @appBarBackgroundActive solid;
            top: 1px;
            left: 1rem;
            margin: -8px 0;
            border-bottom: none;
            border-right: none;
            .rotate(45deg);
        }
        &:before {
            z-index: 0;
        }

        &.place-right {
            right: 0;
            left: auto;

            &:before {
                left: auto;
                right: 1rem;
            }
        }
    }
}

// Form Elements
.app-bar {
    .app-bar-element {
        .clear-float;
        & > .input-control.text, & > .input-control.password {
            margin-top: .55rem;
            font-size: .875rem;
            line-height: 1.8rem;
            display: block;

            input {
                border-color: @transparent;
            }
        }

        & > .button {
            margin-top: -.15rem;
        }

        & > .image-button {
            margin: 0;
            background-color: @transparent;
            color: @white;
            font-size: inherit;
            img.icon {
                padding: 0;
            }
        }
    }
}

.app-bar {
    &.drop-up {
        .app-bar-drop-container {
            top: auto;
            bottom: 3.75rem;

            &:before {
                top: auto;
                bottom: 1px;
                .rotate(225deg);
            }
        }

        .app-bar-menu {
            & > li > .d-menu {
                top: auto;
                bottom: 3.125rem;
            }
        }

        .app-bar-element {
            & > .d-menu {
                top: auto;
                bottom: 3.125rem;
            }
        }

        .app-bar-menu li .d-menu, .app-bar-element .d-menu {
            .d-menu {
                top: auto ;
                bottom: 0;
            }
        }

    }
}

.app-bar {
    .app-bar-element, .app-bar-menu {
        .dropdown-toggle {
            &:before {
                .transition(.3s);
            }

            &.active-toggle {
                &:before {
                    .rotate135;
                    .transition(.3s);
                }
            }
        }

        .d-menu {
            .dropdown-toggle {
                &.active-toggle {
                    &:before {
                        .rotate45;
                    }
                }
            }
        }
    }
}

.app-bar {
    &.fixed-top, &.fixed-bottom {
        z-index: @zindexFixedNavbar;
        position: fixed;
    }

    &.fixed-top {
        top: 0;
    }
    &.fixed-bottom {
        bottom: 0;
    }
}

//flexible
.app-bar {

    overflow: visible;
    height: auto;
    .app-bar-pullbutton {
        .app-bar .app-bar-element;
        float: right;
    }

    .app-bar-pullbutton {
        display: none;
    }   //are invisible by default
    .app-bar-pullmenu {
        display: none;
    }
    .app-bar-pullmenu {
        //special stylings - overwrite for sidebar2 as  pullmenu
        &.flexstyle-sidebar2 {
            position: absolute;
            right: 0;
            z-index: @zindexDropdown;

            .app-bar-pullmenubar {
                float: right;
            }
            .dropdown-toggle {
                &:before {
                    border-color: #323232; //TODO: make this as variable as soon the sidebar colors are styled with variables
                }
            }
            .sidebar2 {
                li {
                    &:hover {
                        background-color: @appBarBackground;
                    }
                    .input-control {
                        text-align: center;
                        display: block;
                        margin: 0.325rem;
                    }
                }

                li {
                    &:hover {
                        a {background-color: @appBarBackground;}
                    }
                }
                li li:not(:hover) {
                    color: @dark ;

                    a {
                        background-color: @white;
                    }
                }
            }
        }

        //default style of the pullmenu
        .app-bar-menu {
            width: 100%;
            border-top: 1px solid @appBarDividerColor;
            position: relative;
            float: none;
            display: none;
            z-index: @zindexDropdown +1; //+1 because we want see it, even if pullmenu is open
            background-color: @appBarBackgroundActive;
            clear: both;
            & > li, & > li > a {
                float: none;
            }

            & > li {
                height: auto;
            }

            li:hover {
                background-color: @appBarBackground;
                a {
                    background-color: @appBarBackground;
                    color: @white;
                }
            }

            .d-menu {
                border: 0;
                border-top: 1px solid @appBarDividerColor;
                clear: both;
                float: none;
                width: 100%;
                position: relative;
                left: 0;
                box-shadow: none;
                max-width: 100%;
                background-color: @appBarBackgroundActive;

                li {
                    width: 100%;
                    background-color: inherit;

                    a {
                        padding-left: 20px;
                        padding-right: 0;
                        background-color: inherit;
                        width: 100%;
                        color: @white;
                    }
                }

                .dropdown-toggle {
                    &:before {
                        border-color: @white;
                        .rotate(-45deg);
                    }
                }

                .divider {
                    background-color: @appBarDividerColor;
                }

                .d-menu {
                    top: 0;
                    left: 0;
                }
            }
        }
    }
}

.app-bar {
    & > .container {
        padding: 0 !important;
    }
}

