@import '../../../style/theme/default/index';
@import '../../../style/mixins/index';
@import '../../input/style/index';

@select-prefix-cls: ~'@{idoll-prefix}-select';

.selection__clear() {
    display: inline-block;
    font-style: normal;
    vertical-align: baseline;
    text-align: center;
    text-transform: none;
    text-rendering: auto;
    opacity: 0;
    position: absolute;
    right: 8px;
    z-index: 1;
    background: #fff;
    top: 50%;
    font-size: 12px;
    color: #ccc;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    line-height: 12px;
    cursor: pointer;
    transition: color 0.3s ease, opacity 0.15s ease;
    &:before {
      display: block;
      .iconfont-font("\e91c");
    }
    &:hover {
      color: #999;
    }
}

.@{select-prefix-cls} {
  box-sizing: border-box;
  display: inline-block;
  position: relative;
  vertical-align: middle;
  color: @select-color;
  font-size: @font-size-base;

  > ul > li > a {
      padding: 0;
      background-color: #fff;
  }

  // arrow
  &-arrow {
      .iconfont-mixin();
      position: absolute;
      top: 50%;
      right: 8px;
      line-height: 1;
      margin-top: -6px;
      .iconfont-size-under-12px(12px);

      * {
          display: none;
      }

      &:before {
        content: '\e926';
        transition: transform 0.2s ease;
      }
  }

  &-selection {
    outline: none;
    user-select: none;

    box-sizing: border-box;
    display: block;

    background-color: #fff;
    border-radius: @border-radius-base;
    border: 1px solid @border-color-base;
    transition: all .3s @ease-in-out;

    &:hover {
      .hover;
    }

    .@{select-prefix-cls}-focused &,
    &:focus,
    &:active {
       .active;
    }

    &__clear {
      .selection__clear();
    }

    &:hover &__clear {
      opacity: 1;
    }
  }

  &-disabled {
    color: #ccc;
  }

  &-disabled &-selection {
    background: #f7f7f7;
    cursor: not-allowed;
    &:hover,
    &:focus,
    &:active {
      border-color: @border-color-base;
      box-shadow: none;
    }

    &__clear {
      display: none;
      visibility: hidden;
      pointer-events: none;
    }
  }

  &-disabled &-selection--multiple &-selection__choice {
    background: #e9e9e9;
    color: #aaa;
    padding-right: 10px;
    &__remove {
      display: none;
    }
  }

  &-selection--single {
    height: @select-height-base;
    position: relative;
    cursor: pointer;

    .@{select-prefix-cls}-selection__rendered {
      height: @select-height-base - 2px;
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: @select-padding-vertical;
      padding-right: @select-padding-vertical + 14px;
      line-height: @select-height-base - 2px;
    }
  }

  &-open&-show-search &-selection--single &-selection-selected-value {
    position: absolute;
    left: @select-padding-vertical;
    top: 0;
  }

  &-open {
    .@{select-prefix-cls}-arrow:before {
      content: '\e929';
      transition: transform 0.2s ease;
    }
  }

  &-combobox {
    .@{select-prefix-cls}-arrow {
      display: none;
    }
    .@{select-prefix-cls}-search--inline {
      height: @select-height-base - 2px;
      width: 100%;
      float: none;
    }
    .@{select-prefix-cls}-search__field__wrap {
      width: 100%;
      height: 100%;
    }
    .@{select-prefix-cls}-search__field {
      width: 100%;
      height: 100%;
      position: relative;
      z-index: 1;
      transition: all .3s @ease-in-out;
      box-shadow: none;
    }
    .@{select-prefix-cls}-selection__rendered {
      padding: 0;
    }
    .@{idoll-prefix}-input {
      width: 100%;
      height: 100%;
      position: relative;
      z-index: 1;
      box-shadow: none;
      border: 0;
    }
  }

  &-combobox&-allow-clear &-selection:hover &-selection__rendered {
    margin-right: 20px; // In case that clear button will overlap content
  }

  &-lg {
    .@{select-prefix-cls}-selection--single {
      height: @select-height-lg;
      .@{select-prefix-cls}-selection__rendered {
        line-height: @select-height-lg - 2px;
      }
    }

    .@{select-prefix-cls}-selection--multiple {
      min-height: @select-height-base;
      .@{select-prefix-cls}-selection__rendered {
        li {
          height: @select-height-base - 8px;
          line-height: @select-height-base - 8px;
        }
      }
    }
  }

  &-sm {
    height: @select-height-sm;
    overflow: hidden;

    .@{select-prefix-cls}-selection {
      height: @select-height-sm;
      border-radius: @border-radius-sm;
      font-size: @select-font-size -2px;
    }
    .@{select-prefix-cls}-selection--single {
      height: @select-height-sm;
      .@{select-prefix-cls}-selection__rendered {
        height: @select-height-sm;
        line-height: @select-height-sm;
      }
    }
    .@{select-prefix-cls}-selection--multiple {
      min-height: @select-height-sm;
      .@{select-prefix-cls}-selection__rendered {
        li {
          height: @select-height-sm - 8px;
          line-height: @select-height-sm - 8px;
        }
      }
    }
  }

  &-disabled &-selection__choice__remove {
    color: #ccc;
    cursor: default;
    &:hover {
      color: #ccc;
    }
  }

  &-search__field__wrap {
    display: inline-block;
    position: relative;
  }

  &-selection__placeholder,
  &-search__field__placeholder { // for TreeSelect compatibility
    position: absolute;
    top: 50%;
    left: @select-padding-vertical + 1px;
    right: @select-padding-vertical + 1px;;
    color: #ccc;
    line-height: 20px;
    height: 20px;
    max-width: 100%;
    margin-top: -10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &-search--inline {
    float: left;
    width: 100%;
    height: 100%;

    .@{select-prefix-cls}-search__field__wrap {
      width: 100%;
      height: 100%;
    }

    .@{select-prefix-cls}-search__field {
      border: 0;
      font-size: 100%;
      width: 100%;
      height: 100%;
      background: transparent;
      outline: 0;
      border-radius: @border-radius-base;
    }

    .@{select-prefix-cls}-search__field__mirror {
      position: absolute;
      top: 0;
      left: 9999px;
      white-space: pre;
      pointer-events: none;
    }

    > i {
      float: right;
    }
  }

  &-selection--multiple {
    min-height: 28px;
    cursor: text;

    .@{select-prefix-cls}-search--inline {
      width: auto;
      .@{select-prefix-cls}-search__field {
        border: none;
        outline: none;
        width: 0.75em;
      }
    }

    .@{select-prefix-cls}-selection__rendered {
      overflow: hidden;
      text-overflow: ellipsis;
      padding-left: @select-padding-vertical;
      padding-bottom: 4px;
    }

    ul {
        padding: 0;
        margin: 0;
    }

    > ul > li,
    .@{select-prefix-cls}-selection__rendered > ul > li {  // for tree-select
      margin-top: 4px;
      height: 20px;
      line-height: 20px;
    }

    .@{select-prefix-cls}-selection__choice {
      background-color: #f3f3f3;
      border-radius: 4px;
      cursor: default;
      float: left;
      padding: 0 @select-option-padding-horizontal;
      margin-right: 4px;
      max-width: 99%;
      position: relative;
      overflow: hidden;
      transition: padding .3s @ease-in-out;
      padding: 0 20px 0 10px;
      &__disabled {
        padding: 0 10px;
      }
    }

    .@{select-prefix-cls}-selection__choice__content {
      display: inline-block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
      transition: margin .3s @ease-in-out;
    }

    .@{select-prefix-cls}-selection__choice__remove {
      .iconfont-mixin();
      color: #999;
      line-height: inherit;
      cursor: pointer;
      display: inline-block;
      font-weight: bold;
      transition: all 0.3s @ease-in-out;
      .iconfont-size-under-12px(8px);
      position: absolute;
      right: 4px;
      padding: 0 0 0 8px;
      &:hover {
        color: #404040;
      }
      &:before {
        content: "\e91c";
      }
    }
  }

}

.@{select-prefix-cls}-dropdown {
    &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft {
      animation-name: idollSlideUpIn;
    }

    &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
    &.slide-up-appear.slide-up-appear-active&-placement-topLeft {
      animation-name: idollSlideDownIn;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft {
      animation-name: idollSlideUpOut;
    }

    &.slide-up-leave.slide-up-leave-active&-placement-topLeft {
      animation-name: idollSlideDownOut;
    }

    &-hidden {
      display: none;
    }

    background-color: white;
    border: 1px solid @border-color-base;
    box-shadow: @box-shadow-base;
    border-radius: @border-radius-base;
    box-sizing: border-box;
    z-index: @zindex-dropdown;
    left: -9999px;
    top: -9999px;
    position: absolute;
    outline: none;
    overflow: hidden;
    font-size: @font-size-base;

    &-menu {
      outline: none;
      margin-top: 0;
      margin-bottom: 0;
      padding-left: 0; // Override default ul/ol
      list-style: none;
      max-height: 250px;
      overflow: auto;

      &-item-group-list {
        margin: 0;
        padding: 0;

        > .@{select-prefix-cls}-dropdown-menu-item {
          padding-left: 24px;
        }
      }

      &-item-group-title {
        color: #999;
        line-height: 1.5;
        padding: 8px 15px;
      }

      &-item {
        height: @select-height-base;
        line-height: @font-size-base;
        position: relative;
        display: block;
        padding: @select-option-padding-horizontal @select-option-padding-vertical;
        font-weight: normal;
        color: #666;
        white-space: nowrap;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        font-size: @font-size-base;
        transition: background 0.3s ease;

        &:hover,
        &-active {
          background-color: @option-hover-bg;
          color: @select-hover-color;
        }

        &-disabled {
          color: #ccc;
          cursor: not-allowed;

          &:hover {
            color: #ccc;
            background-color: #fff;
            cursor: not-allowed;
          }
        }

        &-selected {
          &,
          &:hover {
            background-color: @option-selected-bg;
            color: @select-selected-color;
          }
        }

        &-divider {
          height: 1px;
          margin: 1px 0;
          overflow: hidden;
          background-color: #e5e5e5;
          line-height: 0;
        }
      }
    }

    &&--multiple {
      .@{select-prefix-cls}-dropdown-menu-item {
        &:after {
          .iconfont-font("\e919");
          color: transparent;
          .iconfont-size-under-12px(10px);
          transition: all 0.2s ease;
          position: absolute;
          right: @select-option-padding-vertical;
          font-weight: bold;
          text-shadow: 0 0.1px 0, 0.1px 0 0, 0 -0.1px 0, -0.1px 0;
        }

        &:hover:after {
          color: #ddd;
        }

        &-disabled:after {
          display: none;
        }

        &-selected:after,
        &-selected:hover:after {
          color: @primary-color;
          display: inline-block;
        }
      }
    }

    &-container-open,
    &-open {
      .@{select-prefix-cls}-dropdown {
        display: block;
      }
    }

    .@{select-prefix-cls}-dropdown-search {
      display: block;
      padding: 4px;
      .@{select-prefix-cls}-search__field__wrap {
        width: 100%;
      }
      .@{select-prefix-cls}-search__field {
        padding: 4px @select-padding-vertical;
        padding-right: @select-padding-vertical + 14px;
        width: 100%;
        box-sizing: border-box;
        border: 1px solid @border-color-base;
        border-radius: 4px;
        outline: none;
      }
      &.@{select-prefix-cls}-search--hide {
        display: none;
      }
    }
  }

