/* stylelint-disable declaration-no-important */
@import '../styles/themes/themes.less';
@import '../styles/mixins/mixins.less';

@search-select-name: ~'@{bk-prefix}-search-select';

.@{search-select-name} {
  position: relative;
  z-index: 9;
  height: @component-size-base;
  overflow: inherit;

  .focus {
    color: @search-select-focus-color;
    background: #fff !important;
    border-color: @search-select-focus-border-color !important;
  }

  .div-input {
    flex: 1 1 auto;
    height: 100%;
    padding: 5px 0;
    line-height: 20px;
    word-break: break-all;

    &:focus {
      outline: none;
    }
  }

  &-container {
    box-sizing: border-box;
    // position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    min-height: 30px;
    overflow: hidden;
    font-size: 12px;
    color: @search-select-font-color;
    resize: none;
    border: @border-width-base @border-style-base @border-style-color;
    border-radius: @border-radius-base;
    outline: none;
    transition: border 0.2s linear;

    &.is-focus {
      overflow: auto;
      .focus();

      // .search-container-selected {
      //   margin-bottom: 2p;
      // }
    }

    .search-prefix {
      display: flex;
      flex: 0 0 auto;
      align-items: center;
      height: 100%;
    }

    .search-container {
      position: relative;
      display: flex;
      flex: 1;
      flex-wrap: wrap;
      align-items: center;
      max-width: calc(100% - 42px);
      min-height: 26px;
      padding: 0 2px;
      margin-top: 4px;
      overflow: visible;
      text-align: left;
      transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);

      &-selected {
        position: relative;
        display: inline-block;
        flex: 0 0 auto;
        align-self: center;
        max-width: 99%;
        padding-left: 8px;
        margin: 0 0 4px 6px;
        line-height: 22px;
        color: @search-select-font-color;
        background: #f0f1f5;
        border-radius: 2px;

        &.hidden-selected {
          visibility: hidden;
        }

        &.overflow-selected {
          padding-right: 8px;
        }

        &:hover {
          background: #dcdee5;

          .selected-clear {
            color: @search-select-font-color;
          }
        }

        .selected-name {
          display: inline-block;
          margin-right: 20px;
          word-break: break-all;
        }

        .selected-clear {
          position: absolute;
          top: 4px;
          right: 3px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          width: 14px;
          height: 14px;
          overflow: hidden;
          font-size: 14px;
          line-height: normal;
          color: #979ba5;
          text-align: center;
          cursor: pointer;
        }
      }

      &-input {
        position: relative;
        display: block;
        flex: 1;
        min-width: 40px;
        height: 100%;
        padding: 0 10px;
        margin-top: -4px;
        color: @search-select-font-color;
        border: none;

        .input-before {
          &::after {
            color: @search-select-placeholder-color;
            content: attr(data-placeholder);
          }
        }

        .input-after {
          &:after {
            padding-left: 2px;
            color: @search-select-placeholder-color;
            content: attr(data-tips);
          }
        }
      }

      .selected-input {
        position: relative;
        display: flex;
        align-items: center;
        min-width: 40px;
        height: 100%;
        padding: 0 10px;
        margin-top: -4px;
        color: @search-select-font-color;
        border: none;
      }
    }

    .search-nextfix {
      position: absolute;
      top: 0;
      right: 0;
      display: flex;
      align-items: center;
      color: @light-gray;
      .search-prefix();

      .search-clear {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 12px;
        height: 12px;
        margin-right: 6px;
        font-size: 12px;
        color: @light-gray;

        &:hover {
          color: #979ba5;
          cursor: pointer;
        }
      }

      .search-nextfix-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 8px;
        font-size: 16px;
        transition: color 0.2s linear;

        &.is-focus {
          .focus();
        }
      }
    }

    &::-webkit-scrollbar {
      width: 3px;
      height: 5px;
    }

    &::-webkit-scrollbar-thumb {
      background: #e6e9ea;
      border-radius: 20px;
      box-shadow: inset 0 0 6px rgba(204, 204, 204, 0.3);
    }
  }

  &-tips {
    display: flex;
    align-items: center;
    margin-top: 5px;
    font-size: 12px;
    line-height: 16px;
    color: @search-select-message-color;

    .select-tips {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      margin-right: 5px;
      overflow: hidden;
      font-size: 16px;
    }
  }
}

.@{search-select-name}-menu {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  font-size: 12px;
  color: @search-select-font-color;

  .menu-list-mixin {
    display: flex;
    flex-direction: column;
  }

  .menu-item-mixin {
    display: flex;
    flex: 0 0 32px;
    align-items: center;
    width: 100%;
    max-width: 500px;
    height: 32px;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    outline: none;

    &:hover {
      cursor: pointer;
      background-color: #f5f7fa;
    }
  }

  .menu-disabled-mixin {
    color: @light-gray;

    &:hover {
      cursor: not-allowed;
      background-color: white;
    }
  }

  .menu-header {
    .menu-list-mixin();
    border-bottom: @border-width-base @border-style-base @border-style-color;

    &-item {
      .menu-item-mixin();

      &.is-disabled {
        .menu-disabled-mixin();
      }
    }
  }

  .menu-content-wrapper {
    display: flex;
    width: 100%;
    height: 100%;

    .menu-condition {
      display: flex;
      flex: 0 0 64px;
      flex-direction: column;
      width: 64px;
      padding: 8px 8px 2px 10px;
      background-color: #f5f7fa;

      &-title {
        display: flex;
        align-items: center;
        margin-bottom: 12px;
        line-height: 24px;
      }
      .@{bk-prefix}-radio {
        width: 50px;
        margin-bottom: 14.5px;
      }
      .@{bk-prefix}-radio ~ .@{bk-prefix}-radio {
        margin-left: 0;
      }
    }
  }

  .menu-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    // max-height: 240px;
    padding: 4px 0;
    margin: 0;
    overflow: auto;

    .menu-item {
      .menu-item-mixin();
      white-space: pre;

      .is-keyword {
        display: inline-flex;
        color: @primary-color;
      }

      .is-selected {
        display: flex;
        width: 22px;
        height: 22px;
      }

      &.is-hover {
        color: @primary-color;
        background-color: #f5f7fa;

        .menu-name {
          color: @primary-color;
        }
      }

      &.is-disabled {
        .menu-disabled-mixin();

        .menu-name {
          color: @light-gray;
        }
      }

      .menu-name {
        display: flex;
        align-items: center;
        // max-width: 100px;
        margin-right: 5px;
        font-weight: bold;
        color: @search-select-font-color;
      }
    }
  }

  .menu-footer {
    display: flex;
    align-items: center;
    width: 100%;
    height: 32px;
    border-top: @border-width-base @border-style-base @search-select-menu-border-color;

    &-btn {
      display: flex;
      flex: 1;
      align-items: center;
      justify-content: center;
      height: 100%;

      &:first-child {
        border-right: @border-width-base @border-style-base @search-select-menu-border-color;
      }

      &:hover {
        color: @primary-color;
        cursor: pointer;
      }

      &.is-disabled {
        .menu-disabled-mixin();
      }
    }
  }
}

.@{search-select-name}-popover {
  margin: -12px;
}
