//
// Static resources
//
$navbar-transition-in: 0s;
$navbar-transition-out: .5s;

//
// Navbar styles
//
.navbar, .navbar-form {
    border: none;

    .glyph-chevron-down-2 {
        font-size: 6px;
        margin: 0 0 0 spacing(xxxs, -3);
    }

    .glyph-hamburger {
        font-size: 20px;
    }

    .navbar-toggle {
        padding: spacing(xxxs, -4) spacing(xxs, -2);
        float: left;
    }

    .btn {
        margin: spacing(xxxs, -1) 0;
        vertical-align: top;
    }

    .navbar-text {
        line-height: 1.5;
    }
}

// Navbar collapse (body)
.navbar-collapse {
    border-top: 0;

    @media (max-width: $grid-float-breakpoint) {
        .navbar-nav {
            > li > a {
                padding: spacing(xxs, 1) spacing(xxs, -2);
                line-height: 1.5;

                .icon-flipviewdown {
                    float: right;
                    margin: spacing(xxxs) spacing(xxs, 3) 0 0;
                }
            }
        }
    }
}


// Brand/project name
.navbar-brand {
    padding: spacing(xxs, .5) spacing(xxs, 3) spacing(xxs, .5) spacing(xxxs, 2);
    margin-right: spacing(xxs, 3);
    height: $navbar-height;
    
    @media (min-width: $grid-float-breakpoint) {
        padding-left: spacing(n);
    }
}



// Navbar nav links
.navbar-nav {
    margin: 0 (-$navbar-padding-horizontal);

    > li {
        max-width: initial;
    }


    .open .dropdown-menu {
        top: 100%;
        padding: 0;

        > li > a {
            padding: spacing(xxs, 1) spacing(xxxs, 2);
            height: auto;
            line-height: 1.5;
            @include transition(background-color ease-out $navbar-transition-out);
            &:hover {
                @include transition(background-color $navbar-transition-in);
            }
        }

        .divider {
            margin: 0;
        }
    }

    // Uncollapse the nav
    @media (min-width: $grid-float-breakpoint) {
        margin: 0;

        > li > a {
            padding: spacing(xxs, .5) spacing(xs);
            @include transition(background-color ease-out $navbar-transition-out);
            &:hover {
                @include transition(background-color $navbar-transition-in);
            }
        }

        .open .dropdown-menu {
            padding: 0;

            > li > a {
                padding: spacing(xxs, 5) spacing(xs);
                height: auto;
                line-height: 1.5;
            }
        }

        > li > .dropdown-menu {
            width: 240px;
            padding-top: 0;
            padding-bottom: spacing(xxxs);
        }
    }
}


// Navbar form
.navbar-form {
    margin-top: 0;
    margin-bottom: 0;
    padding: spacing(xs, -4) $navbar-padding-horizontal;
    border-bottom: 0;

    input.form-control {
        margin-bottom: 0;
        margin-top: 0;
        border-right: none;
    }

    .btn.btn-default {
        margin: 0;
        border: 1px solid;
        border-left: none;
        margin-left: -4px;
        min-width: initial;
        padding: spacing(n);

        &::before {
            @include glyph(magnifier);
            padding: spacing(xxxs, 1) spacing(xxxs, 1) spacing(xxxs, 2);
            font-size: 15px;
            line-height: 1;
            display: block;
        }

    }

    @media (min-width: $grid-float-breakpoint) {
        @include navbar-vertical-align($input-height-base);
        padding-top: 0;
        padding-bottom: 0;
    }
}

.navbar-local {
    box-shadow: 0px 1px 0px $color-dim-mid;

    .navbar-nav {
        .open .dropdown-menu {
            > li > a {
                padding: spacing(xxs, 3) spacing(xs);
                height: auto;
                line-height: 1.5;
            }
            > .active > a {
                &,
                &:hover,
                &:focus {
                    color: $navbar-default-link-active-color;
                }
            }
        }
        // Uncollapse the nav
        @media (min-width: $grid-float-breakpoint) {
            margin: 0;

            > li > a {
                padding: spacing(xs, .5) spacing(xs);
            }

            &.compressed {
                > li > a {
                    padding: spacing(xs, .5) spacing(xxs, 6);
                }
            }
        }

        @media (min-width: $screen-xl-min) {
            &.compressed {
                > li > a {
                    padding: spacing(xs, .5) spacing(xs);
                }
            }
        }
    }

    .navbar-brand {
        padding: spacing(xxxs, 2.5) spacing(xxs, 1) spacing(xxxs, 2.5) spacing(xxxs, 2);
    }

    .navbar-toggle {
        @extend .navbar-brand;
        margin: 0;
        line-height: 0;
    }

    @media (min-width: $grid-float-breakpoint) {
        .navbar-brand {
            padding: spacing(xs, -2) spacing(xxs, 3) spacing(xs) spacing(n);
            height: 72px;
        }

        .navbar-toggle {
            margin-top: spacing(xs, -4.5);
            margin-bottom: spacing(xs, -4.5);
        }
    }
}

//
// Colors
//

// A note on colors:
// Themes will be connected to the .navbar-global & .navbar-local classes since these require operating independently of each other.
// When using a standard Bootstrap navbar implementation, add .navbar-global between .navbar and .container and then apply
// whichever theme you intend to use. Themes will work as they do everywhere else, if you do nothing, you'll get the default
// black text on white bg or you can use the appropriate theme for your situation.
// In the default global/local implementation, .navbar-global will have .theme-default and .navbar-local will have .theme-dark.
// It will also have .color-blue to give it the standard blue background
.navbar-global,
.navbar-local {

    &,
    &.theme-default,
    &.theme-light {
        border-color: $color-dim-mid;

        .divider {
            background: $color-dim-mid;
        }
        
        .navbar-toggle {
            background-color: transparent;
        }

        .glyph-hamburger {
            color: $color-vivid-low;
        }

        .navbar-collapse,
        .navbar-form {
            border-color: $color-dim-mid;

            .btn.btn-default {
                background: $color-vivid-mid-alt;
                border-color: $color-vivid-low;
                &:hover {
                    background: $color-vivid-mid-alt;
                }
            }
        }

        .navbar-brand {
            color: $color-type-primary;
        }

        .navbar-nav {
            > li {
                border-top: 1px solid $color-dim-mid;
                
                @media (min-width: $grid-float-breakpoint) {
                    border-top: none;
                }
            }
            
            .active > a {
                background-color: $color-bg-light-vivid-mid;
            }
            .open .dropdown-menu {
                background-color: $color-bg-light-vivid-mid;
                > li > a {
                    &:hover,
                    &:focus {
                        color: $color-type-primary;
                        background-color: $color-dim-low;
                    }
                }
            }
        }
    }


    // This is designed to work with $color-accent. Will work with any color, just override $color-accent
    // Please note, our default $color-accent is designed to pass contrast ratio rules for accessibility
    // It is not recommended to use ligher colors for $color-accent as a result
    &.theme-dark {
        .glyph-hamburger {
            color: $color-type-primary-alt;
        }

        .navbar-collapse,
        .navbar-form {
            border-color: $color-dim-mid-alt;
        }

        .navbar-brand {
            color: $color-type-primary-alt;
        }

        .navbar-nav {
            .active > a {
                background-color: $color-neutral-low;
                &:hover {
                    color: $color-type-primary-alt;
                }
            }

            > li > a {
                color: $color-type-primary-alt;
                &:hover {
                    background-color: $color-dim-mid;
                }
            }

            .open > a {
                &,
                &:hover,
                &:active {
                    background-color: $color-neutral-low;
                    color: $color-type-primary-alt;
                }
            }

            .open .dropdown-menu {
                background-color: $color-accent;
                > li {
                    background-color:  $color-neutral-low;
                    &.divider {
                        background: $color-neutral-mid;
                    }
                }
                > li > a {
                    &,
                    &:hover,
                    &:focus {
                        color: $color-type-primary-alt;
                    }
                    &:hover {
                        background-color: $color-dim-mid;
                    }
                }
            }
        }
    }

    &.theme-alt {
        .glyph-hamburger {
            color: $color-type-primary-alt;
        }

        .navbar-collapse,
        .navbar-form {
            border-color: $color-dim-mid-alt;
        }

        .navbar-brand {
            color: $color-type-primary-alt;
        }

        .navbar-nav {
            > li > a {
                color: $color-type-primary-alt;
                &:hover {
                    background-color: $color-bg-dark-neutral-high;
                }
            }

            .open > a {
                &,
                &:hover,
                &:active {
                    background-color: $color-bg-dark-neutral-mid;
                    color: $color-type-primary-alt;
                }
            }

            .open .dropdown-menu {
                background-color: $color-bg-dark-neutral-mid;
                > li {
                    &.divider {
                        background: $color-neutral-mid-alt;
                    }
                }
                > li > a {
                    color: $color-type-primary-alt;
                    &:hover,
                    &:focus {
                        color: $color-type-primary-alt;
                        background: transparentize($color-white, .95);
                    }
                }
            }
        }
    }
}

// Bootsrap Overrides
.navbar-right > div:first-child {
    display: inline-flex
}