.navbar {
  align-items: center;
  color: $toolbar-color;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  min-height: $toolbar-height;
  padding: $toolbar-padding-y $toolbar-padding-x;
  position: relative;

  // Vertically align some elements normally placed in `.navbar`

  .form-control {
    @include border-radius($toolbar-element-border-radius);
    @include transition-standard(opacity);

    background-color: $toolbar-element-bg;
    border: 0;
    color: inherit;
    opacity: $toolbar-element-opacity;
    padding: (($textfield-height - $textfield-font-size * $textfield-line-height) / 2) $toolbar-inner-spacer-x;

    @include focus-hover {
      box-shadow: none;
      opacity: 1;
    }
  }

  .form-control-lg {
    padding-top: (($textfield-height-lg - $textfield-font-size-lg * $textfield-line-height-lg) / 2);
    padding-bottom: (($textfield-height-lg - $textfield-font-size-lg * $textfield-line-height-lg) / 2);
  }

  .form-control-sm {
    padding-top: (($textfield-height-sm - $textfield-font-size-sm * $textfield-line-height-sm) / 2);
    padding-bottom: (($textfield-height-sm - $textfield-font-size-sm * $textfield-line-height-sm) / 2);
  }

  .input-group {
    @include border-radius($toolbar-element-border-radius);
    @include transition-standard(opacity);

    background-color: $toolbar-element-bg;
    opacity: $toolbar-element-opacity;

    @include focus-hover {
      opacity: 1;
    }

    .form-control {
      background-color: transparent;
      opacity: 1;

      &:not(:first-child) {
        padding-left: 0;
      }

      &:not(:last-child) {
        padding-right: 0;
      }
    }

    .input-group-append {
      margin-left: 0;
      min-width: 0;
    }

    .input-group-prepend {
      margin-right: 0;
      min-width: 0;
    }

    .input-group-text {
      margin-right: $toolbar-inner-spacer-x;
      margin-left: $toolbar-inner-spacer-x;
    }
  }

  .input-group-lg > .form-control {
    padding-top: (($textfield-height-lg - $textfield-font-size-lg * $textfield-line-height-lg) / 2);
    padding-bottom: (($textfield-height-lg - $textfield-font-size-lg * $textfield-line-height-lg) / 2);
  }

  .input-group-sm > .form-control {
    padding-top: (($textfield-height-sm - $textfield-font-size-sm * $textfield-line-height-sm) / 2);
    padding-bottom: (($textfield-height-sm - $textfield-font-size-sm * $textfield-line-height-sm) / 2);
  }

  .nav-tabs {
    margin-top: ($toolbar-padding-y * -1);
    margin-bottom: ($toolbar-padding-y * -1);

    .nav-link {
      min-height: $toolbar-height;
      padding-top: (($toolbar-height - $nav-tab-font-size * $nav-tab-line-height) / 2);
      padding-bottom: (($toolbar-height - $nav-tab-font-size * $nav-tab-line-height) / 2);
    }
  }

  > .container {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

.navbar-dark {
  color: $toolbar-dark-color;

  .form-control,
  .input-group,
  .navbar-brand::before,
  .navbar-nav .show > .nav-link,
  .navbar-toggler::before {
    background-color: $toolbar-dark-element-bg;
  }

  .form-control::placeholder,
  .navbar-nav .nav-link.disabled {
    color: $toolbar-dark-color-lighter;
  }
}

.navbar-fixed-bottom,
.navbar-fixed-top {
  box-shadow: map-get($toolbar-elevation-shadow, shadow);
  position: fixed;
  right: 0;
  left: 0;
  z-index: map-get($toolbar-elevation-shadow, elevation);
}

.navbar-fixed-bottom {
  bottom: 0;
}

.navbar-fixed-top {
  top: 0;
}

.navbar-full {
  box-shadow: map-get($toolbar-elevation-shadow, shadow);
  z-index: map-get($toolbar-elevation-shadow, elevation);
}

.navbar-sticky-top {
  @supports (position: sticky) {
    box-shadow: map-get($toolbar-elevation-shadow, shadow);
    position: sticky;
    top: 0;
    z-index: map-get($toolbar-elevation-shadow, elevation);
  }
}

.toolbar-waterfall {
  @include transition-standard(background-color, box-shadow);

  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: map-get($toolbar-elevation-shadow, elevation);

  &.waterfall {
    background-color: $toolbar-waterfall-bg;
    box-shadow: map-get($toolbar-elevation-shadow, shadow);
    position: fixed;
  }
}

// Misc

.navbar-brand {
  @include typography-title;

  align-items: center;
  color: inherit;
  display: inline-flex;
  height: $toolbar-element-height;
  position: relative;
  white-space: nowrap;

  @include active-focus-hover {
    color: inherit;
    text-decoration: none;
  }

  &::before {
    @include transition-standard(opacity);

    background-color: $toolbar-element-bg;
    content: '';
    display: block;
    opacity: 0;
    position: absolute;
    top: 0;
    right: ($toolbar-inner-spacer-x / -2);
    bottom: 0;
    left: ($toolbar-inner-spacer-x / -2);
  }

  &:focus {
    outline: 0;

    &::before {
      opacity: 1;
    }
  }

  &:not(:first-child) {
    margin-left: $toolbar-inner-spacer-x;
  }

  &:not(:last-child) {
    margin-right: $toolbar-inner-spacer-x;
  }
}

.navbar-text {
  align-items: center;
  color: inherit;
  display: inline-flex;
  flex-wrap: wrap;
  height: $toolbar-element-height;
}

// Nav

.navbar-nav {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin-bottom: 0;
  padding-left: 0;

  .nav-link {
    @include border-radius($toolbar-element-border-radius);
    @include transition-standard(background-color, opacity);

    color: inherit;
    font-size: $toolbar-link-font-size;
    height: $toolbar-link-height;
    line-height: $toolbar-link-line-height;
    opacity: $toolbar-element-opacity;
    padding: $toolbar-link-padding-y $toolbar-link-padding-x;

    @include active-focus-hover {
      background-color: $toolbar-element-bg;
      opacity: 1;
    }

    &.active,
    &.disabled {
      opacity: 1;
    }

    &.disabled {
      background-color: transparent;
      color: $toolbar-color-lighter;
    }

    &:focus {
      outline: 0;
    }
  }

  .active > .nav-link,
  .show > .nav-link {
    opacity: 1;
  }

  .show > .nav-link {
    background-color: $toolbar-element-bg;
  }
}

// Toggleable

.navbar-collapse {
  align-items: center;
  flex-basis: 100%;
  flex-grow: 1;
}

.navbar-expand {
  @each $breakpoint in map-keys($grid-breakpoints) {
    $next: breakpoint-next($breakpoint);
    $infix: breakpoint-infix($next);

    &#{$infix} {
      @include media-breakpoint-down($breakpoint) {
        > .container,
        > .container-fluid {
          padding-right: 0;
          padding-left: 0;
        }
      }

      @include media-breakpoint-up($next) {
        flex-flow: row nowrap;
        justify-content: flex-start;

        .navbar-collapse {
          display: flex !important; // stylelint-disable-line declaration-no-important
          flex-basis: auto;
        }

        .navbar-toggler {
          display: none;

          &:first-child + .navbar-brand {
            margin-left: 0;
          }
        }

        > .container,
        > .container-fluid {
          flex-wrap: nowrap;
        }
      }
    }
  }
}

.navbar-toggler {
  align-items: center;
  background-color: transparent;
  border: 0;
  border-radius: 50%;
  color: inherit;
  display: inline-flex;
  flex-shrink: 0;
  height: $toolbar-element-height;
  justify-content: center;
  line-height: 1;
  padding: 0;
  position: relative;
  width: $toolbar-element-height;

  @include active-focus-hover {
    color: inherit;
    text-decoration: none;

    &::before {
      opacity: 1;
    }
  }

  &::before {
    @include transition-standard(opacity);

    background-color: $toolbar-element-bg;
    border-radius: 50%;
    content: '';
    display: block;
    opacity: 0;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  &:focus {
    outline: 0;
  }

  &:not(:disabled):not(.disabled) {
    cursor: pointer;
  }
}

.navbar-toggler-icon {
  @include set-material-icons;

  display: block;

  &::before {
    content: $toolbar-toggler-icon;
  }
}
