@import '../style/var.less';

.fe-search-bar {
  width: 100%;

  &-form,
  &-result {
    padding: 0 10px;
  }

  &-form {
    box-sizing: border-box;
    position: relative;
    display: flex;
    align-items: center;
    height: @search-form-height;
    overflow: hidden;
  }

  &-input {
    flex: 1;
    position: relative;
    width: 100%;
    height: @search-input-height;
    overflow: hidden;
    border-radius: @search-border-radius;
    background-color: @white;
  }

  &-placeholder,
  input[type='search'] {
    position: absolute;
    top: 0;
    left: 0;
  }

  &-placeholder {
    box-sizing: content-box;
    z-index: 1;
    width: 100%;
    height: @search-input-height;
    color: @dark-text-color;
    line-height: @search-input-line-height;
    transition: width 0.3s;
    display: block;
    text-align: center;

    &-focus {
      padding-left: 10px;
      width: auto;
    }

    &-text {
      color: #9c9c9d;
      font-size: @search-input-placeholder-font-size;
    }
  }

  &-icon {
    color: #b2b2b2;
  }

  input[type='search'] {
    z-index: 2;
    opacity: 0;
    width: 100%;
    text-align: left;
    display: block;
    color: @search-bar-input-color;
    height: @search-input-height;
    font-size: @font-size-lg;
    background-color: transparent;
    border: 0;

    &:focus {
      outline: 0;
    }

    &::placeholder {
      background: none;
      text-align: left;
      color: transparent;
    }

    &::-webkit-search-cancel-button {
      -webkit-appearance: none;
    }
    //干掉input[search]默认的clear button
    &::-webkit-search-decoration,
    &::-webkit-search-cancel-button,
    &::-webkit-search-results-button,
    &::-webkit-search-results-decoration {
      display: none;
    }
  }

  & &-clear {
    color: @dark-text-color;
    box-sizing: content-box;
    position: absolute;
    display: none;
    z-index: 3;
    width: 17px;
    height: 17px;
    top: 0;
    right: 0;
    padding: 5.5px;
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.3s;

    &-show {
      display: block;
    }
  }

  &-cancel {
    flex: none;
    opacity: 1;
    text-align: right;
    padding-left: 8px;
    height: @search-form-height;
    line-height: @search-form-height;
    text-align: right;
    color: @search-bar-cancel-color;
  }

  &-focus {
    .fe-search-bar-input {
      input[type='search'] {
        opacity: 1;
        padding: 0 28px 0 31px;

        &::placeholder {
          color: @search-bar-input-placeholder;
        }
      }
    }
  }

  &-type {
    background: @white;
    .fe-search-bar-input {
      background: @search-bar-input-bgcolor;
      font-size: @search-bar-font-size;
    }
  }

  &-result {
    background: @white;
  }

  &-result-item {
    padding: 5px;
    font-size: @font-size-lg;
    border-bottom: 1px #eee solid;
  }

  &-bc-clip-padding-box {
    background-clip: padding-box;
  }

  &-bc-clip-content-box {
    background-clip: content-box;
  }
}