.select {
  $self: &;
  position: relative;
  display: flex;
  font-size: 14px;
  @include media-breakpoint-up(sm) {
    font-size: $body-font-size;
  }

  select,
  .form-control {
    -webkit-appearance: none;
    padding-right: 30px;
    width: 100%;
    height: 32px;
    line-height: 30px;
    padding: 0 30px 0 10px;
    border-color: $border-color;
    &::-ms-expand {
      display: none;
    }
  }

  label {
    margin-right: 10px;
    padding-top: 2px;
  }

  &:before,
  &:after {
    content: "";
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    height: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    z-index: 10;
  }

  &:after {
    border-top: 7px solid #333;
  }

  &:before {
    display: none;
    border-bottom: 7px solid #333;
  }

  &--arrow-opposite {
    &:before {
      display: block;
      top: 35%;
    }
    &:after {
      top: 65%;
    }
  }

  &--arrow-up {
    &:after {
      display: none;
    }

    &:before {
      display: block;
    }
  }

  &--arrow-long {
    &.select--arrow-opposite {
      &:before {
        top: 38%;
      }
      &:after {
        top: 62%;
      }
    }

    &:before {
      border-bottom: 7px solid #666666;
    }
    &:after {
      border-top: 7px solid #666666;
    }
  }

  &--sm {
    select {
      @extend .form-control-sm;
    }

    &.select--arrow-opposite {
      &:before,
      &:after {
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
      }

      &:before {
        border-bottom: 5px solid #666666;
        top: 38%;
      }

      &:after {
        border-top: 5px solid #666666;
        top: 62%;
      }
    }
  }

  &--xs {
    select,
    .form-control {
      @extend .form-control-xs;
    }

    &.select--arrow-opposite {
      &:before,
      &:after {
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
      }

      &:before {
        border-bottom: 4px solid #666666;
        top: 38%;
      }

      &:after {
        border-top: 4px solid #666666;
        top: 62%;
      }
    }
  }

  &--gray {
    .form-control {
      border-color: #999999;
    }
  }
}

// this for custom select
.select-custom {
  $self: &;
  position: relative;
  font: {
    weight: 300;
  }
  cursor: pointer;

  &__view {
    @extend .form-control;
    align-items: center;
    display: flex;
    padding: 6px 30px 6px 10px;
    position: relative;
    border-radius: 3px;

    &:after {
      @extend .select:after;
    }

    &:before {
      @extend .select:before;
    }

    img {
      margin-right: 5px;
    }

    span {
      overflow: hidden;
      flex-basis: calc(100% - 50px);
      text-overflow: ellipsis;
      white-space: pre;
      font: {
        weight: 300;
      }
    }
  }

  &__list {
    padding: 0;
    margin: 0;
    list-style-type: none;
    border: 1px solid #dedede;
    border-top: none;
    border-radius: 0 0 3px 3px;
    position: absolute;
    top: 30px;
    left: 0;
    z-index: 2;
    width: 100%;
    background-color: #fff;
    display: none;
    // max-height: 90px;
    overflow: hidden;
    li {
      padding: 2px 10px;
      display: flex;
      cursor: pointer;
      align-items: center;
      &:hover {
        background-color: #f1f1f1;
      }
    }
    img {
      width: 25px;
      margin-right: 5px;
    }
  }

  &.is-active {
    #{$self}__view {
      border-radius: 3px 3px 0 0;
    }

    #{$self}__list {
      display: block;
      z-index: 11;
    }
  }

  select {
    display: none;
  }

  &:not(.is-active) {
    .mg-form__input--error {
      + .select-custom__view {
        background-color: $form-input-error-bg-color;
        border: 1px solid $form-input-error-border-color;
      }
    }
  }

  &--arrow-opposite {
    #{$self}__view {
      &:before {
        display: block;
        @extend .select--arrow-opposite:before;
        top: 38%;
      }

      &:after {
        @extend .select--arrow-opposite:after;
        top: 62%;
      }
    }
  }

  &--arrow-long {
    #{$self}__view {
      &:before {
        @extend .select--arrow-long:before;
      }

      &:after {
        @extend .select--arrow-long:after;
      }
    }
  }

  &--sm {
    #{$self}__view {
      @extend .form-control-sm;
      display: flex;
    }
  }

  &--xs {
    #{$self}__view {
      @extend .form-control-xs;
      display: flex;
      img {
        height: 100%;
        vertical-align: top;
      }
    }
  }
}

.select-label {
  display: flex;
  align-items: center;
  label {
    color: #666666;
    margin: 0 5px 0 0;
  }
  select {
    width: 52px;
    height: 22px;
  }
}
