/**
 *
 * This file may have been modified by Bytedance Inc. (“Bytedance Inc.'s Modifications”). 
 * All Bytedance Inc.'s Modifications are Copyright (year) Bytedance Inc..  
 * 
 * This source code is licensed under the Apache license.
 * See LICENSE file in the project root for license information.
 *
 */
@import '../../../styles/variables.less';
@import '../../../styles/mixins.less';

@import './variables.less';
@import './mixins.less';

.@{ant-prefix}-input-number:not(.sp-null) {
  min-width: 104px;
  width: 100%;
  max-width: 288px;
  height: 32px;
  color: @color-text-icon-0;

  .@{ant-prefix}-input-number-input {
    height: 32px;
    padding: 0 30px 0 12px;
  }

  .@{ant-prefix}-input-number-input-wrap {
    margin-top: -1px;
  }

  &.@{ant-prefix}-input-number-focused {
    box-shadow: none;
    z-index: 1;
  }

  &:focus {
    box-shadow: none;
  }
  .@{ant-prefix}-input-number-handler-wrap {
    width: 14px;
    height: 24px;
    margin-top: 3px;
    position: absolute;
    right: 4px;
    border-left: none;
    border-radius: 4px;
  }

  .@{ant-prefix}-input-number-handler-down {
    border-top: none;
    border-radius: 0 0 3px 3px;
    border-left: 1px solid @input-number-handler-border-color;
    border-bottom: 1px solid @input-number-handler-border-color;
    border-right: 1px solid @input-number-handler-border-color;
  }
  .@{ant-prefix}-input-number-handler-up {
    border-radius: 3px 3px 0 0;
    border-left: 1px solid @input-number-handler-border-color;
    border-top: 1px solid @input-number-handler-border-color;
    border-right: 1px solid @input-number-handler-border-color;

    .@{ant-prefix}-input-number-handler-up-inner {

      svg path {
        d: path(
          'M764.4 647.8a28.9 28.9 0 000-40.8L532.8 375.5a28.9 28.9 0 00-40.8 0L260.5 607a28.9 28.9 0 1040.8 40.8l211.1-211 211.1 211a28.9 28.9 0 0040.9 0z'
        );
      }
    }
  }
  .@{ant-prefix}-input-number-handler {

    &:hover {
      background-color: @input-number-handler-hover-bg;
    }

    .anticon {
      width: 10px;
      height: 10px;
      font-size: 10px;
      right: 1px;
    }
  }
  .@{ant-prefix}-input-number-handler-wrap .@{ant-prefix}-input-number-handler {
    height: 50% !important;
  }
  .@{ant-prefix}-input-number-handler-up-disabled,
  .@{ant-prefix}-input-number-handler-down-disabled {

    &:hover {
      background: none;
    }

    .anticon {
      opacity: .45;
    }
  }
}

.@{ant-prefix}-input-number-handler-wrap-borderless:not(.sp-null) {
  border: none !important;
  box-shadow: none !important;
  background-color: transparent;
  .@{ant-prefix}-input-number {
    border: none !important;
    background: transparent;
  }
  .@{ant-prefix}-input-number-static-unit:not(.sp-null) {
    background: transparent;
  }
  .@{ant-prefix}-input-number-static-prefix:not(.sp-null) {
    background: transparent;
  }
}

// 左右进步器
.@{ant-prefix}-input-number-wrapper-show-counter:not(.sp-null) {
  display: inline-flex;
  border: 1px solid @input-number-counter-border-color;
  overflow: hidden;

  .input-bubble-notice-bottom {
    top: 32px;
  }
  &:not(.@{ant-prefix}-input-number-wrapper-disabled):not(.@{ant-prefix}-input-number-handler-wrap-focused):hover {
    border-color: @input-number-counter-hover-border-color;
  }
  .@{ant-prefix}-input-number {
    height: 30px;
    width: 122px;
    min-width: 122px;
    border-radius: 0;
    border: none;
  }
  .@{ant-prefix}-input-number-input:not(.sp-null) {
    text-align: center;
    padding: 0;
  }
  .@{ant-prefix}-input-number-input-wrap {
    width: 60px;
    margin: 0 auto;
  }
  .@{ant-prefix}-input-number-handler-wrap {
    display: block !important;
    float: left !important;
    opacity: 1 !important;
    width: 0 !important;
    position: static !important;
    .@{ant-prefix}-input-number-handler {
      position: absolute;
      width: 30px !important;
      height: 30px !important;
      top: 0;
      border-top: none;
      border-bottom: none;
      text-align: center;
      background-color: @input-number-handler-hover-bg;

      &::before {
        display: block;
        line-height: 28px;
        font-weight: 400;
        font-size: 14px;
        color: @color-text-icon-2;
      }

      &:hover::before {
        color: @color-primary-brand;
      }
    }
    .@{ant-prefix}-input-number-handler-up {
      right: 0;
      border-right: none;
      border-top-left-radius: 0;

      &::before {
        content: '+';
      }

      &-inner {
        display: none;
      }
    }
    .@{ant-prefix}-input-number-handler-down {
      left: 0;
      border-left: none;
      border-bottom-right-radius: 0;

      &::before {
        content: '-';
      }

      &-inner {
        display: none;
      }
    }
  }
}

// 当静态单位显示时，走下面这个样式
.@{ant-prefix}-input-number-handler-wrap-static {
  display: inline-flex;
  border-radius: 4px;
  border: 1px solid @input-number-border-color;
  .@{ant-prefix}-input-number-static-unit {
    position: relative;
    font-size: 12px;
    line-height: 28px;
    color: @color-text-icon-0;
    border: 1px solid @color-line-0;
    height: 30px;
    display: inline-block;
    border-top-right-radius: @border-radius-base;
    border-bottom-right-radius: @border-radius-base;
    background-color: @input-number-static-unit-bg;
    transition: all .3s;

    span {
      padding: 0 8px;
      vertical-align: middle;
    }
  }
  .@{ant-prefix}-input-number-static-prefix {
    position: relative;
    font-size: 12px;
    line-height: 28px;
    color: @color-text-icon-0;
    border: none;
    height: 30px;
    display: inline-block;
    border-top-left-radius: @border-radius-base;
    border-bottom-left-radius: @border-radius-base;
    background-color: @input-number-static-unit-bg;
    transition: all .3s;

    span {
      padding: 0 8px;
      vertical-align: middle;
      white-space: nowrap;
    }
  }

  .@{ant-prefix}-input-number-static-unit-disabled {
    cursor: not-allowed;
    background-color: @input-disabled-bg;
  }

  .@{ant-prefix}-input-number-static-prefix-disabled {
    cursor: not-allowed;
    background-color: @input-disabled-bg;
  }

  .@{ant-prefix}-input-number-static-unit {
    border: none;
    flex-shrink: 0;
  }
  .@{ant-prefix}-input-number:not(.sp-null) {
    border: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    height: 30px;
  }

  .input-bubble-notice-bottom {
    top: 32px;
  }

  &:hover:not(.@{ant-prefix}-input-number-wrapper-disabled) {
    border-color: @input-hover-border-color;
    .@{ant-prefix}-input-number {
      background-color: @input-hover-bg;
    }
    .@{ant-prefix}-input-number-static-unit,
    .@{ant-prefix}-input-number-static-prefix {
      background-color: @input-hover-bg;
    }
  }
}

// 当有前缀时展示，走下面样式
.@{ant-prefix}-input-number-handler-wrap-prefix-static {
  .@{ant-prefix}-input-number {

    &:not(.sp-null) {
      border-top-right-radius: 4px;
      border-bottom-right-radius: 4px;
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }
    .@{ant-prefix}-input-number-input-wrap {
      .@{ant-prefix}-input-number-input {
        padding-left: 0;
      }
    }
  }
}

// 当下拉单位显示时，走下面样式
.@{ant-prefix}-input-number-handler-wrap-select {
  display: inline-flex;
  .@{ant-prefix}-input-number:not(.sp-null) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-right: -1px;
  }
  .@{ant-prefix}-select-selector {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
  }
  &:not(.@{ant-prefix}-input-number-wrapper-disabled):hover {
    .@{ant-prefix}-select-selector {
      border-left-color: @input-number-hover-border-color;
    }
  }

  .input-bubble-notice-bottom {
    top: 32px;
  }
}

// 当进步器为false时
.@{ant-prefix}-input-number-wrapper-no-stepper:not(.sp-null) {
  .@{ant-prefix}-input-number-input {
    padding: 0 12px;
  }
  .@{ant-prefix}-input-number-handler-wrap {
    display: none;
  }
}

// 输入错误
.@{ant-prefix}-input-number-wrapper-error,
.@{ant-prefix}-form-item-has-error .@{ant-prefix}-input-number-handler-wrapper,
.@{ant-prefix}-form-item-has-error
.@{ant-prefix}-input-number-handler-wrapper.@{ant-prefix}-input-number-handler-wrap-focused,
.has-error .@{ant-prefix}-input-number-handler-wrapper {
  position: relative;
  border-color: @input-error-border-color;
  .@{ant-prefix}-input-number {
    border-color: @input-error-border-color;
  }
  .@{ant-prefix}-select-selector {
    border-left-color: @input-error-border-color;
  }
  .@{ant-prefix}-input-number-handler-general-error {
    color: @input-error-border-color;
    position: absolute;
    display: block;
    top: 36px;
    left: 0;
    font-size: 12px;
    line-height: 16px;
  }

  .input-bubble-notice {
    position: absolute;
    z-index: 2;
    padding: 8px;
    .fontStyle-4-normal();
    border-radius: 4px;
    background: @white;
    word-break: break-word;
    font-size: 12px;
    line-height: 16px;

    &.input-bubble-notice-right {
      display: inline-block;
      width: 160px;
      top: 50%;
      transform: translateY(-50%);
      margin-left: 8px;
    }

    &.input-bubble-notice-bottom {
      display: block;
      width: 136px;
      margin-top: 8px;
      left: 0;
    }

    &.input-bubble-notice-info {
      border: 1px solid @color-line-1;
      color: @color-text-icon-1;
    }

    &.input-bubble-notice-error {
      border: 1px solid @input-error-border-color;
      color: @input-error-border-color;
    }
  }

  .input-bubble-notice-triangle {
    position: absolute;
    z-index: 3;
    width: 7px;
    height: 7px;
    background: @white;

    &.input-bubble-notice-right {
      left: -4px;
      top: 50%;
      transform: translateY(-50%) rotate(-45deg);
    }

    &.input-bubble-notice-bottom {
      left: 10px;
      top: -4px;
      transform: rotate(45deg);
    }

    &.input-bubble-notice-info {
      border-top: 1px solid @color-line-1;
      border-left: 1px solid @color-line-1;
    }

    &.input-bubble-notice-error {
      border-top: 1px solid @color-function-danger-main;
      border-left: 1px solid @color-function-danger-main;
    }
  }
}

.@{ant-prefix}-form-item-has-error {
  .@{ant-prefix}-input-number-handler-wrapper.@{ant-prefix}-input-number-handler-wrap-focused {
    &:not(.@{ant-prefix}-input-number-wrapper-disabled) {
      .@{ant-prefix}-input-number-focused {
        border-color: @input-error-active-border-color;
      }

    }
  }
}


.@{ant-prefix}-input-number-wrapper-disabled {
  .@{ant-prefix}-input-number-input {
    color: @color-text-icon-3 !important;
  }
  &.@{ant-prefix}-input-number-wrapper-show-counter {
    .@{ant-prefix}-input-number-handler {
      background-color: rgba(0, 0, 0, 0) !important;
      cursor: not-allowed;

      &::before {
        color: @color-text-icon-3 !important;
      }
    }
  }
}

.@{ant-prefix}-input-number-input:not(.sp-null)::placeholder {
  color: @color-text-icon-3;
}

.@{ant-prefix}-input-number-handler-wrapper {
  display: inline-flex;
  background-color: @white;
  transition: all .2s;
  border-radius: @border-radius-base;

  .input-bubble-notice-bottom {
    top: 100%;
  }
  &.@{ant-prefix}-input-number-handler-wrap-focused {
    box-shadow: @base-shadow;
    border-color: @color-primary-brand;
    .@{ant-prefix}-input-number-static-unit,
    .@{ant-prefix}-input-number-static-prefix {
      background-color: @input-active-bg;
    }
  }
}

// 小尺寸
.@{ant-prefix}-input-number-wrapper-sm:not(.sp-null) {
  height: 28px !important;

  .@{ant-prefix}-input-number {
    height: 26px !important;
    .@{ant-prefix}-input-number-input {
      font-size: 12px;
      height: 28px;
    }
  }
  .@{ant-prefix}-input-number-handler-wrap {
    margin-top: 1px !important;
  }
  .@{ant-prefix}-input-number-static-unit {
    line-height: 22px !important;
    height: 26px !important;
  }

  .@{ant-prefix}-select-selector {
    height: 28px !important;
  }
  .@{ant-prefix}-select-selection-item {
    margin-top: -3px !important;
  }
  .@{ant-prefix}-input-number-static-unit-disabled {
    height: 26px !important;
  }

  .input-bubble-notice {
    top: 28px !important;
  }
  .@{ant-prefix}-input-number-handler-general-error {
    top: 28px !important;
  }
  &:not(.@{ant-prefix}-input-number-wrapper-show-counter):not(.@{ant-prefix}-input-number-handler-wrap-static) {
    .@{ant-prefix}-input-number {
      height: 28px !important;
    }
  }
  &.@{ant-prefix}-input-number-wrapper-show-counter {
    .@{ant-prefix}-input-number-handler {
      height: 26px !important;

      &::before {
        line-height: 24px;
      }
    }
  }
}

// 大尺寸
.@{ant-prefix}-input-number-wrapper-lg:not(.sp-null) {
  .@{ant-prefix}-input-number:not(.sp-null) {
    height: 34px !important;
    .@{ant-prefix}-input-number-input {
      height: 34px;
    }
  }
  .@{ant-prefix}-input-number-handler-wrap {
    margin-top: 5px !important;
  }
  .@{ant-prefix}-input-number-static-unit {
    line-height: 28px !important;
  }
  .@{ant-prefix}-select-selector {
    height: 34px !important;
  }
  &.@{ant-prefix}-input-number-wrapper-show-counter {
    .@{ant-prefix}-input-number-handler {
      height: 34px !important;

      &::before {
        line-height: 32px;
      }
    }
  }
}
