/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@select-dropdown-prefix-cls: ~'@{css-prefix}select-dropdown';
@select-prefix-cls: ~'@{css-prefix}select';
@tree-prefix-cls: ~'@{css-prefix}tree';
@popper-prefix-cls: ~'@{css-prefix}popper';
@scrollbar-prefix-cls: ~'@{css-prefix}scrollbar';
@input-prefix-cls: ~'@{css-prefix}input';
@option-prefix-cls: ~'@{css-prefix}option';

.@{select-dropdown-prefix-cls} {
  .component-css-vars-select-dropdown();

  position: absolute;
  z-index: 1001;
  border: var(--ti-select-dropdown-border-weight) var(--ti-select-dropdown-border-style)
    var(--ti-select-dropdown-border-color);
  border-radius: var(--ti-select-dropdown-border-radius);
  background-color: var(--ti-select-dropdown-bg-color);
  box-shadow: var(--ti-select-dropdown-box-shadow);
  margin-top: var(--ti-select-dropdown-margin-top);
  box-sizing: border-box;
  padding: var(--ti-select-dropdown-padding-top) var(--ti-select-dropdown-padding-horizontal)
    var(--ti-select-dropdown-padding-bottom);

  .@{tree-prefix-cls} {
    max-height: 300px;
    overflow-y: auto;
  }

  &.@{popper-prefix-cls} {
    margin-top: 2px;
  }

  & .@{scrollbar-prefix-cls}.is-empty {
    display: none;

    &__list {
      padding: 0;
    }
  }

  // 下拉面板搜索框
  & &__search {
    margin: var(--ti-select-dropdown-search-margin-top) var(--ti-select-dropdown-search-margin-right)
      var(--ti-select-dropdown-search-margin-bottom) var(--ti-select-dropdown-search-margin-left);
    width: var(--ti-select-dropdown-search-width);

    .@{input-prefix-cls}__inner {
      box-sizing: border-box;
      border-width: var(--ti-select-dropdown-search-border-width);
      background-color: var(--ti-select-dropdown-search-bg-color);
      padding-right: var(--ti-select-dropdown-search-input-padding-right);
      padding-left: var(--ti-select-dropdown-search-input-padding-left);
      border-radius: var(--ti-select-dropdown-search-border-radius);
      border-top-color: var(--ti-select-dropdown-search-border-color-top);
      border-left-color: var(--ti-select-dropdown-search-border-color-left);
      border-right-color: var(--ti-select-dropdown-search-border-color-right);
    }

    .@{input-prefix-cls}__suffix {
      display: var(--ti-select-dropdown-search-suffix-display);

      .tiny-svg {
        font-size: var(--ti-select-dropdown-icon-size);
        fill: var(--ti-select-dropdown-icon-color);
      }

      &-inner {
        width: auto;
        height: auto;
      }
    }

    .@{input-prefix-cls}__prefix {
      display: var(--ti-select-dropdown-search-prefix-display);

      .tiny-svg {
        font-size: var(--ti-select-dropdown-icon-size);
        fill: var(--ti-select-dropdown-icon-color);
        margin-right: 4px;
      }

      &-inner {
        width: auto;
        height: auto;
      }
    }

    .tiny-icon-close {
      &::after {
        content: '';
        display: inline-block;
        height: var(--ti-select-dropdown-line-height);
        width: var(--ti-select-dropdown-line-width);
        background-color: var(--ti-select-dropdown-line-bg-color);
        line-height: 100%;
        vertical-align: middle;
        margin: var(--ti-select-dropdown-line-margin-vertical) var(--ti-select-dropdown-line-margin-horizontal);
      }
    }

    .tiny-svg:hover {
      fill: var(--ti-select-dropdown-svg-hover-bg-color);
    }

    & + div + .@{select-dropdown-prefix-cls}__empty-wrap {
      padding-top: var(--ti-select-dropdown-search-empty-padding-top);
      padding-bottom: var(--ti-select-dropdown-search-empty-padding-bottom);
    }

    & + .@{scrollbar-prefix-cls} {
      .@{select-dropdown-prefix-cls}__wrap {
        .tiny-option-group {
          &:first-child .tiny-option-group__title {
            margin-top: 0px;
          }
        }
      }
    }
  }

  &__loading {
    padding: var(--ti-select-dropdown-loading-padding-vertical) var(--ti-select-dropdown-loading-padding-horizontal);
    margin: 0;
    text-align: center;
    color: var(--ti-select-dropdown-empty-text-color);
    font-size: var(--ti-select-dropdown-empty-font-size);
    line-height: var(--ti-select-dropdown-empty-line-height);

    &-svg {
      height: 21px;
    }
  }

  &__empty-wrap {
    padding: var(--ti-select-dropdown-empty-padding-vertical) var(--ti-select-dropdown-empty-padding-horizontal);
    margin: 0;
    text-align: center;
    color: var(--ti-select-dropdown-empty-text-color);
    font-size: var(--ti-select-dropdown-empty-font-size);
    line-height: var(--ti-select-dropdown-empty-line-height);

    .@{select-dropdown-prefix-cls}__empty-images {
      background-image: url('../images/select-nodata.png');
      width: var(--ti-select-dropdown-empty-image-width);
      height: var(--ti-select-dropdown-empty-image-height);
      margin-bottom: var(--ti-select-dropdown-empty-image-margin-bottom);
      background-size: cover;
      background-repeat: no-repeat;
      display: inline-block;
      vertical-align: bottom;
    }
  }

  &__empty {
    text-align: center;
    color: #999;
    font-size: 14px;
  }

  & &__wrap {
    max-height: var(--ti-select-dropdown-max-height);
    margin-right: -4px;
    padding-bottom: var(--ti-select-dropdown-wrap-padding-bottom);
  }

  & &__list {
    list-style: none;
    margin: 0;
    box-sizing: border-box;
    padding-bottom: 6px;
    text-align: left;
  }

  & .@{option-prefix-cls} {
    padding: var(--ti-option-padding-vertical) var(--ti-option-padding-horizontal);
  }

  & &__wrap.virtual {
    position: relative;
    margin-right: 0 !important;

    & .@{option-prefix-cls} {
      position: absolute;
      width: 100%;
    }
  }

  & &__item {
    white-space: nowrap;
    box-sizing: border-box;
    padding: 0 8px;

    &.is-disabled {
      svg path:first-of-type {
        fill: #f5f5f5;
      }
    }
  }

  .@{select-prefix-cls}__top-create {
    margin: 0 8px 4px 8px;
    border-bottom: var(--ti-select-dropdown-top-create-border-weight-bottom)
      var(--ti-select-dropdown-top-create-border-style-bottom) var(--ti-select-dropdown-top-create-border-color-bottom);

    > div {
      width: fit-content;
      height: 32px;
      display: flex;
      align-items: center;
      font-size: 12px;
      line-height: 20px;
      color: var(--ti-select-dropdown-top-create-text-color);
      cursor: pointer;

      &:hover {
        color: var(--ti-select-dropdown-top-create-text-color-hover);
      }

      svg {
        fill: var(--ti-select-dropdown-top-create-icon-color);
        font-size: 14px;
        margin-right: 4px;
      }
    }
  }
}

@keyframes loading-rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loading-dash {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -40px;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -120px;
  }
}
