@import './../theme/vars.scss';

$venderPrefix: $vender-prefix;
$amosSearchCls: amos-search;

%icon-after {
  display: inline-block;
  width: 0;
  height: 100%;
  vertical-align: middle;
  content: '';
}

%icon-before {
  display: inline-block;
  vertical-align: middle;
}

.#{$amosSearchCls} {
  position: relative;
  font-size: var(--font-size, 12px);

  &-inner {
    display: inline-block;
    width: 100%;
    height: 30px;
    padding: 3px 10px;
    font-size: inherit;
    line-height: 14px;
    color: $search-text-color;
    background-color: white;
    background-image: none;
    border: 0 solid $border-color-split;
    border-radius: $border-radius-base;
    outline: 0;
    box-shadow: 0 0 0 0 rgba(black, 0), 0 0 0 0 rgba(black, 0), inset 0 0 0 1px rgba(23, 23, 23, 0.15), inset 0 1px 1px rgba(25, 25, 25, 0.2);
    box-sizing: border-box;
    transition: all 0.3s;

    &::placeholder {
      font-weight: normal;
      color: $search-placeholder-color;
    }

    &:focus,
    &:hover {
      box-shadow: 0 0 0 0 $search-active-color, 0 0 0 0 rgba(black, 0), inset 0 0 0 1px $search-active-color, inset 0 1px 1px rgba(25, 25, 25, 0.2);
    }

    &:focus.#{$amosSearchCls}-inner::placeholder {
      color: $search-grey-color;
    }

    &:disabled {
      cursor: not-allowed;
      box-shadow: 0 0 0 1px $search-disable-color;
    }

    &.#{$amosSearchCls}-preicon-left {
      padding-left: 24px;
    }

    &.#{$amosSearchCls}-preicon-right {
      padding-right: 24px;
    }
  }

  &.#{$amosSearchCls}-disabled {
    position: relative;
    color: $search-desable-text-color;

    &::before {
      position: absolute;
      z-index: 1000;
      display: inline-block;
      width: 100%;
      height: 100%;
      cursor: not-allowed;
      background: rgba(0, 0, 0, 0.04);
      border-radius: $border-radius-base;
      content: '';
    }
  }

  &-icon {
    input {
      line-height: 30px;
    }

    &-left,
    &-right {
      position: absolute;
      width: 24px;
      height: 100%;
      text-align: center;
      vertical-align: middle;
    }

    &-left &-inner,
    &-right &-inner {
      width: 100%;
    }

    &-inner::before {
      position: relative;
    }

    .event {
      cursor: pointer;

      &:hover {
        color: $search-active-color;
      }
    }
  }

  &-icon-right {
    top: 0;
    right: 0;
  }

  &-lg &-icon-left,
  &-lg &-icon-right {
    width: 30px;
  }

  &-lg &-inner {
    height: 36px;
    font-size: $search-font-size-lg;
  }

  &-lg &-icon-inner {
    width: 100%;
    font-size: 16px;
  }

  &-lg &-inner.#{$amosSearchCls}-preicon-right {
    padding-right: 30px;
  }

  &-lg &-inner.#{$amosSearchCls}-preicon-left {
    padding-left: 26px;
  }

  &-sm &-icon-inner {
    width: 100%;
    font-size: $search-font-size-sm;
  }

  &-sm &-inner {
    height: 20px;
    padding-right: 5px;
    padding-left: 5px;
  }

  &-sm &-inner.#{$amosSearchCls}-preicon-right {
    padding-right: 24px;
  }

  &-sm &-inner.#{$amosSearchCls}-preicon-left {
    padding-left: 22px;
  }

  &-sm &-icon-left {
    width: 24px;
  }

  &-sm &-icon-right {
    width: 24px;
  }

  i[class*='icon'] {
    &::after {
      @extend %icon-after;
    }

    &::before {
      @extend %icon-before;
    }
  }

  // icon 由 img 创建
  span[class*='icon'] {
    &::after {
      @extend %icon-after;
    }

    img {
      @extend %icon-before;
    }
  }
}

.#{$amosSearchCls}-addon {
  display: table;

  .#{$amosSearchCls}-inner {
    position: relative;
    z-index: 1;

    &.addon-after {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    &.addon-before {
      border-bottom-left-radius: 0;
      border-top-left-radius: 0;
    }
  }

  .#{$venderPrefix}-btn {
    height: 100%;
    margin: -7px -12px -4px;
    line-height: 1;
    color: inherit;
    background-color: transparent;
    border-color: transparent;
    border-radius: 0;
  }

  &-before,
  &-after {
    position: relative;
    display: table-cell;
    padding: 4px 11px;
    font-size: 14px;
    font-weight: normal;
    line-height: 1;
    color: rgba(0, 0, 0, 0.65);
    text-align: center;
    background-color: $search-bg-color;
    border: 1px solid $search-border-color;
    border-radius: 4px;
  }

  &-before {
    border-right-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  &-after {
    border-left-width: 0;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
  }
}

// btn search

.btn-search {
  .search-area,
  .btn-area {
    position: relative;
    display: inline-block;
  }

  .amos-input,
  .amos-btn {
    height: 2.8em;
    border-radius: $border-radius-base;
  }

  .amos-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .amos-btn {
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
  }
}
