@import '../../../style/mixins/index';
@import '../../input/style/mixin';

@import './single';
@import './multiple';

@select-prefix-cls: ~'@{vts-prefix}-select';
@select-height-without-border: @input-height-md - 2 * @border-width-base;
@select-dropdown-edge-child-vertical-padding: @dropdown-edge-child-vertical-padding;

.select-selector() {
  position: relative;
  background-color: @select-background;
  border: @border-width-base @border-style-base @input-border-default;
  border-radius: @border-radius-base;
  transition: all 0.3s @ease-in-out;

  input {
    cursor: pointer;
  }
}

/* Reset search input style */
.select-search-input-without-border() {
  .@{select-prefix-cls}-selection-search-input {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    outline: none;
    appearance: none;

    &::-webkit-search-cancel-button {
      display: none;
      -webkit-appearance: none;
    }
  }
}

.@{select-prefix-cls} {
  .reset-component();
  position: relative;
  display: inline-block;
  cursor: pointer;

  .state-for-child(~'@{select-prefix-cls}-selector');

  &&-disabled:not(&-customize-input) &-selector {
    color: @control-color-disable;
    background-color: @input-bg-disable;
    cursor: not-allowed;
    opacity: 1;
    border-color: @input-bg-disable;

    .@{select-prefix-cls}-selection-search-input {
      cursor: not-allowed;
    }
  }

  &:not(&-customize-input) &-selector {
    .select-selector();
    .select-search-input-without-border();
  }

  &:not(&-disabled):hover &-selector {
    .hover();
  }

  // ======================== Selection ========================
  &-selection-item {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;

    // IE11 css hack. `*::-ms-backdrop,` is a must have
    @media all and (-ms-high-contrast: none) {

      *::-ms-backdrop,
      & {
        flex: auto;
      }
    }
  }

  // ======================= Placeholder =======================
  &-selection-placeholder {
    flex: 1;
    overflow: hidden;
    color: @input-placeholder-color;
    white-space: nowrap;
    text-overflow: ellipsis;
    pointer-events: none;

    // IE11 css hack. `*::-ms-backdrop,` is a must have
    @media all and (-ms-high-contrast: none) {

      *::-ms-backdrop,
      & {
        flex: auto;
      }
    }
  }

  // ========================== Arrow ==========================
  &-arrow {
    .iconfont-mixin();
    position: absolute;
    top: 50%;
    right: @input-padding-horizontal-md;
    width: @icon-font-size-md;
    height: @icon-font-size-md;
    font-size: @icon-font-size-md;
    color: @control-suffix-icon-color;
    line-height: 1;
    text-align: center;
    transform: translateY(-50%);
    display: inline-flex;
    justify-content: center;
    align-items: center;

    .@{select-prefix-cls}-disabled & {
      cursor: not-allowed;
      pointer-events: none;
      color: @control-suffix-icon-disabled-color;
    }

    &:hover {
      color: @control-suffix-icon-hover-color;
    }
  }

  // ========================== Clear ==========================
  &-clear {
    position: absolute;
    top: 50%;
    right: @input-padding-horizontal-md + @icon-font-size-md;
    width: @icon-font-size-md;
    height: @icon-font-size-md;
    font-size: @icon-font-size-md;
    color: @control-suffix-icon-color;
    z-index: 1;
    display: inline-block;
    margin-top: (-@font-size-sm / 2);
    font-size: @font-size-sm;
    font-style: normal;
    line-height: 1;
    text-align: center;
    text-transform: none;
    cursor: pointer;
    transition: color 0.3s ease, opacity 0.15s ease;
    text-rendering: auto;

    &::before {
      display: block;
    }

    &:hover {
      color: @control-suffix-icon-hover-color;
    }

    .@{select-prefix-cls}:hover & {
      opacity: 1;
    }
  }

  // ========================== Popup ==========================
  &-dropdown {
    .reset-component();
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: @zindex-dropdown;
    box-sizing: border-box;
    overflow: hidden;
    font-size: @font-size-base;
    // Fix select render lag of long text in chrome
    // https://github.com/ant-design-git/ant-design-git/issues/11456
    // https://github.com/ant-design-git/ant-design-git/issues/11843
    font-variant: initial;
    background-color: @select-dropdown-bg;
    border-radius: @border-radius-base;
    outline: none;
    box-shadow: @input-box-shadow-md;

    &-single.@{select-prefix-cls}-dropdown-xl {
      box-shadow: @input-box-shadow-xl;
    }

    &-single.@{select-prefix-cls}-dropdown-lg {
      box-shadow: @input-box-shadow-lg;
    }

    &-single.@{select-prefix-cls}-dropdown-md {
      box-shadow: @input-box-shadow-md;
    }

    &-single.@{select-prefix-cls}-dropdown-sm {
      box-shadow: @input-box-shadow-sm;
    }


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

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

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

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

    &-hidden {
      display: none;
    }

    &-empty {
      color: @disabled-color;
    }
  }

  // ========================= Options =========================
  .item() {
    position: relative;
    display: block;
    min-height: @select-dropdown-line-height;
    padding: @select-dropdown-vertical-padding @control-padding-horizontal;
    color: @text-color;
    font-weight: normal;
    font-size: @select-dropdown-font-size;
    line-height: @select-dropdown-line-height;
  }

  &-item-empty {
    .item();
    color: @disabled-color;
  }

  &-item {
    .item();

    cursor: pointer;
    align-items: center;
    transition: background 0.3s ease;

    // =========== Group ============
    &-group {
      color: @text-color-secondary;
      font-size: @font-size-sm;
      cursor: default;
    }

    // =========== Option ===========
    &-option {
      display: flex;

      &-content {
        flex: auto;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      &-state {
        flex: none;
      }

      &&-active:not(&-disabled) {
        background-color: @select-item-active-bg;
      }

      &-selected:not(&-disabled) {
        color: @select-item-selected-color;
        font-weight: @select-item-selected-font-weight;
        background-color: @select-item-selected-bg;

        .@{select-prefix-cls}-item-option-state {
          color: @select-check-color;
        }
      }

      &-disabled {
        color: @disabled-color;
        cursor: not-allowed;
      }

      &-grouped {
        padding-left: @control-padding-horizontal * 2;
      }
    }
  }

  // Custom
  &-dropdown-single &-item-option-selected {
    border: @select-item-selected-border;
  }

  // ============================================================
  // ==                          Size                          ==
  // ============================================================
  &-lg {
    font-size: @font-size-lg;
  }

  // no border style
  &-borderless &-selector {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }
}

@import './rtl';