/**
 * Copyright © INOVUA TRADING.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

@import './variables.scss';
@import '../../Overlay/style/base.scss';

.#{$INOVUA_COMBO_BOX_ROOT_CLASS} {
  display: flex;
  align-self: center;
  position: relative;
  box-sizing: border-box;
  text-align: start;
  direction: ltr;
  outline: 0;
  width: 140px;
  vertical-align: middle;

  *,
  *:before,
  *:after {
    box-sizing: border-box;
  }
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}--rtl {
  direction: rtl;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}--inlineFlex {
  display: inline-flex;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list {
  z-index: 100;
  min-height: 28px;

  &:not(.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--relative-to-viewport) {
    left: -1px;
    right: -1px;
    min-width: 100%;
  }

  &:not(.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--relative-to-viewport) {
    position: absolute;
  }
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--position-top:not(.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--relative-to-viewport) {
  bottom: 100%;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--position-bottom:not(.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list--relative-to-viewport) {
  top: 100%;
}

// list
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__virtual-list {
  outline: none;
  overflow: auto;
  max-height: 300px;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__item {
  cursor: pointer;
  user-select: none;
  width: 100%;

  &--rtl {
    direction: rtl;
  }

  &--ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__loading-text,
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__new-custom-tag-text,
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__empty-text {
  padding: 9px;
  text-align: center;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__list__loading-text {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

// input
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__input__wrapper {
  display: flex;
  max-width: 100%;
  margin-bottom: 2px;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__input__wrapper--invisible {
  position: absolute;
  left: -20000px;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__input {
  border: 0;
  outline: none;
  max-width: 100%;
  min-width: 3px;
  font-family: inherit;
  font-size: inherit;
  background: none;

  &::-ms-clear {
    display: none;
  }
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__input__placeholder {
  color: #bbb;
}

// value
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 2px;

  &--no-wrap {
    flex-wrap: nowrap;
    overflow: hidden;
  }
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__tools {
  position: unset;
  display: flex;
  margin-bottom: 1px;
}

// tag
.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__tag {
  display: flex;
  cursor: pointer;
  // 5px to let space for input so it doens't go on two rows
  max-width: calc(100% - 5px);
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__display-value {
  display: inline-block;
  align-self: center;
  // 5px to let space for input so it doens't go on two rows
  margin-bottom: 2px;
  max-width: calc(100% - 5px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__tag--ellipsis
  .#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__tag__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__tag__label {
  flex: 1;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__value__tag__clear-icon {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.#{$INOVUA_COMBO_BOX_ROOT_CLASS}__toggle-icon {
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

// quick fix, remove outline from focusalbe elements
.react-scroll-container__scroller,
.react-virtual-scroll-container__scroll-container {
  outline: none;
}
