/**
 *
 * 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 (reference) '../../style/themes/index';
@import './index.less';

@form-prefix-cls: ~'@{ant-prefix}-form';
@form-item-prefix-cls: ~'@{form-prefix-cls}-item';

.@{form-item-prefix-cls} {
  // ================================================================
  // =                            Status                            =
  // ================================================================

  /* Some non-status related component style is in `components.less` */

  // ========================= Explain =========================

  /* To support leave along ErrorList. We add additional className to handle explain style */

  &-explain {

    &-error {
      color: @error-color;
    }

    &-warning {
      color: @warning-color;
    }
  }

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

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

    // ======================== Switch =========================
    .@{ant-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
    > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
    > .@{ant-prefix}-select .@{ant-prefix}-select-clear,
    :not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
    :not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-clear {
      right: 32px;
    }
    > .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
    :not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value {
      padding-right: 42px;
    }

    // ======================= Cascader ========================
    .@{ant-prefix}-cascader-picker {

      &-arrow {
        margin-right: 19px;
      }

      &-clear {
        right: 32px;
      }
    }

    // ======================== Picker =========================
    // Fix issue: https://github.com/ant-design/ant-design/issues/4783
    .@{ant-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 .3s @ease-out-back;
          pointer-events: none;
        }
      }
    }
  }

  // ======================== 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
    .@{ant-prefix}-select:not(.@{ant-prefix}-select-disabled):not(.@{ant-prefix}-select-customize-input) {
      .@{ant-prefix}-select-selector {
        background-color: @form-warning-input-bg;
        border-color: @input-warning-border-color !important;

        &:hover {
          background-color: @input-warning-hover-bg;
          border-color: @input-warning-hover-border-color !important;
        }
      }
      &.@{ant-prefix}-select-open .@{ant-prefix}-select-selector,
      &.@{ant-prefix}-select-focused .@{ant-prefix}-select-selector {
        .active(@warning-color);
        background-color: @input-warning-active-bg;
        border-color: @input-warning-active-border-color !important;
      }
    }

    // InputNumber, TimePicker
    .@{ant-prefix}-input-number:not(.@{ant-prefix}-input-number-disabled),
    .@{ant-prefix}-picker:not(.@{ant-prefix}-picker-disabled) {
      background-color: @form-warning-input-bg;
      border-color: @input-warning-border-color;

      &:focus {
        .active(@warning-color);
        background-color: @input-warning-active-bg;
        border-color: @input-warning-active-border-color;
      }

      &:not([disabled]):hover {
        background-color: @input-warning-hover-bg;
        border-color: @input-warning-hover-border-color;
      }
    }

    // Cascader
    .@{ant-prefix}-cascader-multiple-wrapper {
      background-color: @form-warning-input-bg;
      border-color: @input-warning-border-color !important;

      &:hover {
        background-color: @input-warning-hover-bg;
        border-color: @input-warning-hover-border-color !important;
      }
    }
    .@{ant-prefix}-cascader-picker-focused .@{ant-prefix}-cascader-multiple-wrapper {
      .active(@warning-color);
      background-color: @input-warning-active-bg;
      border-color: @input-warning-active-border-color !important;
    }
    .@{ant-prefix}-cascader-picker:focus .@{ant-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
    .@{ant-prefix}-select:not(.@{ant-prefix}-select-disabled):not(.@{ant-prefix}-select-customize-input) {
      .@{ant-prefix}-select-selector {
        background-color: @form-error-input-bg;
        border-color: @input-error-border-color !important;

        &:hover {
          background-color: @input-error-hover-bg;
          border-color: @input-error-hover-border-color !important;
        }
      }
      &.@{ant-prefix}-select-open .@{ant-prefix}-select-selector,
      &.@{ant-prefix}-select-focused .@{ant-prefix}-select-selector {
        .active(@error-color);
        background-color: @input-error-active-bg;
        border-color: @input-error-active-border-color !important;
      }
    }

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

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

    // InputNumber, TimePicker
    .@{ant-prefix}-input-number:not(.@{ant-prefix}-input-number-disabled),
    .@{ant-prefix}-picker:not(.@{ant-prefix}-picker-disabled) {
      background-color: @form-error-input-bg;
      border-color: @input-error-border-color;

      &:focus {
        .active(@error-color);
        background-color: @input-error-active-bg;
        border-color: @input-error-active-border-color;
      }

      &:not([disabled]):hover {
        background-color: @input-error-hover-bg;
        border-color: @input-error-hover-border-color;
      }
    }

    .@{ant-prefix}-picker-focused:not(.@{ant-prefix}-picker-disabled) {
      background-color: @input-error-active-bg;
      border-color: @input-error-active-border-color;
    }

    .@{ant-prefix}-mention-wrapper {
      .@{ant-prefix}-mention-editor {

        &,
        &:not([disabled]):hover {
          background-color: @form-error-input-bg;
          border-color: @error-color;
        }
      }
      &.@{ant-prefix}-mention-active:not([disabled]) .@{ant-prefix}-mention-editor,
      .@{ant-prefix}-mention-editor:not([disabled]):focus {
        .active(@error-color);
      }
    }

    // Cascader
    .@{ant-prefix}-cascader-multiple-wrapper {
      background-color: @form-error-input-bg;
      border-color: @input-error-border-color !important;

      &:hover {
        background-color: @input-error-hover-bg;
        border-color: @input-error-hover-border-color !important;
      }
    }
    .@{ant-prefix}-cascader-picker-focused .@{ant-prefix}-cascader-multiple-wrapper {
      .active(@error-color);
      background-color: @input-error-active-bg;
      border-color: @input-error-active-border-color !important;
    }

    // .@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input {
    //   background-color: @form-error-input-bg;
    //   .active(@error-color);
    // }

    // transfer
    .@{ant-prefix}-transfer {

      &-list {
        border-color: @error-color;

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

          &:hover {
            .hover();
          }

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

    // RadioGroup
    .@{ant-prefix}-radio-button-wrapper {
      border-color: @error-color !important;

      &:not(:first-child) {

        &::before {
          background-color: @error-color;
        }
      }
    }
  }

  // ====================== Validating =======================

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