@use "sass:math";
@use "sass:color";

// Default variables
$font_size: 14px !default;
$font_size_small: 12px !default;

$input_border_radius: 5px !default;
$input_height: 38px !default;
$input_height_small: 36px !default;
$dropdown_padding: 18px !default;

$gray_dark: #444 !default;
$gray: #999 !default;
$gray_light: #e8e8e8 !default;
$gray_lighter: #f6f6f6 !default;
$primary_light: $gray !default;
$arrow_color: $gray !default;

// Style the dropdown
.nice-select {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  background-color: #fff;
  border-radius: $input_border_radius;
  border: solid 1px $gray_light;
  box-sizing: border-box;
  clear: both;
  cursor: pointer;
  display: block;
  // float: left;
  width: fit-content;
  font-family: inherit;
  font-size: $font_size;
  font-weight: normal;
  height: $input_height;
  line-height: $input_height - 2;
  outline: none;
  padding-left: $dropdown_padding;
  padding-right: $dropdown_padding + 12;
  position: relative;
  text-align: left !important;
  transition: all 0.2s ease-in-out;
  user-select: none;
  white-space: nowrap;

  &:hover {
    border-color: color.adjust($gray_light, $lightness: -5%);
  }

  &:active, &:focus {
    border-color: $primary_light;
  }

  // Arrow
  &:after {
    border-bottom: 2px solid $arrow_color;
    border-right: 2px solid $arrow_color;
    content: "";
    display: block;
    height: 5px;
    margin-top: -4px;
    pointer-events: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform-origin: 66% 66%;
    transform: rotate(45deg);
    transition: all 0.15s ease-in-out;
    width: 5px;
  }

  &.open {
    border-color: $primary_light;
    &:after {
      transform: rotate(-135deg);
    }
    .nice-select-dropdown {
      opacity: 1;
      pointer-events: auto;
      transform: scale(1) translateY(0);
    }
  }

  &.disabled {
    border-color: color.adjust($gray_light, $lightness: 2%);
    color: $gray;
    pointer-events: none;
    &:after {
      border-color: color.adjust($arrow_color, $lightness: 20%);
    }
  }

  // Modifiers
  &.wide {
    width: 100%;
    .nice-select-dropdown {
      left: 0 !important;
      right: 0 !important;
    }
  }

  &.right {
    float: right;
    .nice-select-dropdown {
      left: auto;
      right: 0;
    }
  }

  &.small {
    font-size: $font_size_small;
    height: $input_height_small;
    line-height: $input_height_small - 2;
    &:after {
      height: 4px;
      width: 4px;
    }
    .option {
      line-height: $input_height_small - 2;
      min-height: $input_height_small - 2;
    }
  }

  .has-multiple {
    white-space: inherit;
    height: auto;
    padding: 7px 12px;
    min-height: 36px;
    line-height: 22px;

    span.current {
      border: 1px solid #ccc;
      background: #eee;
      padding: 0 10px;
      border-radius: 3px;
      display: inline-block;
      line-height: 24px;
      font-size: 14px;
      margin-bottom: 3px;
      margin-right: 3px;
    }

    .multiple-options {
      display: block;
      line-height: 24px;
      padding: 0;
    }
  }

  .nice-select-search-box {
    box-sizing: border-box;
    width: 100%;
    padding: 5px;
    pointer-events: none;
    border-radius: 5px 5px 0 0;
  }

  .nice-select-search {
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid $gray_light;
    border-radius: 3px;
    color: $gray_dark;
    display: inline-block;
    vertical-align: middle;
    padding: 7px 12px;
    margin: 0 10px 0 0;
    width: 100%;
    min-height: 36px;
    line-height: 22px;
    height: auto;
    outline: 0 !important;
    font-size: $font_size;
  }

  .nice-select-dropdown {
    margin-top: 4px;
    background-color: #fff;
    border-radius: $input_border_radius;
    box-shadow: 0 0 0 1px rgba($gray_dark, 0.11);
    pointer-events: none;
    position: absolute;
    top: 100%;
    left: 0;
    transform-origin: 50% 0;
    transform: scale(0.75) translateY(math.div($input_height, 2));
    transition: all 0.2s cubic-bezier(0.5, 0, 0, 1.25), opacity 0.15s ease-out;
    z-index: 9;
    opacity: 0;
    max-height: 230px;
    overflow-y: scroll;
    overflow-x: hidden;
  }

  // List and options
  .list {
    border-radius: $input_border_radius;
    box-sizing: border-box;
    padding: 0;

    &:hover .option:not(:hover) {
      background-color: transparent !important;
    }
  }

  .option {
    cursor: pointer;
    font-weight: 400;
    line-height: $input_height + 2;
    list-style: none;
    outline: none;
    padding-left: $dropdown_padding;
    padding-right: $dropdown_padding + 11;
    text-align: left;
    transition: all 0.2s;

    &:hover,
    &.focus,
    &.selected.focus {
      background-color: $gray_lighter;
    }

    &.selected {
      font-weight: bold;
    }

    &.disabled {
      background-color: transparent;
      color: $gray;
      cursor: default;
    }
  }

  .extra {
    float: right;
  }

  .optgroup {
    font-weight: bold;
  }
}

// Fallback for IE <= 10
.no-csspointerevents .nice-select {
  .nice-select-dropdown {
    display: none;
  }
  &.open {
    .nice-select-dropdown {
      display: block;
    }
  }
}

.nice-select .list::-webkit-scrollbar {
  width: 0;
}

.hidden-select{
  opacity: 0;
  width: 0;
  padding: 0;
  height: 0;
  font-size: 0;
  min-height: auto;
}

.select-selection-list {
    list-style: none;
    padding: 0;
    margin: 0;

  .select-selection {
      background-color: #e4e4e4;
      border: 1px solid #aaa;
      border-radius: 4px;
      box-sizing: border-box;
      display: inline-block;
      margin-left: 5px;
      margin-top: 5px;
      padding: 2px 5px;
      position: relative;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      vertical-align: bottom;
      white-space: nowrap;
  }

  button.remove-select-selection {
    height: 15px;
    width: 15px;
    line-height: 15px;
    padding: 0px;
    background-color: #bd2919;
    border-radius: 20%;
  } 
}