$search-input-field-min-width: 320px;
$search-input-field-x-min-width: 200px;

.navbar-gitlab {
  padding: 0 16px;
  z-index: $header-zindex;
  margin-bottom: 0;
  min-height: $header-height;
  border: 0;
  position: fixed;
  top: $calc-application-bars-height;
  left: 0;
  right: 0;
  border-radius: 0;

  .close-icon {
    display: none;
  }

  .header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    position: relative;
    min-height: $header-height;
    padding-left: 0;

    .title {
      padding-right: 0;
      color: currentColor;
      display: flex;
      position: relative;
      margin: 0;
      font-size: 18px;
      vertical-align: top;
      white-space: nowrap;

      img {
        height: 24px;

        + .logo-text {
          margin-left: 8px;
        }
      }

      &.wrap {
        white-space: normal;
      }

      &.initializing {
        opacity: 0;
      }

      a:not(.canary-badge) {
        display: flex;
        align-items: center;
        padding: 2px 8px;
        margin: 4px 2px 4px -8px;
        border-radius: $border-radius-default;

        &:active,
        &:focus {
          @include gl-focus($focus-ring: $focus-ring-dark);
        }
      }
    }

    .dropdown.open {
      > a {
        border-bottom-color: $white;
      }
    }

    .navbar-collapse > ul.nav > li:not(.d-none) {
      margin: 0 2px;
    }
  }

  .header-search {
    min-width: $search-input-field-min-width;

    // This is a temporary workaround!
    // the button in GitLab UI Search components need to be updated to not be the small size
    // see in Figma: https://www.figma.com/file/qEddyqCrI7kPSBjGmwkZzQ/Component-library?node-id=43905%3A45540
    .gl-search-box-by-type-clear.btn-sm {
      padding: 0.5rem !important;
    }

    @include media-breakpoint-between(md, lg) {
      min-width: $search-input-field-x-min-width;
    }

    &.is-searching {
      .in-search-scope-help {
        position: absolute;
        top: $gl-spacing-scale-2;
        right: 2.125rem;
        z-index: 2;
      }
    }

    &.is-not-focused {
      .gl-search-box-by-type-clear {
        display: none;
      }
    }

    .keyboard-shortcut-helper {
      transform: translateY(calc(50% - 2px));
      box-shadow: none;
      border-color: transparent;
    }
  }

  .header-search-dropdown-menu {
    max-height: $dropdown-max-height;
    top: 100%;
  }

  .navbar-collapse {
    flex: 0 0 auto;
    border-top: 0;
    padding: 0;

    @include media-breakpoint-down(xs) {
      flex: 1 1 auto;
    }

    .nav {
      flex-wrap: nowrap;

      > li:not(.d-none) a {
        @include media-breakpoint-down(xs) {
          margin-left: 0;
        }
      }
    }
  }

  .container-fluid {
    padding: 0;

    .user-counter {
      svg {
        margin-right: 3px;
      }
    }

    .navbar-toggler {
      position: relative;
      right: -10px;
      border-radius: 0;
      min-width: 45px;
      padding: 0;
      margin: $gl-padding-8 $gl-padding-8 $gl-padding-8 0;
      font-size: 14px;
      text-align: center;
      color: currentColor;

      &:hover,
      &:focus,
      &.active {
        color: currentColor;
        background-color: transparent;
      }
    }

    .navbar-nav {
      @include media-breakpoint-down(xs) {
        display: flex;
        padding-right: 10px;
        flex-direction: row;
      }

      li {
        .badge.badge-pill:not(.gl-badge) {
          box-shadow: none;
          font-weight: $gl-font-weight-bold;
        }
      }
    }

    .nav > li {
      &.header-user {
        @include media-breakpoint-down(xs) {
          padding-left: 10px;
        }
      }

      > a {
        will-change: color;
        margin: 4px 0;
        padding: 6px 8px;
        height: 32px;

        @include media-breakpoint-down(xs) {
          padding: 0;
        }

        &.header-user-dropdown-toggle {
          margin-left: 2px;

          .header-user-avatar {
            margin-right: 0;
          }
        }
      }

      .header-new-dropdown-toggle {
        margin-right: 0;
      }

      .impersonated-user,
      .impersonated-user:hover {
        margin-right: 1px;
        background-color: $white;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }

      .impersonation-btn,
      .impersonation-btn:hover {
        background-color: $white;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;

        svg {
          color: $orange-500;
        }
      }
    }
  }
}

.navbar-sub-nav,
.navbar-nav {
  > li {
    > a,
    > button {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 6px 8px;
      margin: 4px 2px;
      font-size: 12px;
      color: currentColor;
      border-radius: $border-radius-default;
      height: 32px;
      font-weight: $gl-font-weight-bold;

      &:hover,
      &:focus {
        text-decoration: none;
        outline: 0;
        color: $white;
      }

      &:active,
      &:focus {
        @include gl-focus($focus-ring: $focus-ring-dark);
      }
    }

    .top-nav-toggle,
    > button {
      background: transparent;
      border: 0;
    }

    &.line-separator {
      margin: 8px;
    }
  }

  .dropdown-menu {
    position: absolute;
  }
}

.navbar-sub-nav {
  display: flex;
  align-items: center;
  height: 100%;
  margin: 0 0 0 6px;

  .dropdown-chevron {
    position: relative;
    top: -1px;
    font-size: 10px;
  }

  .frequent-items-item-select-holder {
    display: inline;
  }

  .impersonation i {
    color: $red-500;
  }
}

.caret-down,
.btn .caret-down {
  top: 0;
  height: 11px;
  width: 11px;
  margin-left: 4px;
  fill: currentColor;
}

.header-user .dropdown-menu,
.header-new .dropdown-menu {
  margin-top: $dropdown-vertical-offset;
}

.top-bar-container {
  min-height: $top-bar-height;
}

.top-bar-fixed {
  @include gl-inset-border-b-1-gray-100;
  background-color: $body-bg;
  left: var(--application-bar-left);
  position: fixed;
  right: var(--application-bar-right);
  top: $calc-application-bars-height;
  width: auto;
  z-index: $top-bar-z-index;

  @media (prefers-reduced-motion: no-preference) {
    transition: left $gl-transition-duration-medium, right $gl-transition-duration-medium;
  }

  .breadcrumbs-list {
    @include media-breakpoint-down(xs) {
      flex-wrap: nowrap;
    }
  }
}

.breadcrumbs {
  flex: 1;
  min-width: 0;
  align-self: center;
  color: $gl-text-color-secondary;

  .avatar-tile {
    margin-right: 4px;
    border: 1px solid $border-color;
    border-radius: 50%;
    vertical-align: sub;
  }

  .text-expander {
    margin-left: 0;
    margin-right: 2px;

    > i {
      position: relative;
      top: 1px;
    }
  }
}

.breadcrumbs-list {
  display: flex;
  margin-bottom: 0;
  line-height: 16px;

  @include media-breakpoint-down(xs) {
    flex-wrap: wrap;
  }

  > li {
    display: flex;
    align-items: center;
    position: relative;
    min-width: 0;
    padding: 2px 0;

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

    &:last-child {
      > a {
        font-weight: 600;
        line-height: 16px;
        color: $gl-text-color;
      }
    }

    > a {
      font-size: 12px;
      color: currentColor;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex: 0 1 auto;
    }

    &:last-of-type > .breadcrumbs-list-angle {
      display: none;
    }
  }
}

.breadcrumb-item-text {
  text-decoration: inherit;

  @include media-breakpoint-down(xs) {
    @include str-truncated(128px);
  }
}

.breadcrumbs-list-angle {
  position: absolute;
  right: 7px;
  top: 50%;
  color: $gl-text-color-tertiary;
  transform: translateY(-50%);
}

.breadcrumbs-extra {
  display: flex;
  flex: 0 0 auto;
  margin-left: auto;
}

@include media-breakpoint-down(xs) {
  .navbar-gitlab .container-fluid {
    font-size: 18px;

    .navbar-nav {
      table-layout: fixed;
      width: 100%;
      margin: 0;
      text-align: right;
    }

    .navbar-collapse {
      margin-left: -8px;
      margin-right: -10px;

      .nav > li:not(.d-none) {
        flex: 1;
      }
    }
  }

  .header-user-dropdown-toggle {
    text-align: center;
  }

  .header-user-avatar {
    float: none;
  }
}

.header-user {
  &.show .dropdown-menu {
    margin-top: 4px;
    color: var(--gl-text-color, $gl-text-color);
    left: auto;
    max-height: $dropdown-max-height-lg;

    .user-status {
      max-width: 240px;
    }

    svg {
      vertical-align: text-top;
    }

    a.ci-minutes-emoji gl-emoji,
    a.trial-link gl-emoji {
      font-size: $gl-font-size;
      vertical-align: baseline;
    }
  }
}

.header-user-avatar {
  float: left;
  margin-right: 5px;
  border-radius: 50%;
  border: 1px solid $gray-normal;
}

.notification-dot {
  background-color: $orange-300;
  height: 12px;
  width: 12px;
  pointer-events: none;
  visibility: hidden;
  top: 3px;
}

.with-notifications .notification-dot {
  visibility: visible;
}

.navbar-empty {
  justify-content: center;
  height: $header-height;
  background: $white;
  border-bottom: 1px solid $gray-100;

  .tanuki-logo,
  .brand-header-logo {
    max-height: 100%;
  }
}

.set-user-status-modal {
  .modal-body {
    min-height: unset;
  }

  .input-lg {
    max-width: unset;
  }

  .no-emoji-placeholder {
    svg {
      fill: var(--gray-500, $gray-500);
    }
  }

  .emoji-menu-toggle-button {
    @include emoji-menu-toggle-button;
    padding: $gl-vert-padding $gl-btn-padding;
  }

  .input-group {
    &,
    .input-group-prepend,
    .input-group-append {
      height: $input-height;
    }
  }
}

.nav-links > li > a {
  .badge.badge-pill {
    @include media-breakpoint-down(xs) { display: none; }
  }

  @include media-breakpoint-down(xs) { margin-right: 3px; }
}

.toggle-mobile-nav {
  @include gl-display-none;

  @include media-breakpoint-down(sm) {
    @include gl-display-block;

    + .breadcrumbs {
      @include gl-pl-4;
      @include gl-border-l-1;
      @include gl-border-l-solid;
      @include gl-border-gray-100;
    }
  }
}

.top-nav-container-view {
  .gl-dropdown & .gl-search-box-by-type {
    @include gl-m-0;
  }

  .frequent-items-list-item-container > a:hover {
    background-color: $nav-active-bg !important;
  }
}

.top-nav-toggle {
  .dropdown-chevron {
    top: 0;
  }
}

.top-nav-menu-item {
  &.active,
  &:hover {
    background-color: $nav-active-bg !important;
  }

  .gl-icon {
    color: inherit !important;
  }
}

.top-nav-responsive {
  @include gl-display-none;
}

.top-nav-responsive-open {
  .more-icon {
    display: none;
  }

  .close-icon {
    display: block;
    margin: auto;
  }

  @include media-breakpoint-down(xs) {
    .navbar-collapse {
      display: flex;
    }

    .hide-when-top-nav-responsive-open {
      display: none !important;
    }

    .top-nav-responsive {
      @include gl-display-block;
    }

    .navbar-gitlab .header-content .title-container {
      flex: 0;
    }
  }
}
