$ng-select-highlight: $primary !default;
$ng-select-primary-text: $dark !default;
$ng-select-disabled-text: $dark-gray-3;
$ng-select-disabled-bg: $light-gray-2 !default;
$ng-select-border: $light-gray-2 !default;
$ng-select-bg: $light-gradient !default;
$ng-select-selected: $light-gray-1;
$ng-select-marked: $light-gray-1_5 !default;
$ng-select-border-radius: $border-radius !default;
$ng-select-height: 36px !default;

.ng-select {
  position: relative;
  &.ng-select-opened {
    &.ng-select-clearable .ng-select-container.ng-has-value:hover {
      .ng-clear-wrapper {
        opacity: 0;
        pointer-events: none;
      }
      .ng-arrow-wrapper {
        opacity: 1;
      }
    }

    > .ng-select-container {
      background: $ng-select-bg;
      border-color: $ng-select-highlight;
      box-shadow: 0 0 0 2px $ng-select-selected;
      .ng-arrow-wrapper {
        transform: rotate(180deg);
        opacity: 1;
      }
    }
  }
  &.ng-select-focused {
    .ng-select-container {
      border-color: $ng-select-highlight;
    }
  }
  &.ng-select-disabled {
    > .ng-select-container {
      background-color: $ng-select-disabled-bg;
      &:hover {
        border: 1px solid $ng-select-border;
        cursor: not-allowed;
      }
      .ng-value-container {
        .ng-value {
          color: $ng-select-disabled-text;
        }
      }
    }
  }

  .ng-has-value .ng-placeholder {
    display: none;
  }

  &.ng-select-clearable .ng-select-container.ng-has-value:hover {
    .ng-clear-wrapper {
      opacity: 1;
    }
    .ng-arrow-wrapper {
      opacity: 0;
      pointer-events: none;
    }
  }

  .ng-arrow-wrapper .ng-arrow {
    height: 8px !important;
    width: 8px !important;
    border-width: 1px 1px 0 0;
  }

  .ng-select-container {
    background-color: $ng-select-bg;
    border-radius: $ng-select-border-radius;
    border: 1px solid $ng-select-border;
    min-height: $ng-select-height;
    align-items: center;
    transition: all 0.3s;
    box-sizing: border-box;
    padding-right: 11px;
    padding-left: 11px;

    .ng-input {
      line-height: 22px;

      input {
        color: $ng-select-primary-text;
        font-weight: 500;
      }
    }
    .ng-value-container {
      align-items: center;
      .ng-value {
        font-size: 16px;
        color: $ng-select-primary-text;
        font-weight: 500;
      }
      .ng-placeholder {
        font-size: 14px;
        color: lighten($ng-select-primary-text, 60);
      }
    }
  }
  &.ng-select-single {
    &.ng-select-opened .ng-select-container .ng-value {
      opacity: 0.4;
    }

    .ng-select-container {
      .ng-value-container {
        .ng-input {
          top: 2px;
          left: 0;
          padding-left: 10px;
          padding-right: 50px;
        }
      }
    }
  }
  &.ng-select-multiple {
    &.ng-select-disabled {
      > .ng-select-container .ng-value-container .ng-value {
        background-color: $ng-select-disabled-bg;

        .ng-value-label {
          padding: 0 5px;
        }
      }
    }
    .ng-select-container {
      min-height: $ng-select-height;
      padding-left: 5px;

      .ng-value-container {
        padding-bottom: 3px;

        .ng-value {
          margin-top: 3px;
          margin-right: 4px;
          font-size: 0.9em;
          background-color: $light-gray-2;
          border: 1px solid lighten($ng-select-border, 6);
          border-radius: $border-radius-sm;
          height: 24px;
          line-height: 22px;

          &.ng-value-disabled {
            background-color: $ng-select-disabled-bg;
            color: $ng-select-disabled-text;

            .ng-value-label {
              padding-left: 5px;
            }
          }
          .ng-value-label {
            display: inline-block;
            padding: 0 5px;
          }
          .ng-value-icon {
            display: inline-block;
            padding: 0 5px;
          }
        }
        .ng-placeholder {
          top: 50%;
          height: 20px;
          margin-top: -10px;
          margin-left: 6px;
        }
        .ng-input {
          height: 24px;
          margin-top: 3px;
        }
      }
    }
  }
  .ng-clear-wrapper {
    opacity: 0;
    color: darken($ng-select-border, 20);
    background: rgba(0, 0, 0, 0.25);
    width: 12px;
    height: 12px;
    text-align: center;
    border-radius: 12px;
    vertical-align: middle;
    transition: color .3s ease;
    position: absolute;
    right: 13px;

    &:hover {
      background: rgba(0, 0, 0, 0.45);
    }
    .ng-clear {
      color: #fff;
      font-size: 9px;
      position: absolute;
      left: 3px;
      line-height: 12px;
    }
  }
  .ng-spinner-zone {
    padding: 5px 5px 0 0;
  }
  .ng-arrow-wrapper {
    width: 16px;
    height: 26px;
    transition: transform 0.3s;

    .ng-arrow {
      border-style: solid;
      border-width: 0.1rem 0.1rem 0 0;
      height: 8px;
      width: 8px;
      top: -2px;
      transform: rotate(135deg);
      color: $ng-select-disabled-text;
    }
  }
}

.ng-dropdown-panel {
  background-color: $light;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: $ng-select-border-radius;
  margin-top: 4px;
  margin-bottom: 4px;
  left: 0;
  // z-index: 10;

  &.ng-select-bottom {
    top: 100%;
    border-top-color: lighten($ng-select-border, 10);
  }
  &.ng-select-top {
    bottom: 100%;
    border-bottom-color: lighten($ng-select-border, 10);
  }
  .ng-dropdown-header {
    border-bottom: 1px solid $ng-select-border;
    padding: 5px 7px;
  }
  .ng-dropdown-footer {
    border-top: 1px solid $ng-select-border;
    padding: 5px 7px;
  }
  .ng-dropdown-panel-items {
    .ng-optgroup {
      user-select: none;
      padding: 4px 12px;
      color: rgba(0, 0, 0, .45);
      cursor: pointer;
      &.ng-option-disabled {
        cursor: default;
        color: rgba(0, 0, 0, .45);
      }
      &.ng-option-marked {
        background-color: $ng-select-marked;
      }
      &.ng-option-selected {
        background-color: #fafafa;
        font-weight: 500;
      }
      &.ng-option-selected.ng-option-marked {
        background-color: $ng-select-marked;
      }
    }
    .ng-option {
      background-color: $ng-select-bg;
      color: $ng-select-primary-text;
      padding: 5px 12px;
      transition: background .3s ease;

      &:first-child {
        border-top-right-radius: 4px;
        border-top-left-radius: 4px;
      }

      &:last-child {
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 4px;
      }
      &.ng-option-selected {
        background-color: #fafafa;
        font-weight: 600;
      }
      &.ng-option-selected.ng-option-marked {
        color: $ng-select-primary-text;
        background-color: $ng-select-marked;
      }
      &.ng-option-marked {
        background-color: $ng-select-marked;
        color: $ng-select-primary-text;
      }
      &.ng-option-disabled {
        color: $ng-select-disabled-text;
        cursor: not-allowed;
      }
      &.ng-option-child {
        padding-left: 20px;
      }
      .ng-option-label {
        font-size: 14px;
      }
      .ng-tag-label {
        font-size: 80%;
        font-weight: 400;
        padding-right: 5px;
      }
    }
  }
}
