//
// Navbars (Redux)
// --------------------------------------------------


// COMMON STYLES
// -------------

// Base class and wrapper
.navbar {
  overflow: visible;
//  margin-bottom: @baseLineHeight;

  // Fix for IE7's bad z-indexing so dropdowns don't appear below content that follows the navbar
  *position: relative;
  *z-index: 2;
}

// Inner for background effects
// Gradient is applied to its own element because overflow visible is not honored by IE when filter is present
.navbar-inner {
  min-height: @navbarHeight;
  padding-left:  20px;
  padding-right: 20px;
  .box-shadow(inset 0 1px 0 rgba(255,255,255,0.4));
  background: @navbarBackground;
  border: 2px solid @navbarBorder;

  // Prevent floats from breaking the navbar
  .clearfix();
}

// Set width to auto for default container
// We then reset it for fixed navbars in the #gridSystem mixin
.navbar .container {
  width: auto;
}

// Override the default collapsed state
.nav-collapse.collapse {
  height: auto;
  overflow: visible;
}


// Brand: website or project name
// -------------------------
.navbar .brand {
  float: left;
  display: block;
  // Vertically center the text given @navbarHeight
  padding: ((@navbarHeight - @baseLineHeight) / 2) 20px ((@navbarHeight - @baseLineHeight) / 2);
  font-size: 18px;
  font-weight: 200;
  color: @navbarBrandColor;
  text-shadow: 0 1px 0 @navbarBackgroundHighlight;
  &:hover,
  &:focus {
    text-decoration: none;
  }
}

// Plain text in topbar
// -------------------------
.navbar-text {
  margin-bottom: 0;
  line-height: @navbarHeight;
  color: @navbarText;
}

// Janky solution for now to account for links outside the .nav
// -------------------------
.navbar-link {
  color: @navbarLinkColor;
  &:hover,
  &:focus {
    color: @navbarLinkColorHover;
  }
}

// Dividers in navbar
// -------------------------
.navbar .divider-vertical {
  height: @navbarHeight;
  margin: 0;
  border-left: 1px solid @navbarBorder;
  border-right: 1px solid @navbarBackgroundHighlight;
}

// Buttons in navbar
// -------------------------
.navbar .btn,
.navbar .btn-group {
  .navbarVerticalAlign(30px); // Vertically center in navbar
}
.navbar .btn-group .btn,
.navbar .input-prepend .btn,
.navbar .input-append .btn,
.navbar .input-prepend .btn-group,
.navbar .input-append .btn-group {
  margin-top: 0; // then undo the margin here so we don't accidentally double it
}

// Navbar forms
// -------------------------
.navbar-form {
  margin-bottom: 0; // remove default bottom margin
  .clearfix();
  input,
  select,
  .radio,
  .checkbox {
    .navbarVerticalAlign(30px); // Vertically center in navbar
    margin-right: 5px;
    margin-left: 5px;
  }
  input,
  select,
  .btn {
    display: inline-block;
    margin-bottom: 0;
  }
  input[type="image"],
  input[type="checkbox"],
  input[type="radio"] {
    margin-top: 3px;
  }
  .input-append,
  .input-prepend {
    margin-top: 5px;
    white-space: nowrap; // preven two  items from separating within a .navbar-form that has .pull-left
    input {
      margin-top: 0; // remove the margin on top since it's on the parent
    }
  }
}

// Navbar search
// -------------------------
.navbar-search {
  position: relative;
  float: left;
  .navbarVerticalAlign(38px); // Vertically center in navbar
  margin-bottom: 0;
  .search-query {
    margin-bottom: 0;
    padding: 8px 12px 13px;
    line-height: 20px;
    #font > .sans-serif(13px, normal, 1);
    border: 0;
    &:focus {
      background: #fff;
    }
  }
}



// Static navbar
// -------------------------

.navbar-static-top {
  position: static;
  margin-bottom: 0; // remove 18px margin for default navbar

}



// Fixed navbar
// -------------------------

// Shared (top/bottom) styles
.navbar-fixed-top,
.navbar-fixed-bottom {
  position: fixed;
  right: 0;
  left: 0;
  z-index: @zindexFixedNavbar;
  margin-bottom: 0; // remove 18px margin for default navbar
}
.navbar-fixed-top .navbar-inner,
.navbar-static-top .navbar-inner {
  border-width: 0 0 2px;
}
.navbar-fixed-bottom .navbar-inner {
  border-width: 2px 0 0;
}
.navbar-fixed-top .navbar-inner,
.navbar-fixed-bottom .navbar-inner {
  padding-left:  0;
  padding-right: 0;
}
.navbar-inverse.navbar-fixed-top .navbar-inner {
  border-width: 0;
}

// Reset container width
// Required here as we reset the width earlier on and the grid mixins don't override early enough
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
  #grid > .core > .span(@gridColumns);
}

// Fixed to top
.navbar-fixed-top {
  top: 0;
}
.navbar-fixed-top,
.navbar-static-top {
  .navbar-inner {

  }
}

// Fixed to bottom
.navbar-fixed-bottom {
  bottom: 0;
  .navbar-inner {

  }
}



// NAVIGATION
// ----------

.navbar .nav {
  position: relative;
  left: 0;
  display: block;
  float: left;
  margin: 0 10px 0 0;
}
.navbar .nav.pull-right {
  float: right; // redeclare due to specificity
  margin-right: 0; // remove margin on float right nav
}
.navbar .nav > li {
  float: left;
}

// Links
.navbar .nav > li > a {
  float: none;
  // Vertically center the text given @navbarHeight
  padding: (((@navbarHeight - @baseLineHeight) / 2) - 3) 15px (((@navbarHeight - @baseLineHeight) / 2) - 1);
  color: @navbarLinkColor;
  text-decoration: none;
  text-shadow: 0 1px 0 @navbarBackgroundHighlight;
}
.navbar .nav .dropdown-toggle .caret {
  margin-top: 10px;
}

// Hover/focus
.navbar .nav > li > a:focus,
.navbar .nav > li > a:hover {
  background-color: @navbarLinkBackgroundHover; // "transparent" is default to differentiate :hover/:focus from .active
  color: @navbarLinkColorHover;
  text-decoration: none;
}

// Active nav items
.navbar .nav > .active > a,
.navbar .nav > .active > a:hover,
.navbar .nav > .active > a:focus {
  color: @navbarLinkColorActive;
  text-decoration: none;
  background-color: @navbarLinkBackgroundActive;
  .box-shadow(inset 0 1px 0 rgba(255,255,255,0.4));
}

// Navbar button for toggling navbar items in responsive layouts
// These definitions need to come after '.navbar .btn'
.navbar .btn-navbar {
  display: none;
  float: right;
  padding: 7px 10px;
  margin-left: 5px;
  margin-right: 5px;
  .buttonBackground(darken(@navbarBackgroundHighlight, 5%), darken(@navbarBackground, 5%));
}
.navbar .btn-navbar .icon-bar {
  display: block;
  width: 18px;
  height: 2px;
  background-color: #f5f5f5;
}
.btn-navbar .icon-bar + .icon-bar {
  margin-top: 3px;
}



// Dropdown menus
// --------------

// Menu position and menu carets
.navbar .nav > li > .dropdown-menu {
  border-top: 0;
  border-color: @navbarBorder;
  &:before {
    content: '';
    display: inline-block;
    border-left:   7px solid transparent;
    border-right:  7px solid transparent;
    border-bottom: 7px solid #ccc;
    border-bottom-color: @navbarBorder;
    position: absolute;
    top: -7px;
    left: 9px;
  }
  &:after {
    content: '';
    display: inline-block;
    border-left:   6px solid transparent;
    border-right:  6px solid transparent;
    border-bottom: 6px solid @navbarBorder;
    position: absolute;
    top: -6px;
    left: 10px;
  }
  a:active {
    background-color: lighten(@grayLighter,8%);
    color: @grayDarker;
  }
}
.navbar-fixed-bottom .nav > li > .dropdown-menu,
.navbar-fixed-top .nav > li > .dropdown-menu {
  border-top: 2px solid @navbarBorder;
  margin-top: 0;
}
// Menu position and menu caret support for dropups via extra dropup class
.navbar-fixed-bottom .nav > li > .dropdown-menu {
  &:before {
    border-top: 7px solid #ccc;
    border-top-color: @navbarBorder;
    border-bottom: 0;
    bottom: -7px;
    top: auto;
  }
  &:after {
    border-top: 6px solid @navbarBorder;
    border-bottom: 0;
    bottom: -6px;
    top: auto;
  }
}

// Caret should match text color on hover/focus
.navbar .nav li.dropdown > a:hover .caret,
.navbar .nav li.dropdown > a:focus .caret {
  border-top-color: @navbarLinkColorHover;
  border-bottom-color: @navbarLinkColorHover;
}

// Remove background color from open dropdown
.navbar .nav li.dropdown.open > .dropdown-toggle,
.navbar .nav li.dropdown.active > .dropdown-toggle,
.navbar .nav li.dropdown.open.active > .dropdown-toggle {
  background-color: @navbarLinkBackgroundActive;
  color: @navbarLinkColorActive;
}
.navbar .nav li.dropdown > .dropdown-toggle .caret {
  border-top-color: @navbarLinkColor;
  border-bottom-color: @navbarLinkColor;
}
.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
.navbar .nav li.dropdown.active > .dropdown-toggle .caret,
.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret {
  border-top-color: @navbarLinkColorActive;
  border-bottom-color: @navbarLinkColorActive;
}

// Right aligned menus need alt position
.navbar .pull-right > li > .dropdown-menu,
.navbar .nav > li > .dropdown-menu.pull-right {
  left: auto;
  right: -2px;
  &:before {
    left: auto;
    right: 12px;
  }
  &:after {
    left: auto;
    right: 13px;
  }
  .dropdown-menu {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: -1px;
  }
}


// Inverted navbar
// -------------------------

.navbar-inverse {

  .navbar-inner {
    background: @navbarInverseBackground;
    border-color: @navbarInverseBorder;
    .box-shadow(inset 0 1px 0 rgba(255,255,255,0.1));
  }

  .brand,
  .nav > li > a {
    color: @navbarInverseLinkColor;
    text-shadow: 0 -1px 0 rgba(0,0,0,.25);
    &:hover,
    &:focus {
      color: @navbarInverseLinkColorHover;
    }
  }

  .brand {
    color: @navbarInverseBrandColor;
  }

  .navbar-text {
    color: @navbarInverseText;
  }

  .nav > li > a:focus,
  .nav > li > a:hover {
    background-color: @navbarInverseLinkBackgroundHover;
    color: @navbarInverseLinkColorHover;
    .box-shadow(inset 0 1px 0 rgba(255,255,255,0.1));
  }

  .nav .active > a,
  .nav .active > a:hover,
  .nav .active > a:focus {
    color: @navbarInverseLinkColorActive;
    background-color: @navbarInverseLinkBackgroundActive;
    .box-shadow(inset 0 1px 0 rgba(255,255,255,0.1));
  }

  // Inline text links
  .navbar-link {
    color: @navbarInverseLinkColor;
    &:hover,
    &:focus {
      color: @navbarInverseLinkColorHover;
    }
  }

  // Dividers in navbar
  .divider-vertical {
    border-left-color: @navbarInverseBackground;
    border-right-color: @navbarInverseBackgroundHighlight;
  }

  &.navbar .nav > li > .dropdown-menu {
    border-top: 0;
    margin-top: 2px;
    border-color: @navbarInverseBorder;
    &:before {
      border-bottom-color: @navbarInverseBorder;
    }
    &:after {
      border-bottom: 6px solid @navbarInverseBorder;
    }
    a:active {
      background-color: @gray;
      color: @white;
    }
  }

  // Dropdowns
  .nav li.dropdown.open > .dropdown-toggle,
  .nav li.dropdown.active > .dropdown-toggle,
  .nav li.dropdown.open.active > .dropdown-toggle {
    background-color: @navbarInverseLinkBackgroundActive;
    color: @navbarInverseLinkColorActive;
  }
  .nav li.dropdown > a:hover .caret,
  .nav li.dropdown > a:focus .caret {
    border-top-color: @navbarInverseLinkColorActive;
    border-bottom-color: @navbarInverseLinkColorActive;
  }
  .nav li.dropdown > .dropdown-toggle .caret {
    border-top-color: @navbarInverseLinkColor;
    border-bottom-color: @navbarInverseLinkColor;
  }
  .nav li.dropdown.open > .dropdown-toggle .caret,
  .nav li.dropdown.active > .dropdown-toggle .caret,
  .nav li.dropdown.open.active > .dropdown-toggle .caret {
    border-top-color: @navbarInverseLinkColorActive;
    border-bottom-color: @navbarInverseLinkColorActive;
  }

  // Navbar search
  .navbar-search {
    .search-query {
      color: @white;
      background-color: rgba(255,255,255,0.1);
      line-height: 21px;
      .transition(none);
      .placeholder(@navbarInverseSearchPlaceholderColor);
      .box-shadow(inset 0 1px 0 rgba(0,0,0,0.1));
      // Focus states (we use .focused since IE7-8 and down doesn't support :focus)
      &:focus,
      &.focused {
        color: @white;
      }
    }
  }

  // Navbar collapse button
  .btn-navbar {
    .buttonBackground(darken(@navbarInverseBackgroundHighlight, 5%), darken(@navbarInverseBackground, 5%));
  }

}
