// ======================
// ====== 按钮样式 ======
// ======================

@input-number-button-prefix-cls: ~'@{ant-prefix}-input-number-button';
@form-item-prefix-cls: ~'@{ant-prefix}-form-item';
// bonree-start
@input-number-button-prefix-cls-focused: ~'@{ant-prefix}-input-number-button-focused';
// bonree-end

.input-wrap-hover() {
  .@{input-number-button-prefix-cls}-input {
    border-color: @primary-color-hover;
  }

  &::before,
  &::after {
    border-color: @primary-color-hover;
    opacity: 1;
  }
}

.input-wrap-disabled() {
  .@{input-number-button-prefix-cls}-input {
    border-color: @border-color-base;
  }

  &::before,
  &::after {
    border-color: @border-color-base;
  }
}

.@{input-number-button-prefix-cls} {
  .reset-component();
  .input();

  //== Style for input-group: input with label, with button or dropdown...
  &-group {
    .reset-component();
    .input-group(~'@{input-number-button-prefix-cls}');

    &-wrapper {
      display: inline-block;
      text-align: start;
      vertical-align: top; // https://github.com/ant-design/ant-design/issues/6403
    }
  }

  display: inline-block;
  // width: 90px;
  width: 128px;
  margin: 0;
  padding: 0;
  // border: @border-width-base @border-style-base @border-color-base;
  // border-radius: @border-radius-base;
  border: none;

  &-handler {
    // position: relative;
    position: absolute;
    z-index: 1;
    display: block;
    // width: 100%;
    width: @input-height-base;
    // height: 50%;
    height: 100%;
    overflow: hidden;
    color: @text-color-secondary;
    font-weight: bold;
    line-height: 0;
    text-align: center;
    background: #fff;
    // border-left: @border-width-base @border-style-base @input-number-handler-border-color;
    border: @border-width-base @border-style-base @border-color-base;
    transition: all 0.1s linear;

    &:hover {
      background: @primary-color-outline;
      border-color: @primary-color-hover;
    }

    &:active {
      background: @primary-1;
      border-color: @primary-color-active;
      box-shadow: @br-box-shadow-base;
    }

    &:hover &-up-inner,
    &:hover &-down-inner {
      // color: @input-number-handler-hover-bg;
      color: @primary-color-hover;
    }

    &:active &-up-inner,
    &:active &-down-inner {
      // color: @input-number-handler-hover-bg;
      color: @primary-color-active;
    }
  }

  &-handler-up-inner,
  &-handler-down-inner {
    .iconfont-mixin();

    position: absolute;
    top: 50%;
    left: 50%;
    // right: 4px;
    // width: 12px;
    // height: 12px;
    width: @br-font-size-largest;
    height: @br-font-size-largest;
    color: @text-color-secondary;
    // line-height: 12px;
    line-height: @br-font-size-largest;
    transform: translate(-50%, -50%);
    transition: all 0.1s linear;
    user-select: none;
  }

  &:hover {
    .hover(@input-number-hover-border-color);
    & + .@{form-item-prefix-cls}-children-icon {
      opacity: 0;
      transition: opacity 0.24s linear 0.24s;
    }
  }

  &:focus {
    box-shadow: none;
  }

  &-focused {
    // .active();
    box-shadow: none;
  }

  &-disabled {
    .disabled();
    .@{input-number-button-prefix-cls}-input-wrap {
      &:active {
        box-shadow: none;
        .@{input-number-button-prefix-cls}-input {
          border-color: @border-color-base;
        }
        &::before,
        &::after {
          border-color: @border-color-base;
        }
      }
    }
    .@{input-number-button-prefix-cls}-input {
      cursor: not-allowed;
    }
    // .@{input-number-button-prefix-cls}-handler-wrap {
    //   display: none;
    // }

    .@{input-number-button-prefix-cls}-handler {
      background: @disabled-bg;
      cursor: not-allowed;

      &-up-inner,
      &-down-inner {
        color: @disabled-color;
      }

      &:hover,
      &:active {
        background: @disabled-bg;
        border-color: @border-color-base;
        box-shadow: none;
        .@{input-number-button-prefix-cls}-handler-up-inner,
        .@{input-number-button-prefix-cls}-handler-down-inner {
          color: @disabled-color;
        }
      }
    }

    .@{input-number-button-prefix-cls}-input-wrap {
      &:hover {
        .input-wrap-disabled();
      }
    }
  }

  &-readonly {
    .@{input-number-button-prefix-cls}-handler-wrap {
      display: none;
    }
  }

  &-input-wrap {
    position: relative;
    z-index: 3; // 在form中bonree-input-number-handler-wrap会设置z-index:2
    width: ~'calc(100% - 2 * @{input-height-base})';
    margin: 0 @input-height-base;

    &::before,
    &::after {
      position: absolute;
      top: 0;
      width: 0;
      height: 100%;
      border: 0 @border-style-base @border-color-split;
      opacity: 0;
      transition: all 0.3s linear;
      content: '';
    }

    &::before {
      left: -1px;
      border-left-width: 1px;
    }

    &::after {
      right: -1px;
      border-right-width: 1px;
    }

    &:hover {
      .input-wrap-hover();
    }
  }

  &-input {
    width: 100%;
    // height: @input-height-base - 2px;
    height: @input-height-base;
    // padding: 0 @control-padding-horizontal - 1px;
    text-align: left;
    text-align: center;
    background-color: transparent;
    // border: 0;
    // border-radius: @border-radius-base;
    border: none;
    border-top: @border-width-base @border-style-base @border-color-base;
    border-bottom: @border-width-base @border-style-base @border-color-base;
    border-radius: 0;
    outline: 0;
    transition: all 0.3s linear;
    appearance: textfield !important;
    .placeholder();

    &[type='number']::-webkit-inner-spin-button,
    &[type='number']::-webkit-outer-spin-button {
      margin: 0;
      /* stylelint-disable-next-line property-no-vendor-prefix */
      -webkit-appearance: none;
      appearance: none;
    }
  }

  &-lg {
    padding: 0;
    font-size: @font-size-lg;

    .@{input-number-button-prefix-cls}-handler-wrap {
      height: @height-lg;
    }

    input {
      // height: @input-height-lg - 2px;
      height: @input-height-lg;
    }
  }

  &-sm {
    padding: 0;

    .@{input-number-button-prefix-cls}-handler-wrap {
      height: @height-sm;
    }

    input {
      // height: @input-height-sm - 2px;
      height: @input-height-sm;
      padding: 0 @control-padding-horizontal-sm - 1px;
    }
  }

  &-handler-wrap {
    position: absolute;
    top: 0;
    right: 0;
    // width: 22px;
    // height: 100%;
    z-index: 0;
    width: 100%;
    height: @input-height-base;
    // background: @input-number-handler-bg;
    // border-radius: 0 @border-radius-base @border-radius-base 0;
    // opacity: 0;
    // transition: opacity 0.24s linear 0.1s;

    // Fix input number inside Menu makes icon too large
    // We arise the selector priority by nest selector here
    // https://github.com/ant-design/ant-design/issues/14367
    .@{input-number-button-prefix-cls}-handler {
      .@{input-number-button-prefix-cls}-handler-up-inner,
      .@{input-number-button-prefix-cls}-handler-down-inner {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: auto;
        margin-right: 0;
        // font-size: 7px;
        font-size: @br-font-size-largest;
      }
    }

    .@{input-number-button-prefix-cls}-borderless & {
      border-left-width: 0;
    }

    // &::before,&::after {
    //   content: '';
    //   position: absolute;
    //   left: @border-radius-base;
    //   width: ~'calc(100% - 2 * @{border-radius-base})';
    //   height: 1px;
    //   background: @normal-color;
    // }

    // &::before {
    //   top: 0;
    // }

    // &::after {
    //   bottom: 0;
    // }
  }

  // &-handler-wrap:hover &-handler {
  //   height: 40%;
  // }

  // &:hover &-handler-wrap,&-focused &-handler-wrap {
  //   opacity: 1;
  // }

  &-handler-up {
    top: 0;
    // left: 0;
    right: 0;
    border-top-right-radius: @border-radius-base;
    border-bottom-right-radius: @border-radius-base;
    cursor: pointer;
    // &-inner {
    //   top: 50%;
    //   margin-top: -5px;
    //   text-align: center;
    // }
    // &:hover {
    //   height: 60% !important;
    // }
  }

  &-handler-down {
    top: 0;
    // right: 0;
    left: 0;
    // border-top: @border-width-base @border-style-base @border-color-base;
    // border-bottom-right-radius: @border-radius-base;
    border-top-left-radius: @border-radius-base;
    border-bottom-left-radius: @border-radius-base;
    cursor: pointer;
    // &-inner {
    //   top: 50%;
    //   text-align: center;
    //   transform: translateY(-50%);
    // }
    // &:hover {
    //   height: 60% !important;
    // }
    // .@{input-number-button-prefix-cls}-borderless & {
    //   border-top-width: 0;
    // }
  }

  &-handler-up-disabled,
  &-handler-down-disabled {
    color: @disabled-color;
    background: @disabled-bg;
    cursor: not-allowed;

    &:active {
      box-shadow: none;
    }
    &:hover {
      color: @disabled-color;
      background: @disabled-bg;
      border-color: @normal-color;
    }
  }

  &-handler-up-disabled:hover &-handler-up-inner,
  &-handler-down-disabled:hover &-handler-down-inner {
    color: @disabled-color;
  }

  &-borderless {
    box-shadow: none;
  }

  // ===================== Out Of Range =====================
  &-out-of-range {
    input {
      color: @error-color;
    }
  }
}

// bonree-start
.@{input-number-button-prefix-cls-focused} {
  .@{input-number-button-prefix-cls}-input-wrap {
    .@{input-number-button-prefix-cls}-input {
      border-color: @primary-color-hover;
      box-shadow: @br-box-shadow-base // 0 0 0 3px rgb(41 155 255 / 8%)
;
    }

    &::before,
    &::after {
      border-color: @primary-color-hover;
      opacity: 1;
    }
  }
}
// bonree-end
