// @import "./variables.scss";

.#{$namespace}autocomplete {
  display: inline-block;

  .#{$namespace}base-dropdown-content {
    width: 100%;
  }
  &-loading{
    pointer-events: none;
    height: $autocomplete-loading-height;
    text-align: center;
    &:before {
      content: '';
      display: inline-block;
      height: 1em;
      width: 1em;
      border-radius: .5em;
      line-height: $autocomplete-loading-before-line-height;
      vertical-align: -0.15em;
      border: 1px solid currentColor;
      border-top-color: rgba(255, 255, 255, .35);
      margin-right: $unit-1;
      animation: loading .5s infinite linear;
    }
    
    &:after {
      pointer-events: none;
      content: "";
      border-radius: inherit;
      position: absolute;
      right: 8px;
      top: $autocomplete-loading-after-top;
      background-color: rgba(255, 255, 255, .35);
    }
  }
}
.#{$namespace}autocomplete-suggestion {
  max-height: $autocomplete-suggestion-max-height;
  overflow: auto;
  padding-top: 5px;
  padding-bottom: 5px;
  border-radius: $autocomplete-suggestion-border-radius;
  background-color: #fff;
  box-shadow: 0 1px 3px 0 rgba(130, 125, 124, 0.2);
  cursor: pointer;
  white-space: nowrap;

  .#{$namespace}autocomplete-item {
    padding: 2px 12px;
    line-height: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    &:hover {
      background-color: $autocomplete-item-hover-bg-color;
    }
    &.#{$namespace}autocomplete-item-hover {
      background-color: $autocomplete-item-hover-bg-color;
    }
    &.#{$namespace}autocomplete-item-active {
      color: $autocomplete-item-active-color;
    }

    .#{$namespace}autocomplete-highlighted {
      color: $autocomplete-item-highlighted-color;
    }

    .#{$namespace}autocomplete-subtitle {
      color: $autocomplete-item-subtitle-color;
    }
  }

  .#{$namespace}suggestion-empty {
    display: flex;
    justify-content: center;
    padding: 15px 12px;
    color: $autocomplete-suggestion-empty-color;
  }
}

// 兼容以前的
.#{$namespace}form-autocomplete {
  position: relative;
  min-width: $autocomplete-form-autocomplete-min-width;

  .#{$namespace}form-autocomplete-input {
    align-content: flex-start;
    display: flex;
    flex-wrap: wrap;
    height: auto;
    min-height: $autocomplete-form-autocomplete-input-min-height;
    padding: $autocomplete-form-autocomplete-input-padding;

    &.#{$namespace}form-input {
      line-height: normal;
    }

    &.#{$namespace}is-focused {
      // @include control-shadow();
      border-color: $autocomplete-form-autocomplete-input-focused-border-color;
    }

    .#{$namespace}form-input {
      border-color: transparent;
      box-shadow: none;
      display: inline-block;
      flex: 1 0 auto;
      height: $autocomplete-form-autocomplete-input-form-input-height;
      line-height: $autocomplete-form-autocomplete-input-form-input-line-height;
      margin: $autocomplete-form-autocomplete-input-form-input-margin;
      width: auto;
    }
  }

  .#{$namespace}menu {
    left: 0;
    position: absolute;
    top: calc(100% - 8px);
    width: 100%;
    min-width: $autocomplete-form-autocomplete-menu-min-width;
    padding: $autocomplete-form-autocomplete-menu-padding;

    .#{$namespace}menu-item {
      height: $autocomplete-form-autocomplete-menu-item-height;

      & > a {
        padding: $autocomplete-form-autocomplete-menu-item-a-padding;
      }

      .#{$namespace}tile {
        height: $autocomplete-form-autocomplete-menu-item-title-height;

        mark {
          background: transparent;
          color: $autocomplete-form-autocomplete-menu-item-mark-color;
        }
      }
    }
  }

  &.#{$namespace}autocomplete-oneline {
    .#{$namespace}form-autocomplete-input {
      flex-wrap: nowrap;
      overflow-x: auto;
    }

    .#{$namespace}chip {
      flex: 1 0 auto;
    }
  }
}

// react-autocomplete-DataItem
.#{$namespace}dataItem {
  display: block;
  height: auto;
  margin-bottom: 3px;
  padding-left: $autocomplete-dataItem-padding-left;
  padding-right: $autocomplete-dataItem-padding-right;

  &:hover {
    background-color: $autocomplete-dataItem-on-hover-bg-color;
  }
  
  &.#{$namespace}dataItem-hover {
    background-color: $autocomplete-dataItem-hover-bg-color; // 在select 样式文件中定义
  }
  &.#{$namespace}select-item-active {
    color: $autocomplete-dataItem-active-color;
  }

  &.#{$namespace}select-item-disabled {
    color: $autocomplete-dataItem-disabled-color;
    cursor: not-allowed;

    &:hover {
      background-color: $autocomplete-dataItem-disabled-hover-bg-color;
    }
  }
}
.#{$namespace}customContainer {
  font-size: $autocomplete-customContainer-font-size;
  line-height: $autocomplete-customContainer-line-height;
  color: $autocomplete-customContainer-color;
  &.#{$namespace}customContainer-disabled {
    color: $autocomplete-customContainer-disabled-color;
  }
}
.#{$namespace}skey {
  color: $autocomplete-skey-color;
}
