@import '../../scss/variables/colors';

$base-class: 'dropdown';

.#{$base-class} {
  background-color: #fff;
  box-shadow: 0 1px 10px 0 rgba(66, 77, 87, 0.3);
  border-radius: 4px;
  min-width: 168px;
  max-width: 336px;
  display: none;

  &:focus {
    outline: none;
  }

  &--visible {
    display: block;
  }

  &__list {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 500px;

    &:focus {
      outline: none;
    }
  }

  &__arrow {
    position: absolute;
    height: 6px;
    margin: -6px 0;
    width: 12px;

    &::after {
      content: '';
      position: absolute;
      z-index: 1;
      border: 6px solid transparent;
      border-color: #fff #fff transparent transparent;
      transform: rotate(-45deg);
      box-shadow: -5px 5px 10px -2px rgba(66, 77, 87, 0.3);
    }

    &[data-placement*='bottom'] {
      top: 0;

      &::after {
        border-color: #fff #fff transparent transparent;
        box-shadow: 3px -3px 10px -2px rgba(66, 77, 87, 0.3);
      }
    }

    &[data-placement*='top'] {
      top: 100%;

      &::after {
        border-color: transparent transparent #fff #fff;
        box-shadow: -3px 3px 10px -2px rgba(66, 77, 87, 0.3);
      }
    }

    &[data-placement*='right'] {
      left: 0;
      height: 12px;
      margin: 0 -6px;
      width: 6px;

      &::after {
        border-color: #fff transparent transparent #fff;
        box-shadow: -3px -3px 10px -2px rgba(66, 77, 87, 0.3);
      }
    }

    &[data-placement*='left'] {
      left: 100%;
      height: 12px;
      margin: 0 -6px;
      width: 6px;

      &::after {
        border-color: transparent #fff #fff transparent;
        box-shadow: 3px 3px 10px -2px rgba(66, 77, 87, 0.3);
      }
    }
  }

  &__list-item {
    list-style: none;
    padding: 10px;
    cursor: pointer;
    line-height: 1.3;
    font-size: 14px;
    color: $font-primary-color;
    display: flex;
    align-items: center;
    box-sizing: border-box;

    &:focus {
      outline: none;
    }

    &__icon {
      margin-right: 10px;
      height: 16px;
    }

    &__content {
      max-width: calc(100% - 20px);
      display: flex;
    }

    &__title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex: 1 1 auto;
    }

    &--focused {
      background-color: $hover-background-color;
    }

    &__checkmark {
      opacity: 0;
      visibility: hidden;
      transition: all 0.15s ease-in-out;
      fill: $primary-color;
      margin-left: auto;
      padding-left: 5px;
    }

    &--selected {
      color: $primary-color;

      .#{$base-class}__list-item__checkmark {
        opacity: 1;
        visibility: visible;
        transition: all 0.15s ease-in-out;
      }
    }

    &--disabled {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
    }

    &--with-divider {
      border-bottom: 1px solid $divider-color;
    }
  }
}

@media screen and (max-height: 490px) {
  .#{$base-class}__list {
    max-height: calc(100vh - 10px);
  }
}
