@import '../dao-color.scss';
$select-color: $black-dark;
$select-default-color: $grey-dark;
$select-focus-color: $black-light;
$select-border-radius: 4px;
$select-border-color: $grey-light;
$select-bg-img: linear-gradient(to top, rgba(61, 68, 79, .05) 0%, rgba(61, 68, 79, 0) 100%);
$select-bg-color: $white-light;
$select-disabled-color: $grey-light;

.dao-select {
  display: inline-block;
  width: 287px;
  position: relative;
  height: 32px;
  background: $white;
  .dao-select-main {
    color: $select-color;
    position: relative;
    display: inline-block;
    width: 100%;
    height: 100%;
    .dao-select-switch {
      width: 100%;
      display: flex;
      overflow: hidden;
      border: 1px solid $select-border-color;
      border-radius: $select-border-radius;
      height: 100%;
      justify-content: center;
      align-items: center;
      background-image: $select-bg-img;
      cursor: pointer;
      &-text {
        height: 100%;
        padding: 0 10px;
        flex: 1;
        overflow: hidden;
        display: inline-flex;
        white-space: nowrap;
        align-items: center;
        user-select: none;
      }
      .icon-box {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding-right: 8px;
        .icon {
          width: 16px;
          height: 16px;
          vertical-align: baseline;
          fill: $select-default-color;
        }
      }
      &:hover {
        background-color: rgba(204, 209, 217, 0.1);
      }
      &.open {
        background-color: rgba(204, 209, 217, 0.15);
        box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.06), inset 0px 0px 4px 0px rgba(0, 0, 0, 0.08);
        background-image: none;
      }
      &:hover,&.open {
        .icon-box .icon{
          fill: $select-focus-color;
        }
      }
    }
    .placeholder {
      color: $select-default-color;
    }
    .selected-text {
      line-height: 24px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    &.with-btn {
      display: flex;
      .dao-select-switch {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-right: none;
      }
      .dao-select-btn {
        flex-grow: 0;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        height: 32px;
      }
    }
    &.disabled {
      cursor: not-allowed!important;
      .dao-select-switch {
        cursor: not-allowed!important;
        &:hover {
          background-color: transparent;
          background-image: $select-bg-img;
        }
        &-text * {
          color: $select-disabled-color;
        }
        svg {
          fill: $select-disabled-color!important;
        }
        .switch-loading {
          display: flex;
          align-items: center;
          .loading {
            animation: loading 1.5s linear infinite;
          }
          .loading-text {
            margin-left: 6px;
          }
        }
      }
    }
  }
  &.sm-select {
    height: 26px;
    width: 200px;
    .dao-select-switch {
      border-radius: 3px;
      &-text {
        padding: 0 5px;
      }
      .icon-box {
        padding-right: 5px;
        padding-left: 5px;
      }
    }
  }
}

.dao-select .dao-select-dropdown,
.dao-select-dropdown.append-to-body.dao-select-popper{
  position: absolute;
  //width: 100%;
  padding: 5px 0;
  list-style: none;
  border-radius: 5px;
  background-color: $white;
  box-shadow: 0 0 0 1px rgba($black-dark, .06), 0 5px 12px 0 rgba($black-dark, .3);
  max-height: 200px;
  overflow: auto;
  z-index: 1000;
  &.withSearch {
    padding-top: 0;
    overflow: hidden;
    max-height: none;
    .option-list {
      max-height: 200px;
      overflow: auto;
    }
    .dao-select-category:nth-of-type(1) .dao-select-category-label {
      border-top: none;
    }
  }
  .dao-tab .dao-tab__header {
    background-color: $select-bg-color;
    padding: 10px 0 0;
    margin-top: 0px;
    border-top-left-radius: $select-border-radius;
    border-top-right-radius: $select-border-radius;
  }
  &.withTab {
    max-height: none;
    padding-top: 0;
    .dao-select-category:first-child .dao-select-category-label {
      border-top: none;
    }
    .dao-tab-item {
      max-height: 200px;
      overflow-y: auto;
      margin: 0;
      padding: 0;
    }
  }
  // 解决在同时有 search 和 tab 时会有两个 scroll bar 的问题
  &.withSearch.withTab {
    .option-list {
      max-height: none;
    }
  }
  &-options.withTab.withSearch {
    .search-container {
      margin-bottom: -1px;
    }
  }
  .search-container {
    background-color: $select-bg-color;
    padding: 10px 10px;
    border-top-left-radius: $select-border-radius;
    border-top-right-radius: $select-border-radius;
    border-bottom: 1px solid #e4e7ed;
    input.dao-control.search {
      width: 100%;
    }
  }
}
