//
// Navbars
// --------------------------------------------------


// Wrapper and base class
//
// Provide a static navbar from which we expand to create full-width, fixed, and
// other navbar variations.

.ai1ec-navbar {
  position: relative;
  min-height: @navbar-height; // Ensure a navbar always shows (e.ai1ec-g., without a .ai1ec-navbar-brand in collapsed mode)
  margin-bottom: @navbar-margin-bottom;
  border: 1px solid transparent;

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

  @media (min-width: @grid-float-breakpoint) {
    border-radius: @navbar-border-radius;
  }
}


// Navbar heading
//
// Groups `.ai1ec-navbar-brand` and `.ai1ec-navbar-toggle` into a single component for easy
// styling of responsive aspects.

.ai1ec-navbar-header {
  .ai1ec-clearfix();

  @media (min-width: @grid-float-breakpoint) {
    float: left;
  }
}


// Navbar collapse (body)
//
// Group your navbar content into this for easy collapsing and expanding across
// various device sizes. By default, this content is collapsed when <768px, but
// will expand past that for a horizontal display.
//
// To start (on mobile devices) the navbar links, forms, and buttons are stacked
// vertically and include a `max-height` to overflow in case you have too much
// content for the user's viewport.

.ai1ec-navbar-collapse {
  max-height: 340px;
  overflow-x: visible;
  padding-right: @navbar-padding-horizontal;
  padding-left:  @navbar-padding-horizontal;
  border-top: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  .ai1ec-clearfix();
  -webkit-overflow-scrolling: touch;

  &.ai1ec-in {
    overflow-y: auto;
  }

  @media (min-width: @grid-float-breakpoint) {
    width: auto;
    border-top: 0;
    box-shadow: none;

    &.ai1ec-collapse {
      display: block !important;
      height: auto !important;
      padding-bottom: 0; // Override default setting
      overflow: visible !important;
    }

    &.ai1ec-in {
      overflow-y: visible;
    }

    // Undo the collapse side padding for navbars with containers to ensure
    // alignment of right-aligned contents.
    .ai1ec-navbar-fixed-top &,
    .ai1ec-navbar-static-top &,
    .ai1ec-navbar-fixed-bottom & {
      padding-left: 0;
      padding-right: 0;
    }
  }
}


// Both navbar header and collapse
//
// When a container is present, change the behavior of the header and collapse.

.ai1ec-container > .ai1ec-navbar-header,
.ai1ec-container > .ai1ec-navbar-collapse {
  margin-right: -@navbar-padding-horizontal;
  margin-left:  -@navbar-padding-horizontal;

  @media (min-width: @grid-float-breakpoint) {
    margin-right: 0;
    margin-left:  0;
  }
}


//
// Navbar alignment options
//
// Display the navbar across the entirety of the page or fixed it to the top or
// bottom of the page.

// Static top (unfixed, but 100% wide) navbar
.ai1ec-navbar-static-top {
  z-index: @zindex-navbar;
  border-width: 0 0 1px;

  @media (min-width: @grid-float-breakpoint) {
    border-radius: 0;
  }
}

// Fix the top/bottom navbars when screen real estate supports it
.ai1ec-navbar-fixed-top,
.ai1ec-navbar-fixed-bottom {
  position: fixed;
  right: 0;
  left: 0;
  z-index: @zindex-navbar-fixed;

  // Undo the rounded corners
  @media (min-width: @grid-float-breakpoint) {
    border-radius: 0;
  }
}
.ai1ec-navbar-fixed-top {
  top: 0;
  border-width: 0 0 1px;
}
.ai1ec-navbar-fixed-bottom {
  bottom: 0;
  margin-bottom: 0; // override .ai1ec-navbar defaults
  border-width: 1px 0 0;
}


// Brand/project name

.ai1ec-navbar-brand {
  float: left;
  padding: @navbar-padding-vertical @navbar-padding-horizontal;
  font-size: @font-size-large;
  line-height: @line-height-computed;

  &:hover,
  &:focus {
    text-decoration: none;
  }

  @media (min-width: @grid-float-breakpoint) {
    .ai1ec-navbar > .ai1ec-container & {
      margin-left: -@navbar-padding-horizontal;
    }
  }
}


// Navbar toggle
//
// Custom button for toggling the `.ai1ec-navbar-collapse`, powered by the collapse
// JavaScript plugin.

.ai1ec-navbar-toggle {
  position: relative;
  float: right;
  margin-right: @navbar-padding-horizontal;
  padding: 9px 10px;
  .ai1ec-navbar-vertical-align(34px);
  background-color: transparent;
  background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.ai1ec-com/necolas/normalize.ai1ec-css/issues/214
  border: 1px solid transparent;
  border-radius: @border-radius-base;

  // Bars
  .ai1ec-icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 1px;
  }
  .ai1ec-icon-bar + .ai1ec-icon-bar {
    margin-top: 4px;
  }

  @media (min-width: @grid-float-breakpoint) {
    display: none;
  }
}


// Navbar nav links
//
// Builds on top of the `.ai1ec-nav` components with it's own modifier class to make
// the nav the full height of the horizontal nav (above 768px).

.ai1ec-navbar-nav {
  margin: (@navbar-padding-vertical / 2) -@navbar-padding-horizontal;

  > li > a {
    padding-top:    10px;
    padding-bottom: 10px;
    line-height: @line-height-computed;
  }

  @media (max-width: @grid-float-breakpoint-max) {
    // Dropdowns get custom display when collapsed
    .ai1ec-open .ai1ec-dropdown-menu {
      position: static;
      float: none;
      width: auto;
      margin-top: 0;
      background-color: transparent;
      border: 0;
      box-shadow: none;
      > li > a,
      .ai1ec-dropdown-header {
        padding: 5px 15px 5px 25px;
      }
      > li > a {
        line-height: @line-height-computed;
        &:hover,
        &:focus {
          background-image: none;
        }
      }
    }
  }

  // Uncollapse the nav
  @media (min-width: @grid-float-breakpoint) {
    float: left;
    margin: 0;

    > li {
      float: left;
      > a {
        padding-top:    @navbar-padding-vertical;
        padding-bottom: @navbar-padding-vertical;
      }
    }

    &.ai1ec-navbar-right:last-child {
      margin-right: -@navbar-padding-horizontal;
    }
  }
}


// Component alignment
//
// Repurpose the pull utilities as their own navbar utilities to avoid specificity
// issues with parents and chaining. Only do this when the navbar is uncollapsed
// though so that navbar contents properly stack and align in mobile.

@media (min-width: @grid-float-breakpoint) {
  .ai1ec-navbar-left  { .ai1ec-pull-left(); }
  .ai1ec-navbar-right { .ai1ec-pull-right(); }
}


// Navbar form
//
// Extension of the `.ai1ec-form-inline` with some extra flavor for optimum display in
// our navbars.

.ai1ec-navbar-form {
  margin-left: -@navbar-padding-horizontal;
  margin-right: -@navbar-padding-horizontal;
  padding: 10px @navbar-padding-horizontal;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  @shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1);
  .ai1ec-box-shadow(@shadow);

  // Mixin behavior for optimum display
  .ai1ec-form-inline();

  .ai1ec-form-group {
    @media (max-width: @grid-float-breakpoint-max) {
      margin-bottom: 5px;
    }
  }

  // Vertically center in expanded, horizontal navbar
  .ai1ec-navbar-vertical-align(@input-height-base);

  // Undo 100% width for pull classes
  @media (min-width: @grid-float-breakpoint) {
    width: auto;
    border: 0;
    margin-left: 0;
    margin-right: 0;
    padding-top: 0;
    padding-bottom: 0;
    .ai1ec-box-shadow(none);

    // Outdent the form if last child to line up with content down the page
    &.ai1ec-navbar-right:last-child {
      margin-right: -@navbar-padding-horizontal;
    }
  }
}


// Dropdown menus

// Menu position and menu carets
.ai1ec-navbar-nav > li > .ai1ec-dropdown-menu {
  margin-top: 0;
  .ai1ec-border-top-radius(0);
}
// Menu position and menu caret support for dropups via extra dropup class
.ai1ec-navbar-fixed-bottom .ai1ec-navbar-nav > li > .ai1ec-dropdown-menu {
  .ai1ec-border-bottom-radius(0);
}

// Right aligned menus need alt position
.ai1ec-navbar-nav.ai1ec-pull-right > li > .ai1ec-dropdown-menu,
.ai1ec-navbar-nav > li > .ai1ec-dropdown-menu.ai1ec-pull-right {
  left: auto;
  right: 0;
}


// Buttons in navbars
//
// Vertically center a button within a navbar (when *not* in a form).

.ai1ec-navbar-btn {
  .ai1ec-navbar-vertical-align(@input-height-base);

  &.ai1ec-btn-sm {
    .ai1ec-navbar-vertical-align(@input-height-small);
  }
  &.ai1ec-btn-xs {
    .ai1ec-navbar-vertical-align(22);
  }
}


// Text in navbars
//
// Add a class to make any element properly align itself vertically within the navbars.

.ai1ec-navbar-text {
  .ai1ec-navbar-vertical-align(@line-height-computed);

  @media (min-width: @grid-float-breakpoint) {
    float: left;
    margin-left: @navbar-padding-horizontal;
    margin-right: @navbar-padding-horizontal;

    // Outdent the form if last child to line up with content down the page
    &.ai1ec-navbar-right:last-child {
      margin-right: 0;
    }
  }
}

// Alternate navbars
// --------------------------------------------------

// Default navbar
.ai1ec-navbar-default {
  background-color: @navbar-default-bg;
  border-color: @navbar-default-border;

  .ai1ec-navbar-brand {
    color: @navbar-default-brand-color;
    &:hover,
    &:focus {
      color: @navbar-default-brand-hover-color;
      background-color: @navbar-default-brand-hover-bg;
    }
  }

  .ai1ec-navbar-text {
    color: @navbar-default-color;
  }

  .ai1ec-navbar-nav {
    > li > a {
      color: @navbar-default-link-color;

      &:hover,
      &:focus {
        color: @navbar-default-link-hover-color;
        background-color: @navbar-default-link-hover-bg;
      }
    }
    > .ai1ec-active > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-default-link-active-color;
        background-color: @navbar-default-link-active-bg;
      }
    }
    > .ai1ec-disabled > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-default-link-disabled-color;
        background-color: @navbar-default-link-disabled-bg;
      }
    }
  }

  .ai1ec-navbar-toggle {
    border-color: @navbar-default-toggle-border-color;
    &:hover,
    &:focus {
      background-color: @navbar-default-toggle-hover-bg;
    }
    .ai1ec-icon-bar {
      background-color: @navbar-default-toggle-icon-bar-bg;
    }
  }

  .ai1ec-navbar-collapse,
  .ai1ec-navbar-form {
    border-color: @navbar-default-border;
  }

  // Dropdown menu items
  .ai1ec-navbar-nav {
    // Remove background color from open dropdown
    > .ai1ec-open > a {
      &,
      &:hover,
      &:focus {
        background-color: @navbar-default-link-active-bg;
        color: @navbar-default-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {
      // Dropdowns get custom display when collapsed
      .ai1ec-open .ai1ec-dropdown-menu {
        > li > a {
          color: @navbar-default-link-color;
          &:hover,
          &:focus {
            color: @navbar-default-link-hover-color;
            background-color: @navbar-default-link-hover-bg;
          }
        }
        > .ai1ec-active > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-default-link-active-color;
            background-color: @navbar-default-link-active-bg;
          }
        }
        > .ai1ec-disabled > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-default-link-disabled-color;
            background-color: @navbar-default-link-disabled-bg;
          }
        }
      }
    }
  }


  // Links in navbars
  //
  // Add a class to ensure links outside the navbar nav are colored correctly.

  .ai1ec-navbar-link {
    color: @navbar-default-link-color;
    &:hover {
      color: @navbar-default-link-hover-color;
    }
  }

}

// Inverse navbar

.ai1ec-navbar-inverse {
  background-color: @navbar-inverse-bg;
  border-color: @navbar-inverse-border;

  .ai1ec-navbar-brand {
    color: @navbar-inverse-brand-color;
    &:hover,
    &:focus {
      color: @navbar-inverse-brand-hover-color;
      background-color: @navbar-inverse-brand-hover-bg;
    }
  }

  .ai1ec-navbar-text {
    color: @navbar-inverse-color;
  }

  .ai1ec-navbar-nav {
    > li > a {
      color: @navbar-inverse-link-color;

      &:hover,
      &:focus {
        color: @navbar-inverse-link-hover-color;
        background-color: @navbar-inverse-link-hover-bg;
      }
    }
    > .ai1ec-active > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-inverse-link-active-color;
        background-color: @navbar-inverse-link-active-bg;
      }
    }
    > .ai1ec-disabled > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-inverse-link-disabled-color;
        background-color: @navbar-inverse-link-disabled-bg;
      }
    }
  }

  // Darken the responsive nav toggle
  .ai1ec-navbar-toggle {
    border-color: @navbar-inverse-toggle-border-color;
    &:hover,
    &:focus {
      background-color: @navbar-inverse-toggle-hover-bg;
    }
    .ai1ec-icon-bar {
      background-color: @navbar-inverse-toggle-icon-bar-bg;
    }
  }

  .ai1ec-navbar-collapse,
  .ai1ec-navbar-form {
    border-color: darken(@navbar-inverse-bg, 7%);
  }

  // Dropdowns
  .ai1ec-navbar-nav {
    > .ai1ec-open > a {
      &,
      &:hover,
      &:focus {
        background-color: @navbar-inverse-link-active-bg;
        color: @navbar-inverse-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {
      // Dropdowns get custom display
      .ai1ec-open .ai1ec-dropdown-menu {
        > .ai1ec-dropdown-header {
          border-color: @navbar-inverse-border;
        }
        .ai1ec-divider {
          background-color: @navbar-inverse-border;
        }
        > li > a {
          color: @navbar-inverse-link-color;
          &:hover,
          &:focus {
            color: @navbar-inverse-link-hover-color;
            background-color: @navbar-inverse-link-hover-bg;
          }
        }
        > .ai1ec-active > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-inverse-link-active-color;
            background-color: @navbar-inverse-link-active-bg;
          }
        }
        > .ai1ec-disabled > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-inverse-link-disabled-color;
            background-color: @navbar-inverse-link-disabled-bg;
          }
        }
      }
    }
  }

  .ai1ec-navbar-link {
    color: @navbar-inverse-link-color;
    &:hover {
      color: @navbar-inverse-link-hover-color;
    }
  }

}
