@import "../button/index.less";
@import "../input/index.less";

@border-color: #eee;
@hover-border-color: var(--global-primary-color);
@lg: 40px;
@lg-wdith: 200px;
@lg-right: 20px;
@md: 32px;
@md-wdith: 160px;
@md-right: 16px;
@sm: 28px;
@sm-wdith: 140px;
@sm-right: 14px;
@xs: 24px;
@xs-wdith: 120px;
@xs-right: 12px;

.set-size(@width, @size, @right-size) {
  & {
    height: @size;
    width: @width;
    .layui-input {
      height: @size;
      line-height: @size;
      padding: 0 @size;
    }
    .layui-control-btn {
      width: @size;
      height: @size;
      line-height: @size;
    }
    &[position="right"] {
      .layui-input {
        padding: 0 @size 0 0;
      }
      .layui-control-btn {
        height: @right-size;
        line-height: @right-size;
      }
      .layui-subtraction-btn {
        top: @right-size - 1;
      }
    }
  }
}

.layui-input-number {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  border: 1px solid @border-color;
  border-color: @border-color;
  border-radius: var(--global-border-radius);
  overflow: hidden;
  .set-size(@lg-wdith, @lg, @lg-right);
  margin-left: 5px;
  .layui-input-wrapper {
    text-align: center;
    border: 0;
  }
  .layui-control-btn {
    position: absolute;
    box-sizing: border-box;
    border: 0;
    border-color: @border-color;
    border-style: solid;
    border-radius: 0;
    padding: 0;
    text-align: center;
    top: 0;
    &:hover {
      color: @hover-border-color;
    }
    &.layui-subtraction-btn {
      border-right-width: 1px;
    }
    &.layui-addition-btn {
      border-left-width: 1px;
      right: 0;
    }
    .layui-icon {
      padding: 0px;
    }
  }
  /* 谷歌--去掉自带的控制按钮 */
  input.layui-input::-webkit-outer-spin-button,
  input.layui-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
  }

  /* 火狐--去掉自带的控制按钮 */
  input.layui-input[type="number"] {
    -moz-appearance: textfield;
  }

  &[position="right"] {
    .layui-subtraction-btn {
      right: 0;
      border-right-width: 0px;
      border-left-width: 1px;
    }
    .layui-addition-btn {
      border-bottom-width: 1px;
    }
  }

  &[size="md"] {
    .set-size(@md-wdith,@md, @md-right);
  }

  &[size="sm"] {
    .set-size(@sm-wdith, @sm, @sm-right);
  }

  &[size="xs"] {
    .set-size(@xs-wdith, @xs, @xs-right);
  }
}
