/** Select2 selectbox style override **/
.select2-container {
  width: 100% !important;
}

.select2-container,
.select2-container.select2-drop-above {
  .select2-choice {
    background: $white-light;
    border-color: $input-border;
    height: 35px;
    padding: $gl-vert-padding $gl-input-padding;
    font-size: $gl-font-size;
    line-height: 1.42857143;
    border-radius: $border-radius-base;

    .select2-arrow {
      background-image: none;
      background-color: transparent;
      border: none;
      padding-top: 12px;
      padding-right: 20px;
      font-size: 10px;

      b {
        display: none;
      }

      &::after {
        content: "\f078";
        position: absolute;
        z-index: 1;
        text-align: center;
        pointer-events: none;
        box-sizing: border-box;
        color: $gray-darkest;
        display: inline-block;
        font: normal normal normal 14px/1 FontAwesome;
        font-size: inherit;
        text-rendering: auto;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
      }
    }

    .select2-chosen {
      margin-right: 15px;
    }

    &:hover {
      background-color: $white-normal;
      border-color: $border-white-normal;
      color: $gl-text-color;
    }
  }
}

.select2-drop {
  background-color: $white-light;
  border: 1px solid $dropdown-border-color;
  border-radius: $border-radius-base;
  box-shadow: 0 2px 4px $dropdown-shadow-color;
  min-width: 175px;
}

.select2-results .select2-result-label,
.select2-more-results {
  padding: 10px 15px;
}

.select2-drop {
  color: $gl-grayish-blue;
}

.select2-highlighted {
  background: $dropdown-hover-color !important;
}

.select2-results li.select2-result-with-children > .select2-result-label {
  font-weight: $gl-font-weight-bold;
  color: $gl-text-color;
}

.select2-container-active {
  .select2-choice,
  .select2-choices {
    box-shadow: none;
  }
}

.select2-dropdown-open {
  .select2-choice {
    border-color: $border-white-normal;
    outline: 0;
    background-image: none;
    background-color: $white-dark;
    box-shadow: $gl-btn-active-gradient;
  }
}

.select2-container-multi {
  .select2-choices {
    border-radius: $border-radius-default;
    border-color: $input-border;
    background: none;

    .select2-search-field input {
      padding: 5px $gl-padding / 2;
      height: auto;
      font-family: inherit;
      font-size: inherit;
    }

    .select2-search-choice {
      margin: 5px 0 0 8px;
      box-shadow: none;
      border-color: $input-border;
      color: $gl-text-color;
      line-height: 15px;
      background-color: $gray-light;
      background-image: none;
      padding: 3px 18px 3px 5px;

      .select2-search-choice-close {
        top: 5px;
        left: initial;
        right: 3px;
      }

      &.select2-search-choice-focus {
        border-color: $gl-text-color;
      }
    }
  }

  &.select2-container-active .select2-choices,
  &.select2-dropdown-open .select2-choices {
    border-color: $dropdown-input-focus-border;
    box-shadow: 0 0 4px $search-input-focus-shadow-color;
  }
}

.select2-drop-active {
  margin-top: 6px;
  font-size: 14px;

  &.select2-drop-above {
    margin-bottom: 8px;
  }

  .select2-results {
    max-height: 350px;

    .select2-highlighted {
      background: $gl-primary;
    }
  }
}

.select2-search {
  padding: 15px 15px 5px;

  .select2-drop-auto-width & {
    padding: 15px 15px 5px;
  }
}

.select2-search input {
  padding: 2px 25px 2px 5px;
  background: $white-light image-url('select2.png');
  background-repeat: no-repeat;
  background-position: right 0 bottom 6px;
  border: 1px solid $input-border;
  border-radius: $border-radius-default;
  transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;

  &:focus {
    border-color: $input-border-focus;
  }
}

.select2-search input.select2-active {
  background-color: $white-light;
  background-image: image-url('select2-spinner.gif') !important;
  background-repeat: no-repeat;
  background-position: right 5px center !important;
  background-size: 16px 16px !important;
}

.select2-results .select2-no-results,
.select2-results .select2-searching,
.select2-results .select2-ajax-error,
.select2-results .select2-selection-limit {
  background: $gray-light;
  display: list-item;
  padding: 10px 15px;
}


.select2-results {
  margin: 0;
  padding: 10px 0;
}

.ajax-users-select {
  width: 400px;

  &.input-large {
    width: 210px;
  }

  &.input-clamp {
    max-width: 100%;
  }
}

.select2-highlighted {
  .group-result {
    .group-path {
      color: $white-light;
    }
  }
}

.group-result {
  .group-image {
    float: left;
  }

  .group-name {
    font-weight: $gl-font-weight-bold;
  }

  .group-path {
    color: $group-path-color;
  }
}

.project-result {
  .project-name {
    font-weight: $gl-font-weight-bold;
  }

  .project-path {
    color: $project-path-color;
  }
}

.user-result {
  min-height: 24px;
  display: flex;

  .user-image {
    float: left;
  }

  &.no-username {
    .user-name {
      line-height: 24px;
    }
  }
}

.namespace-result {
  .namespace-kind {
    color: $namespace-kind-color;
    font-weight: $gl-font-weight-normal;
  }

  .namespace-path {
    margin-left: 10px;
    font-weight: $gl-font-weight-bold;
  }
}

.ajax-users-dropdown {
  min-width: 250px !important;
}

// TODO: change global style
.ajax-project-dropdown,
.ajax-users-dropdown,
body[data-page="projects:edit"] #select2-drop,
.ajax-users-dropdown,
body[data-page="projects:settings:repository:show"] #select2-drop,
body[data-page="projects:new"] #select2-drop,
body[data-page="projects:merge_requests:edit"] #select2-drop,
body[data-page="projects:blob:new"] #select2-drop,
body[data-page="profiles:show"] #select2-drop,
body[data-page="admin:groups:show"] #select2-drop,
body[data-page="projects:issues:show"] #select2-drop,
body[data-page="admin:groups:show"] #select2-drop,
body[data-page="projects:blob:edit"] #select2-drop {
  &.select2-drop {
    border: 1px solid $dropdown-border-color;
    border-radius: $border-radius-base;
    color: $gl-text-color;
  }

  &.select2-drop-above {
    border-top: none;
    margin-top: -4px;
  }

  .select2-results {
    .select2-no-results,
    .select2-searching,
    .select2-ajax-error,
    .select2-selection-limit {
      background: transparent;
    }

    .select2-result {
      padding: 0 1px;

      .select2-match {
        font-weight: $gl-font-weight-bold;
        text-decoration: none;
      }

      .select2-result-label {
        padding: #{$gl-padding / 2} $gl-padding;
      }

      &.select2-highlighted {
        background-color: transparent !important;
        color: $gl-text-color;

        .select2-result-label {
          background-color: $dropdown-item-hover-bg;
        }
      }
    }
  }
}
