$frost-input-select-option-row-height: 35px;
$frost-input-select-option-with-secondary-labels-row-height: 45px;
$frost-select-arrow-box-shadow: 0 0 7px 3px transparentize($frost-select-container-shadow, .4);
$frost-select-disabled-background-color: $frost-color-lgrey-3;
$frost-select-disabled-border-color: $frost-color-lgrey-1;
$frost-select-disabled-color: $frost-color-grey-6;
$frost-select-dropdown-box-shadow: 0 2px 7px 3px transparentize($frost-select-container-shadow, .4);
$frost-select-error-border-color: $frost-color-danger;
$frost-select-focused-border-color: $frost-color-blue-1;
$frost-select-height: 35px;
$frost-select-normal-border-color: $frost-color-grey-7;
$frost-select-placeholder-color: $frost-color-grey-6;
$frost-checkbox-medium-width: 32px;
$frost-select-list-item-horizontal-padding: 10px;

@mixin triangle-down($color, $size) {
  width: 25px;
  height: 0;
  border-top: $size solid $color;
  border-right: $size solid transparent;
  border-left: $size solid transparent;
}

@mixin triangle-up($color, $size) {
  width: 25px;
  height: 0;
  border-right: $size solid transparent;
  border-bottom: $size solid $color;
  border-left: $size solid transparent;
}

.frost-select {
  display: flex;
  position: relative;
  align-items: center;
  min-width: 175px;
  height: $frost-select-height;
  border: 1px solid $frost-select-normal-border-color;
  background-color: $frost-color-white;
  cursor: pointer;

  polygon {
    fill: $frost-select-indicator;
  }

  svg {
    position: absolute;
    top: 7px;
    right: 10px;
    width: 20px;
    height: 20px;
  }
}

.frost-select-clear {
  float: right;
}

.frost-select-disabled {
  border-color: $frost-select-disabled-border-color;
  background-color: $frost-select-disabled-background-color;
  color: $frost-select-disabled-color;
}

.frost-select-down-arrow {
  @include triangle-down($frost-select-container-background, 12px);
  display: inline-block;
  position: fixed;
  overflow: visible;
  z-index: 9003;
  pointer-events: none;
}

.frost-select-down-arrow-shadow {
  display: block;
  position: fixed;
  width: 25px;
  height: 25px;
  margin-bottom: 5px;
  transform: rotate(45deg);
  box-shadow: $frost-select-arrow-box-shadow;
  content: '';
  z-index: 9001;
  pointer-events: none;
}

.frost-select-dropdown-container {
  z-index: 9004;
}

.frost-select-dropdown-empty-msg {
  padding: 0 5px 5px;
  color: $frost-color-grey-3;
}

.frost-select-error {
  border-color: $frost-select-error-border-color;

  polygon {
    fill: $frost-select-indicator;
  }
}

.frost-select-focused {
  border-color: $frost-select-focused-border-color;
  outline: none;

  polygon {
    fill: $frost-select-focused-border-color;
  }
}

.frost-select-dropdown {
  display: flex;
  position: fixed;
  flex-direction: column;
  height: auto;
  transition: height .4s ease, opacity .2s ease;
  border: 1px solid $frost-color-lgrey-3;
  border-radius: 3px;
  background: $frost-select-container-background;
  box-shadow: $frost-select-dropdown-box-shadow;
  opacity: 1;
  z-index: 9002;
  pointer-events: auto;
  overflow-y: auto;

  ul {
    display: flex;
    flex-wrap: wrap;
    height: auto;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .frost-text {
    width: auto;
    min-width: auto;
    padding: 5px;
  }

  .frost-text-clear {
    top: 12px;
    right: 10px;
  }

  .multi-status {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    border-bottom: solid 5px $frost-color-lgrey-3;
    font-size: $frost-font-m;

    .number-selected {
      color: $frost-color-grey-5;
    }
  }

  &-wrap-labels {
    .frost-select-list-item {
      height: auto;
      min-height: $frost-input-select-option-row-height;
      white-space: normal;
    }
  }
}

.frost-select-list-item {
  display: flex;
  flex: 1 0 auto;
  width: 100%;
  height: $frost-input-select-option-row-height;
  padding: 0 5px;
  border-bottom: solid 1px $frost-color-lgrey-3;
  color: $frost-color-grey-3;
  line-height: $frost-input-select-option-row-height;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;

  .frost-checkbox {
    input {
      visibility: hidden;
    }
    position: relative;
    top: -2px;
    pointer-events: none;
    box-sizing: content-box;

    svg {
      top: 6px;
      left: 2px;
    }
  }

  u {
    color: $frost-color-grey-2;
  }
}

.frost-select-list-item-container {
  flex: 1;
}

.frost-select-list-secondary-item {
  min-height: $frost-input-select-option-with-secondary-labels-row-height;
  line-height: $frost-input-select-option-with-secondary-labels-row-height;

  .frost-select-list-item-text {
    min-height: $frost-font-m;
    padding-top: 5px;
    line-height: $frost-font-m;
  }

  .frost-select-list-secondary-item-text {
    min-height: $frost-font-s;
    padding-top: 2px;
    padding-bottom: 3px;
    color: $frost-color-grey-5;
    font-size: $frost-font-s;
    font-weight: 100;
    line-height: $frost-font-s;

    u {
      color: $frost-color-grey-3;
    }
  }

  .frost-checkbox {
    top: -2px;
  }

  &-wrap-labels {
    .frost-select-list-secondary-item {
      height: auto;
      min-height: $frost-font-m;
      white-space: normal;
    }
  }
}

.frost-select-list-item-focused {
  background: transparentize($frost-selection, .92);
}

.frost-select-list-item-selected {
  color: $frost-color-grey-2;
  font-weight: 500;
}

.frost-select-list-item-text {
  flex: 1 0 auto;

  &:not(.frost-multi-select-list-item-text) {
    max-width: calc(100% - #{$frost-select-list-item-horizontal-padding});
  }
}

.frost-multi-select-list-item-text {
  max-width: calc(100% - #{$frost-checkbox-medium-width} - #{$frost-select-list-item-horizontal-padding});
}

.frost-select-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9001;
}

.frost-select-placeholder {
  color: $frost-select-placeholder-color;
}

.frost-select-text {
  width: calc(100% - 30px);
  padding-left: 5px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.frost-select-up-arrow {
  @include triangle-up($frost-select-container-background, 12px);
  display: inline-block;
  position: fixed;
  overflow: visible;
  z-index: 9003;
  pointer-events: none;
}

.frost-select-up-arrow-shadow {
  display: block;
  position: fixed;
  width: 25px;
  height: 25px;
  margin-top: 8px;
  transform: rotate(45deg);
  box-shadow: $frost-select-arrow-box-shadow;
  content: '';
  z-index: 9001;
  pointer-events: none;
}
