@import '../style/theme/color';
@import '../style/core/_font';
@import '../style/core/animation';

.devui-search {
  .devui-serach-line {
    border-color: $devui-dividing-line;
  }
}

svg.svg-icon-search {
  path {
    fill: $devui-icon-fill;
    transition: all $devui-animation-ease-in-out-smooth $devui-animation-duration-slow;
  }

  &:hover {
    path {
      fill: $devui-icon-fill-hover;
    }
  }
}

svg.svg-icon-clear {
  vertical-align: middle;
  position: relative;
  top: -0.1em;

  path {
    fill: $devui-shape-icon-fill;
    transition: all $devui-animation-ease-in-out-smooth $devui-animation-duration-slow;
  }

  &:hover {
    path {
      fill: $devui-shape-icon-fill-hover;
    }
  }
}

:host {
  display: inline-block;
}

.devui-search {
  position: relative;

  .devui-input {
    height: 28px;
    padding: 4px 8px;
    font-size: $devui-font-size;
    padding-right: 28px;
    text-overflow: ellipsis;

    &.devui-icon-left {
      padding-left: 32px;
    }

    &.devui-search-no-border:not(:focus, :active) {
      background-color: unset;
    }

    &.devui-search-no-border:not(:hover, :focus, :active) {
      border: 1px solid transparent;
    }

    &.devui-clear-exit:not(.devui-icon-left) {
      padding-right: 60px;
    }

    &-sm {
      height: 26px;
      padding: 4px 8px;
      font-size: $devui-font-size;
      padding-right: 24px;

      &.devui-clear-exit:not(.devui-icon-left) {
        padding-right: 56px;
      }
    }

    &-lg {
      height: 46px;
      padding: 12px 8px;
      font-size: $devui-font-size-lg;
      line-height: 24px;
      padding-right: 36px;

      &.devui-clear-exit:not(.devui-icon-left) {
        padding-right: 72px;
      }
    }

    &::-ms-clear {
      display: none;
    }

    &:disabled {
      background-color: $devui-disabled-bg;
      border-color: $devui-disabled-line;
      color: $devui-disabled-text;

      & + .devui-search-icon {
        svg path {
          fill: $devui-disabled-text;
        }
      }
    }
  }

  .icon {
    cursor: pointer;
  }

  .devui-search-icon {
    position: absolute;
    width: auto;
    pointer-events: all;
    cursor: pointer;
    height: 100%;
    line-height: 28px;
    padding: 0 12px;
    top: 0;
    right: 0;
    z-index: 2;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;

    &.devui-icon-left {
      left: 8px;
      right: auto;
      padding-left: 0;
    }

    > svg {
      height: 16px;
      width: 16px;
    }

    &-sm {
      height: 26px;
      line-height: 26px;
      padding: 0 12px;

      > svg {
        height: 14px;
        width: 14px;
      }
    }

    &-lg {
      height: 46px;
      line-height: 46px;

      > svg {
        height: 18px;
        width: 18px;
      }
    }
  }

  .devui-search-clear {
    position: absolute;
    width: auto;
    top: 0;
    right: 36px;
    padding: 0 8px;
    pointer-events: all;
    cursor: pointer;
    height: 100%;
    line-height: 28px;
    font-size: $devui-font-size-lg;
    z-index: 2;
    display: none;

    &.devui-icon-left {
      right: 0;
    }

    &.devui-clear-exit {
      display: block;
    }

    &-sm {
      line-height: 26px;
      padding: 0 8px;

      > svg {
        height: 14px;
        width: 14px;
      }
    }

    &-lg {
      right: 46px;
      line-height: 46px;
      padding: 0 8px;

      > svg {
        height: 18px;
        width: 18px;
      }
    }
  }

  .devui-search-line {
    position: absolute;
    right: 36px;
    height: 46%;
    top: 27%;
    width: 1px;
    border-left-width: 1px;
    border-left-style: solid;
    border-color: $devui-line;
    line-height: 28px;
    display: none;

    &.devui-clear-exit {
      display: block;
    }

    &-sm {
      line-height: 26px;
    }

    &-lg {
      line-height: 46px;
      right: 42px;
    }
  }
}
