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

:host {
  display: inline-block;
  position: relative;
  width: 80px;

  .disabled {
    cursor: not-allowed;
  }

  &:hover {
    .input-box:not(.disabled) {
      padding-right: 24px;
    }

    .input-control-buttons:not(.disabled) {
      display: flex;
    }
  }

  &:focus-within {
    .input-box:not(.disabled) {
      border: 1px solid $devui-form-control-line-active;
      padding-right: 24px;
    }

    .input-control-buttons:not(.disabled) {
      border-color: $devui-form-control-line-active;
    }

    .input-control-buttons:not(.disabled) {
      display: flex;
    }
  }

  .input-box {
    box-sizing: border-box;
    padding: 4px 8px;
    font-size: $devui-font-size;
    vertical-align: middle;
    border-radius: $devui-border-radius;
    outline: none;
    width: 100%;
    line-height: 20px;
    height: 28px;
    border-width: 1px;
    border-style: solid;

    &:not(.disabled) {
      background-color: $devui-base-bg;
      border-color: $devui-line;
      color: $devui-text;
    }
  }

  .input-control-buttons {
    display: none;
    position: absolute;
    right: 0;
    width: 22px;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid transparent;
    border-left-color: $devui-line;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    line-height: 100%;
    border-radius: 0 $devui-border-radius $devui-border-radius 0;

    &.disabled {
      border-left-color: $devui-disabled-line;
    }

    .input-control-button {
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-box-sizing: border-box;
      -moz-box-sizing: border-box;
      box-sizing: border-box;
      height: 50%;
      line-height: 50%;
      border-width: 0 1px;
      transition: transform $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
      display: flex;
      justify-content: center;
      align-items: center;

      &.input-control-inc svg {
        position: relative;
        top: 2px;
        transform: rotate(180deg);
      }

      &.input-control-dec svg {
        position: relative;
        bottom: 2px;
      }

      svg path {
        fill: $devui-text-weak;
      }

      &:not(.disabled) {
        cursor: pointer;

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

      &.disabled {
        & > svg path {
          fill: $devui-disabled-text;
        }
      }
    }
  }
}

.devui-input-number-lg {
  & > .input-box {
    font-size: $devui-font-size-lg;
    line-height: 24px;
    height: 46px;
  }

  ::ng-deep &.input-control-buttons .input-control-button {
    .devui-svg-icon-arrow {
      width: 16px;
      height: 16px;
    }
  }
}

.devui-input-number-sm {
  & > .input-box {
    font-size: $devui-font-size-sm;
    line-height: 18px;
    height: 26px;
  }

  & ::ng-deep .input-control-buttons .input-control-button {
    &:first-child .devui-svg-icon-arrow {
      width: 14px;
      height: 14px;
    }

    &:last-child .devui-svg-icon-arrow {
      width: 13px;
      height: 13px;
      left: 0;
    }
  }
}

.input-container {
  line-height: 100%;
}
