.vscomp-popup-active {
  overflow: hidden !important;
}

.vscomp-ele {
  display: inline-block;
  max-width: 250px;
  width: 100%;
}

.vscomp-wrapper {
  color: $font-color;
  display: inline-flex;
  flex-wrap: wrap;
  font-family: $font-family;
  font-size: $font-size;
  position: relative;
  text-align: left;
  width: 100%;

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

  &:focus {
    outline: none;
  }
}

.vscomp-dropbox-wrapper {
  left: 0;
  position: absolute;
  top: 0;
}

.vscomp-toggle-button {
  align-items: center;
  background-color: $primary-bg;
  border: 1px solid $border-color;
  cursor: pointer;
  display: flex;
  padding: 7px $arrow-width 7px 10px;
  position: relative;
  width: 100%;
}

.vscomp-value {
  height: 20px;
  line-height: 20px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vscomp-arrow {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  position: absolute;
  right: 0;
  top: 0;
  width: $arrow-width;

  &::after {
    @include prefix(transform, rotate(45deg));
    border: 1px solid transparent;
    border-bottom-color: $arrow-color;
    border-right-color: $arrow-color;
    content: '';
    height: $arrow-size;
    margin-top: -6px;
    width: $arrow-size;
  }
}

.vscomp-clear-icon {
  height: $clear-icon-size;
  position: relative;
  width: $clear-icon-size;

  &::before,
  &::after {
    background-color: #999;
    content: '';
    height: $clear-icon-size;
    left: 5px;
    position: absolute;
    top: 0;
    width: 2px;
  }

  &::before {
    @include prefix(transform, rotate(45deg));
  }

  &::after {
    @include prefix(transform, rotate(-45deg));
  }

  &:hover {
    &::before,
    &::after {
      background: $icon-hover-color;
    }
  }
}

.vscomp-clear-button {
  align-items: center;
  border-radius: 50%;
  display: none;
  height: $clear-button-width;
  justify-content: center;
  margin-top: math.div($clear-button-width, -2);
  position: absolute;
  right: $arrow-width;
  top: 50%;
  width: $clear-button-width;

  &:hover {
    background: $focus-color;

    .vscomp-clear-icon {
      &::before,
      &::after {
        background-color: $icon-hover-color;
      }
    }
  }
}

.vscomp-dropbox-close-button {
  align-items: center;
  background-color: $primary-bg;
  border-radius: 50%;
  bottom: -#{$dropbox-close-button-width + $dropbox-close-button-offset};
  cursor: pointer;
  display: none;
  height: $dropbox-close-button-width;
  justify-content: center;
  left: 50%;
  margin-left: math.div($dropbox-close-button-width, -2);
  position: absolute;
  width: $dropbox-close-button-width;
}

.vscomp-value-tag {
  &.more-value-count {
    white-space: nowrap;
  }
}

.vscomp-dropbox-container {
  width: 100%;
  z-index: $z-index + 1;
}

.vscomp-dropbox {
  background-color: $primary-bg;
  width: 100%;
}

.vscomp-options-container {
  max-height: #{$dropbox-height - $search-height};
  overflow: auto;
  position: relative;
}

.vscomp-options-bottom-freezer {
  bottom: 0;
  height: 2px;
  left: 0;
  position: absolute;
  right: 0;
}

.vscomp-option {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  height: $option-height;
  padding: 0 15px;
  position: relative;

  &.selected {
    background-color: $selected-color;
  }

  &.focused {
    background-color: $focus-color;
  }

  &.disabled {
    cursor: default;
    opacity: 0.5;
  }

  &.group-title {
    .vscomp-option-text {
      cursor: default;
      opacity: 0.6;
    }

    &.selected {
      background-color: transparent;
    }
  }

  &.group-option {
    padding-left: 30px;
  }
}

.vscomp-new-option-icon {
  height: $new-option-icon-width;
  position: absolute;
  right: 0;
  top: 0;
  width: $new-option-icon-width;

  &::before {
    border: math.div($new-option-icon-width, 2) solid $primary-color;
    border-bottom-color: transparent;
    border-left-color: transparent;
    content: '';
    position: absolute;
    right: 0;
    top: 0;
  }

  &::after {
    align-items: center;
    color: #fff;
    content: '+';
    display: flex;
    font-size: 18px;
    height: math.div($new-option-icon-width, 2);
    justify-content: center;
    position: absolute;
    right: 1px;
    top: 0;
    width: math.div($new-option-icon-width, 2);
  }
}

.vscomp-option-text {
  @include ellipse;
  user-select: none;
  width: 100%;
}

.vscomp-option-description {
  @include ellipse;
  color: $font-color-light;
  font-size: $font-size-small;
  line-height: 15px;
  width: 100%;
}

.vscomp-search-container {
  align-items: center;
  border-bottom: 1px solid $border-color;
  display: flex;
  height: $search-height;
  padding: 0 5px 0 15px;
  position: relative;
}

.vscomp-search-label,
.vscomp-live-region,
.vscomp-dropbox-container-top,
.vscomp-dropbox-container-bottom {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.vscomp-search-input {
  background-color: transparent;
  border: 0;
  color: inherit;
  font-size: 15px;
  height: #{$search-height - 2px};
  padding: 10px 0;
  width: calc(100% - #{$search-clear-width});

  &:focus {
    outline: none;
  }
}

.vscomp-search-clear {
  align-items: center;
  color: #999;
  cursor: pointer;
  display: flex;
  font-size: 25px;
  height: $search-clear-width;
  justify-content: center;
  user-select: none;
  visibility: hidden;
  width: $search-clear-width;

  &:hover {
    color: inherit;
  }
}

.vscomp-no-options,
.vscomp-no-search-results {
  align-items: center;
  display: none;
  justify-content: center;
  padding: 20px 10px;
}

.vscomp-options-loader {
  display: none;
  padding: 20px 0;
  text-align: center;

  &::before {
    @include prefix(animation, vscomp-animation-spin 0.8s infinite linear);
    background-color: $primary-bg;
    border-radius: 50%;
    box-shadow: -4px -5px 3px -3px rgba(0, 0, 0, 0.3);
    content: '';
    display: inline-block;
    height: $options-loader-size;
    opacity: 0.7;
    width: $options-loader-size;
  }
}

.vscomp-ele {
  &[disabled] {
    cursor: not-allowed;
    user-select: none;

    .vscomp-wrapper {
      opacity: 0.7;
      pointer-events: none;
    }
  }
}

.vscomp-wrapper {
  .checkbox-icon {
    display: inline-flex;
    height: 15px;
    margin-right: $option-checkbox-margin;
    position: relative;
    width: 15px;

    &::after {
      @include prefix(transition-duration, 0.2s);
      border: 2px solid $checkbox-color;
      content: '';
      display: inline-block;
      height: 100%;
      width: 100%;
    }

    &.checked::after {
      @include checkbox-checked;
    }
  }

  &.show-as-popup {
    .vscomp-dropbox-container {
      align-items: center;
      background-color: $overlay-bg;
      display: flex;
      height: 100vh;
      justify-content: center;
      left: 0;
      opacity: 1;
      overflow: auto;
      padding: 0 10px;
      position: fixed;
      top: 0;
      width: 100vw;
    }

    .vscomp-dropbox {
      margin-top: math.div(($dropbox-close-button-width + $dropbox-close-button-offset), -2);
      max-height: calc(80% - #{$dropbox-close-button-width + $dropbox-close-button-offset});
      max-width: 500px;
      position: relative;
      width: 80%;
    }

    .vscomp-dropbox-close-button {
      display: flex;
    }
  }

  &.popup-position-left {
    .vscomp-dropbox-container {
      justify-content: flex-start;
    }
  }

  &.popup-position-right {
    .vscomp-dropbox-container {
      justify-content: flex-end;
    }
  }

  &.has-select-all {
    .vscomp-toggle-all-button {
      align-items: center;
      cursor: pointer;
      display: flex;
    }

    .vscomp-search-input,
    .vscomp-toggle-all-label {
      width: calc(100% - #{$search-clear-width + $checkbox-full-width});
    }

    .vscomp-toggle-all-label {
      display: none;
    }
  }

  &:not(.has-search-input) {
    .vscomp-toggle-all-button {
      width: 100%;
    }

    .vscomp-toggle-all-label {
      display: inline-block;
    }
  }

  &.multiple {
    .vscomp-option {
      .vscomp-option-text {
        width: calc(100% - #{$checkbox-full-width});
      }

      .vscomp-option-description {
        padding-left: $checkbox-full-width;
      }

      &.selected .checkbox-icon::after {
        @include checkbox-checked;
      }
    }
  }

  &.focused,
  &:focus {
    .vscomp-toggle-button {
      box-shadow: $box-shadow1;
    }
  }

  &.closed {
    .vscomp-dropbox-container,
    &.vscomp-dropbox-wrapper {
      display: none;
    }
  }

  &:not(.has-value) {
    .vscomp-value {
      opacity: 0.5;
    }
  }

  &.has-clear-button {
    &.has-value .vscomp-clear-button {
      display: flex;
    }

    .vscomp-toggle-button {
      padding-right: #{$arrow-width + $clear-button-width};
    }
  }

  &.has-no-options,
  &.has-no-search-results {
    .vscomp-options-container {
      display: none;
    }
  }

  &.has-no-options {
    .vscomp-no-options {
      display: flex;
    }
  }

  &.has-no-search-results {
    .vscomp-no-search-results {
      display: flex;
    }
  }

  &.has-search-value {
    .vscomp-search-clear {
      visibility: visible;
    }
  }

  &.has-no-options {
    .vscomp-toggle-all-button {
      opacity: 0.5;
      pointer-events: none;
    }
  }

  &.keep-always-open {
    .vscomp-toggle-button {
      padding-right: $clear-button-width;
    }

    .vscomp-clear-button {
      right: 5px;
    }

    .vscomp-arrow {
      display: none;
    }

    .vscomp-dropbox-container {
      position: relative;
      z-index: $z-index;
    }

    .vscomp-dropbox {
      @include prefix(transition-duration, 0s);
      border: 1px solid $border-color;
      box-shadow: none;
    }

    &.focused,
    &:focus,
    &:hover {
      box-shadow: $box-shadow1;
    }
  }

  &.server-searching {
    .vscomp-options-list {
      display: none;
    }

    .vscomp-options-loader {
      display: block;
    }
  }

  &.has-error {
    .vscomp-toggle-button {
      border-color: $error-color;
    }
  }

  &.show-value-as-tags {
    .vscomp-toggle-button {
      padding: 4px 22px 0 10px;
    }

    .vscomp-value {
      display: flex;
      flex-wrap: wrap;
      height: auto;
      min-height: 28px;
      overflow: auto;
      text-overflow: unset;
      white-space: normal;
    }

    .vscomp-value-tag {
      @include ellipse;
      align-items: center;
      border: 1px solid #ddd;
      border-radius: 20px;
      display: inline-flex;
      font-size: 12px;
      line-height: 16px;
      margin: 0 4px 4px 0;
      max-width: 100%;
      padding: 2px 3px 2px 8px;

      &.more-value-count {
        padding-right: 8px;
      }
    }

    .vscomp-value-tag-content {
      @include ellipse;
      width: calc(100% - #{$value-tag-clear-width});
    }

    .vscomp-value-tag-clear-button {
      align-items: center;
      display: flex;
      height: $value-tag-clear-width;
      justify-content: center;
      width: $value-tag-clear-width;

      .vscomp-clear-icon {
        transform: scale(0.8);
      }
    }

    .vscomp-arrow {
      height: 34px;
    }

    .vscomp-clear-button {
      margin-top: 0;
      top: 5px;
    }

    &.has-value {
      .vscomp-arrow {
        display: none;
      }

      .vscomp-clear-button {
        right: 2px;
      }
    }

    &:not(.has-value) {
      .vscomp-toggle-button {
        padding-bottom: 2px;
      }

      .vscomp-value {
        align-items: center;
        padding-bottom: 3px;
      }
    }
  }
}
