@import "../palette";
@import "../variables";
@import "../mixins/border";

.dropdown {
  @include border($input-border-color);
  position: relative;
  color: $selected-text;
  user-select: none;
  outline: none;
  cursor: pointer;
  background: $dark-blue-color;
  height: em-calc(40px);
  transition: border-color $global-transition-duration ease;

  &:hover:not(.dropdown--disabled) {
    box-shadow: 0 0 em-calc(5px) $light-blue-color;
  }

  &:focus:not(.dropdown--disabled) {
    .dropdown__container {
      box-shadow: 0 0 em-calc(3px) $light-blue-color;
    }
  }
  &--clean {
    color: inherit;
    background: transparent;
    vertical-align: baseline;
    display: inline-block;
    padding: 0;
    border: none;
    > .dropdown__container {
      padding: 0;
    }
    .dropdown__arrow {
      height: 1em;
    }
    &:hover:not(.dropdown--disabled) {
      box-shadow: none;
      .dropdown__selected-text {
        opacity: 0.7;
      }
    }

    &:focus:not(.dropdown--disabled) {
      .dropdown__container {
        box-shadow: none;
      }
    }
    .dropdown__options {
      width: auto;
    }
    .dropdown__selected-text,
    .dropdown__selected-text--default {
      color: $brand-color;
      font-weight: 500;
    }
  }
  &--disabled {
    @include border($disabled-input-border-color);
    background: $disabled-input-background-color;
    cursor: not-allowed;
    .dropdown__selected-text {
      color: $disabled-input-text-color;
    }
    .dropdown__selected-text--default {
      color: $unselected-text;
    }
  }

  &__container {
    display: flex;
    padding: 0 em-calc(12px);
  }

  &__arrow {
    background: url("#{$path-images}/dropdown-arrow.svg") center center no-repeat;
    width: 1em;
    height: em-calc(40px);
    align-self: center;
  }

  &__selected-text {
    flex: 1 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    align-self: center;
    transition: color $global-transition-duration ease;
  }

  &__selected-text--default {
    color: $unselected-text;
  }

  &__options {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    @include border($light-blue-color);
    background: $dropdown-background-color;
    margin-top: em-calc(3px);
    z-index: $scrim-content-z-index;
    max-height: em-calc(260px);
    overflow-y: auto;
  }

  &__option {
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: bold;
    padding: em-calc(10px) em-calc(12px);
    color: $brand-color;

    &:hover {
      background: $light-blue-color;
    }
  }

  &__search {
    input {
      box-sizing: border-box;
      width: 100%;
      background: transparent;
      color: $selected-text;
      padding: em-calc(8px);
      border: 0;
      border-bottom: 1px solid $light-blue-color;
      margin: 0;
      outline: none;
    }
  }
  &-inline {
    display: inline-block;
  }
}

.dropdown-small {
  width: em-calc(60px);
    .dropdown__option {
      line-height: 1;
      font-size: rem-calc(13px);
      font-weight: normal;
      padding: em-calc(2px);
    }
}
