@use "sass:math";

@import "mixins/mixins";
@import "common/var";
@import "input";

@include b(input-number) {
  position: relative;
  display: inline-block;
  width: 180px;
  line-height: #{$input-height - 2};
  .#{$namespace}-input {
    display: block;

    &_inner {
      -webkit-appearance: none;
      padding-left: #{$input-height + 10};
      padding-right: #{$input-height + 10};
      text-align: center;
    }
  }
  @include e((increase, decrease)) {
    position: absolute;
    z-index: 1;
    top: 1px;
    width: $input-height;
    height: auto;
    text-align: center;
    background: $bg-color;
    color: $text-color-default;
    cursor: pointer;
    font-size: 14px;

    [class*=#{$namespace}-icon] {
      font-size: 14px;
    }

    &:hover {
      color: $primary-color;

      &:not(.is-disabled) ~ .#{$namespace}-input .#{$namespace}-input_inner {
        border-color: $input-border-focus;
      }
    }
    &.ro-disabled {
      color: $disabled-color;
      cursor: not-allowed;
    }
  }

  @include e(increase) {
    right: 1px;
    border-radius: 0 $border-radius-default $border-radius-default 0;
    border-left: $border-base;
  }

  @include e(decrease) {
    left: 1px;
    border-radius: $border-radius-default 0 0 $border-radius-default;
    border-right: $border-base;
  }

  @include pf(disabled) {
    @include e((increase, decrease)) {
      border-color: $disabled-border;
      color: $disabled-color;

      &:hover {
        color: $disabled-color;
        cursor: not-allowed;

        ~ .#{$namespace}-input .#{$namespace}-input_inner {
          border-color: $disabled-border;
        }
      }
    }
  }


  @include mf(medium) {
    width: 160px;
    line-height: #{$input-medium-height - 2};
    @include e((increase, decrease)) {
      width: $input-medium-height;
    }

    .#{$namespace}-input_inner {
      padding-left: #{$input-medium-height + 7};
      padding-right: #{$input-medium-height + 7};
    }
  }

  @include mf(small) {
    width: 140px;
    line-height: #{$input-small-height - 2};
    @include e((increase, decrease)) {
      width: $input-small-height;
      [class*=#{$namespace}-icon] {
        font-size: $input-small-font-size;
      }
    }
    .#{$namespace}-input_inner {
      padding-left: #{$input-small-height + 7};
      padding-right: #{$input-small-height + 7};
    }
  }

  @include mf(mini) {
    width: 120px;
    line-height: #{$input-mini-height - 2};
    @include e((increase, decrease)) {
      width: $input-mini-height;
      [class*=#{$namespace}-icon] {
        font-size: $input-mini-font-size;
      }
    }
    .#{$namespace}-input_inner {
      padding-left: #{$input-mini-height + 7};
      padding-right: #{$input-mini-height + 7};
    }
  }

  @include pf(without-controls) {
    .#{$namespace}-input_inner {
      padding-left: 15px;
      padding-right: 15px;
    }
  }

  //$i-h: #{($input-height - 2)/2};
  //$i-h-m: #{($input-medium-height - 2)/2};
  //$i-h-s: #{($input-small-height - 2)/2};
  //$i-h-mi:#{($input-mini-height - 2)/2};

  $i-h: #{math.div($input-height - 2,2)};
  $i-h-m: #{math.div($input-medium-height - 2,2)};
  $i-h-s: #{math.div($input-small-height - 2,2)};
  $i-h-mi: #{math.div($input-mini-height - 2,2)};

  @include pf(controls-right) {
    .#{$namespace}-input_inner {
      padding-left: 15px;
      padding-right: #{$input-height + 10};
    }
    @include e((increase, decrease)) {
      height: auto;
      line-height: $i-h;

      [class*=#{$namespace}-icon] {
        transform: scale(.8);
      }
    }

    @include e(increase) {
      border-radius: 0 $border-radius-default 0 0;
      border-bottom: $border-base;
    }

    @include e(decrease) {
      border-left: $border-base;
      border-right: none;
      border-radius: 0 0 $border-radius-default 0;
      right: 1px;
      top: auto;
      left: auto;
      bottom: 1px;
    }

    &[class*=medium] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-m;
      }
    }

    &[class*=small] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-s;
      }
    }

    &[class*=mini] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-mi;
      }
    }
  }

  @include pf(controls-left) {
    .#{$namespace}-input_inner {
      padding-right: 15px;
      padding-left: #{$input-height+10};
    }
    @include e((increase, decrease)) {
      height: auto;
      line-height: $i-h;

      [class*=#{$namespace}-icon] {
        transform: scale(.8);
      }
    }

    @include e(increase) {
      border-radius: $border-radius-default 0 0 0;
      border-bottom: $border-base;
      border-left: none;
      border-right: $border-base;
      left: 1px;
    }

    @include e(decrease) {
      border-right: $border-base;
      border-left: none;
      border-radius: 0 0 0 $border-radius-default;
      right: auto;
      bottom: 1px;
      top: auto;
      left: 1px;
    }

    &[class*=medium] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-m;
      }
    }

    &[class*=small] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-s;
      }
    }

    &[class*=mini] {
      [class*=increase], [class*=decrease] {
        line-height: $i-h-mi;
      }
    }
  }
}
