/**
 * Select Style
 */

@import '../mixins/index.scss';

/**
 * AtSelect
 */
.at-select {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 80px;
  color: $select-font-color;
  font-size: $font-size-base;
  line-height: 1.5;
  vertical-align: middle;

  .at-select__input {
    width: 100%;
    border: none;
    outline: none;
    position: absolute;
    left: 0;
    top: 0;
    margin: 0 24px 0 8px;
    background-color: transparent;

    &::placeholder {
      color: $input-placeholder-color;
    }
  }

  &--open {
    .at-select__arrow {
      transform: rotate(180deg);
    }
  }

  /* element */
  &__selection {
    position: relative;
    display: block;
    padding: $select-padding-base;
    outline: none;
    line-height: $select-selection-height-sm;
    border: 1px solid $border-color-base;
    border-radius: $border-radius-base;
    background-color: $color-white;
    transition: all .3s;
    cursor: pointer;
    min-height: $select-selection-height-sm;
    overflow: hidden;

    &__ul {
      list-style: none;
      &__tag {
        color: rgba(0, 0, 0, .65);
        background-color: #fafafa;
        border: 1px solid #e8e8e8;
        border-radius: 2px;
        cursor: default;
        float: left;
        margin-right: 4px;
        max-width: 99%;
        position: relative;
        overflow: hidden;
        transition: padding .3s cubic-bezier(.645, .045, .355, 1);
        padding: 0 10px 0 10px;
        line-height: 26px;
        margin-top: 1px;
      }
    }

    &:hover {
      border-color: $select-border-c-hover;

      .at-select__arrow {
        display: inline-block;
      }
      .at-select__clear {
        display: inline-block;
      }
    }
  }
  &__selected {
    @include ellipsis();
    display: block;
    padding-left: 6px;
  }
  &__arrow {
    display: inline-block;
    position: absolute;
    top: 50%;
    right: 8px;
    margin-top: -5px;
    font-size: 10px;
    cursor: pointer;
    transition: transform .3s;
  }
  &__clear {
    display: none;
    position: absolute;
    top: 50%;
    right: 8px;
    margin-top: -5px;
    font-size: 10px;
    cursor: pointer;
  }
  &__placeholder {
    color: $input-placeholder-color;
  }
  &__dropdown {
    width: 100%;
    position: relative;
    font-size: $select-dropdown-font-size-base;
    border-radius: $border-radius-base;
    background-color: $select-dropdown-bg-color;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    z-index: $zindex-dropdown;

    .at-select__list {
      list-style: none;
      padding: 0;
      font-size: 0;
    }
    .at-select__not-found {
      padding: $dropdown-option-padding-base;
    }
    .at-select__option {
      @include ellipsis();
      width: 100%;
      padding: $dropdown-option-padding-base;
      font-size: $select-dropdown-font-size-base;
      line-height: 1.5;
      white-space: nowrap;
      transition: all .3s;
      overflow: hidden;
      cursor: pointer;

      &--selected {
        font-weight: bold;
        background-color: $dropdown-option-bg-c-selected;
      }
      &:hover,
      &--focus {
        background-color: $dropdown-option-bg-c-hover;
      }
      &--disabled {
        color: $input-placeholder-color-disabled;
      }
    }
    &--bottom {
      margin-top: 2px;
    }
    &--top {
      margin-bottom: 2px;
    }
    &--left {
      margin-right: 2px;
    }
    &--right {
      margin-left: 2px;
    }
  }

  &-search-inline {
    border: none !important;
    outline: none !important;
    left: 0 !important;
    top: 0 !important;
    display: inline-block !important;
    margin: 0 24px 0 8px !important;
    background-color: transparent !important;
  }

  /* modifier */
  &--visible {
    .at-select__arrow {
      transform: rotate(180deg);
    }
  }
  &--show-clear {
    .at-select__selection:hover {
      .at-select__arrow {
        opacity: 0;
      }
    }
  }
  &--disabled {
    .at-select__selection {
      cursor: $cursor-disabled;
      background-color: $select-selection-bg-color-disabled;

      &:hover {
        border-color: $select-border-c-disabled;
      }
    }
    .at-select__placeholder,
    .at-select__selected {
      color: $input-placeholder-color-disabled;
      line-height: 30px;
    }
  }
  &--multiple {
    .at-tag {
      margin: 4px 4px 0 0;
    }
    .at-tag__text {

    }
  }
  &--normal {
    .at-select__selection {
      height: $select-selection-height-base;
      line-height: $select-selection-height-base - 2;
    }
    .at-select__dropdown .at-select__option {
      font-size: $select-dropdown-font-size-base;
    }
  }
  &--small {
    font-size: $select-font-size-sm;

    .at-select__selection {
      height: $select-selection-height-sm;
      line-height: $select-selection-height-sm - 2;
      &__ul {
        &__tag {
          line-height: $select-selection-height-sm - 6;
          margin-top: 1px;
        }
      }
    }
    .at-select__dropdown .at-select__option {
      font-size: $select-dropdown-font-size-sm;
    }
  }
  &--large {
    font-size: $select-font-size-lg;

    .at-select__selection {
      min-height: $select-selection-height-lg;
      line-height: $select-selection-height-lg - 2;
      &__ul {
        &__tag {
          line-height: $select-selection-height-lg - 8;
          margin-top: 2px;
        }
      }
    }
    .at-select__dropdown .at-select__option {
      font-size: $select-dropdown-font-size-lg;
    }
  }
}

/**
 * AtOptionGroup
 */
.at-option-group {
  padding: 0;

  &__label {
    @include ellipsis();
    width: 100%;
    padding: 8px;
    color: $option-group-font-c;
    font-size: $select-dropdown-font-size-base;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    transition: all .3s;
    cursor: initial;
  }
  &__list {
    padding: 0;
  }
}

.at-select-selection__placeholder {
  position: absolute;
  top: 50%;
  left: 0;
  right: 9px;
  color: #bfbfbf;
  line-height: 20px;
  height: 20px;
  max-width: 100%;
  margin-top: -10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  cursor: text;
  padding-left: 8px;
  z-index: 1;
}
