@import './index.less';
@import '../../style/mixins/index';

.@{form-item-prefix-cls} {
  // ================================================================
  // =                            Status                            =
  // ================================================================
  /* Some non-status related component style is in `components.less` */

  &-has-feedback {
    // ========================= Input =========================
    .@{mk-prefix}-input {
      padding-right: 24px;
    }
    // https://github.com/ant-design/ant-design/issues/19884
    .@{mk-prefix}-input-affix-wrapper {
      .@{mk-prefix}-input-suffix {
        padding-right: 18px;
      }
    }

    // Fix issue: https://github.com/ant-design/ant-design/issues/7854
    .@{mk-prefix}-input-search:not(.@{mk-prefix}-input-search-enter-button) {
      .@{mk-prefix}-input-suffix {
        right: 28px;
      }
    }

    // ======================== Switch =========================
    .@{mk-prefix}-switch {
      margin: 2px 0 4px;
    }

    // ======================== Select =========================
    // Fix overlapping between feedback icon and <Select>'s arrow.
    // https://github.com/ant-design/ant-design/issues/4431
    > .@{mk-prefix}-select .@{mk-prefix}-select-arrow,
    > .@{mk-prefix}-select .@{mk-prefix}-select-selection__clear,
    :not(.@{mk-prefix}-input-group-addon) > .@{mk-prefix}-select .@{mk-prefix}-select-arrow,
    :not(.@{mk-prefix}-input-group-addon)
    > .@{mk-prefix}-select
    .@{mk-prefix}-select-selection__clear {
      right: 28px;
    }
    > .@{mk-prefix}-select .@{mk-prefix}-select-selection-selected-value,
    :not(.@{mk-prefix}-input-group-addon)
    > .@{mk-prefix}-select
    .@{mk-prefix}-select-selection-selected-value {
      padding-right: 42px;
    }

    // ======================= Cascader ========================
    .@{mk-prefix}-cascader-picker {
      &-arrow {
        margin-right: 17px;
      }
      &-clear {
        right: 28px;
      }
    }

    // ======================== Picker =========================
    // Fix issue: https://github.com/ant-design/ant-design/issues/4783
    .@{mk-prefix}-picker {
      padding-right: @input-padding-horizontal-base + @font-size-base * 1.3;

      &-large {
        padding-right: @input-padding-horizontal-lg + @font-size-base * 1.3;
      }

      &-small {
        padding-right: @input-padding-horizontal-sm + @font-size-base * 1.3;
      }
    }

    // ===================== Status Group ======================
    &.@{form-item-prefix-cls} {
      &-has-success,
      &-has-warning,
      &-has-error,
      &-is-validating {
        // ====================== Icon ======================
        .@{form-item-prefix-cls}-children-icon {
          position: absolute;
          top: 50%;
          right: 0;
          z-index: 1;
          width: @input-height-base;
          height: 20px;
          margin-top: -10px;
          font-size: @font-size-base;
          line-height: 20px;
          text-align: center;
          visibility: visible;
          animation: zoomIn 0.3s @ease-out-back;
          pointer-events: none;

          & svg {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            margin: auto;
          }
        }
      }
    }
  }

  // ======================== Success ========================
  &-has-success {
    &.@{form-item-prefix-cls}-has-feedback .@{form-item-prefix-cls}-children-icon {
      color: @success-color;
      animation-name: diffZoomIn1 !important;
    }
  }

  // ======================== Warning ========================
  &-has-warning {
    .form-control-validation(@warning-color; @warning-color; @form-warning-input-bg);

    &.@{form-item-prefix-cls}-has-feedback .@{form-item-prefix-cls}-children-icon {
      color: @warning-color;
      animation-name: diffZoomIn3 !important;
    }

    //select
    .@{mk-prefix}-select:not(.@{mk-prefix}-select-borderless) {
      .@{mk-prefix}-select-selector {
        border-color: @warning-color !important;
      }
      &.@{mk-prefix}-select-open .@{mk-prefix}-select-selector,
      &.@{mk-prefix}-select-focused .@{mk-prefix}-select-selector {
        .active(@warning-color);
      }
    }

    //input-number, timepicker
    .@{mk-prefix}-input-number,
    .@{mk-prefix}-picker {
      border-color: @warning-color;
      &-focused,
      &:focus {
        .active(@warning-color);
      }
      &:not([disabled]):hover {
        border-color: @warning-color;
      }
    }

    .@{mk-prefix}-cascader-picker:focus .@{mk-prefix}-cascader-input {
      .active(@warning-color);
    }
  }

  // ========================= Error =========================
  &-has-error {
    .form-control-validation(@error-color; @error-color; @form-error-input-bg);

    &.@{form-item-prefix-cls}-has-feedback .@{form-item-prefix-cls}-children-icon {
      color: @error-color;
      animation-name: diffZoomIn2 !important;
    }

    //select
    .@{mk-prefix}-select:not(.@{mk-prefix}-select-borderless) {
      .@{mk-prefix}-select-selector {
        border-color: @error-color;
      }
      &.@{mk-prefix}-select-open .@{mk-prefix}-select-selector,
      &.@{mk-prefix}-select-focused .@{mk-prefix}-select-selector {
        .active(@error-color);
      }
    }

    .@{mk-prefix}-select {
      &.@{mk-prefix}-select-li {
        .@{mk-prefix}-select-selector {
          .li_border_error();
        }
        &.@{mk-prefix}-select-open .@{mk-prefix}-select-selector,
        &.@{mk-prefix}-select-focused .@{mk-prefix}-select-selector {
          .li_border_error();
        }
      }
    }

    .@{mk-prefix}-input {
      &.@{mk-prefix}-input-li {
        .li_border_error();
      }
    }

    .@{mk-prefix}-input-password {
      &.@{mk-prefix}-input-password-li {
        .li_border_error();
        .mkui-input{
          border-bottom: 0 !important;
        }
      }
    }

    // fixes https://github.com/ant-design/ant-design/issues/20482
    .@{mk-prefix}-input-group-addon .@{mk-prefix}-select {
      &.@{mk-prefix}-select-single:not(.@{mk-prefix}-select-customize-input)
      .@{mk-prefix}-select-selector {
        border: 0;
      }
    }

    .@{mk-prefix}-select.@{mk-prefix}-select-auto-complete {
      .@{mk-prefix}-input:focus {
        border-color: @error-color;
      }
    }

    //input-number, timepicker
    .@{mk-prefix}-input-number,
    .@{mk-prefix}-picker {
      border-color: @error-color;
      &-focused,
      &:focus {
        .active(@error-color);
      }
      &:not([disabled]):hover {
        border-color: @error-color;
      }
    }

    .@{mk-prefix}-input-number {
      &.@{mk-prefix}-input-number-li {
        .li_border_error();
      }
    }

    .@{mk-prefix}-picker {
      &.@{mk-prefix}-picker-li {
        .li_border_error();
      }
    }

    .@{mk-prefix}-mention-wrapper {
      .@{mk-prefix}-mention-editor {
        &,
        &:not([disabled]):hover {
          border-color: @error-color;
        }
      }
      &.@{mk-prefix}-mention-active:not([disabled]) .@{mk-prefix}-mention-editor,
      .@{mk-prefix}-mention-editor:not([disabled]):focus {
        .active(@error-color);
      }
    }

    .@{mk-prefix}-cascader-picker:focus .@{mk-prefix}-cascader-input {
      .active(@error-color);
    }

    // transfer
    .@{mk-prefix}-transfer {
      &-list {
        border-color: @error-color;

        &-search:not([disabled]) {
          border-color: @input-border-color;

          &:hover {
            .hover();
          }

          &:focus {
            .active();
          }
        }
      }
    }
  }

  // Patch to keep error explain color
  &-has-error-leave {
    .@{form-item-prefix-cls}-explain {
      color: @error-color;
    }
  }

  // ====================== Validating =======================
  &-is-validating {
    &.@{form-item-prefix-cls}-has-feedback .@{form-item-prefix-cls}-children-icon {
      display: inline-block;
      color: @primary-color;
    }
  }
}
