@import (reference) '../../style/themes/index';

@form-prefix-cls: ~'@{wd-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: @fluctuation-rise-text;
    }

    &-warning {
      color: @trade-selling-sellinging;
    }
  }

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

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

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

    // ======================= Cascader ========================
    .@{wd-prefix}-cascader-picker {
      &-arrow {
        margin-right: 19px;
      }

      &-clear {
        right: 32px;
      }
    }

    // ======================== Picker =========================
    // Fix issue: https://github.com/ant-design/ant-design/issues/4783
    .@{wd-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;
        }
      }
    }
  }

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

  // ======================== Warning ========================
  &-has-warning {
    .form-control-validation(@trade-selling-sellinging; @trade-selling-sellinging; @form-warning-input-bg; @trade-selling-hover; @trade-selling-sellinging-outline);

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

    // Select
    .@{wd-prefix}-select:not(.@{wd-prefix}-select-disabled):not(
        .@{wd-prefix}-select-customize-input
      ) {
      .@{wd-prefix}-select-selector {
        background-color: @form-warning-input-bg;
        border-color: @trade-selling-sellinging !important;
      }
      &.@{wd-prefix}-select-open .@{wd-prefix}-select-selector,
      &.@{wd-prefix}-select-focused .@{wd-prefix}-select-selector {
        .active(@trade-selling-sellinging, @trade-selling-hover, @trade-selling-sellinging-outline);
      }
    }

    // InputNumber, TimePicker
    .@{wd-prefix}-input-number,
    .@{wd-prefix}-picker {
      background-color: @form-warning-input-bg;
      border-color: @trade-selling-sellinging;

      &-focused,
      &:focus {
        .active(@trade-selling-sellinging, @trade-selling-hover, @trade-selling-sellinging-outline);
      }

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

    .@{wd-prefix}-cascader-picker:focus .@{wd-prefix}-cascader-input {
      .active(@trade-selling-sellinging, @trade-selling-hover, @trade-selling-sellinging-outline);
    }
  }

  // ========================= Error =========================
  &-has-error {
    // Input
    &.@{form-item-prefix-cls} {
      .form-control-validation(@fluctuation-rise-rise; @fluctuation-rise-rise; @form-error-input-bg; @fluctuation-rise-hover; @fluctuation-rise-rise-outline);
    }

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

    // Select
    .@{wd-prefix}-select:not(.@{wd-prefix}-select-disabled):not(
        .@{wd-prefix}-select-customize-input
      ) {
      .@{wd-prefix}-select-selector {
        border-color: @fluctuation-rise-rise;

        &:hover {
          border-color: @fluctuation-rise-hover;
        }
      }
      &:not(.@{wd-prefix}-select-borderless) {
        .@{wd-prefix}-select-selector {
          background-color: transparent;
        }
      }
      &.@{wd-prefix}-select-open .@{wd-prefix}-select-selector,
      &.@{wd-prefix}-select-focused .@{wd-prefix}-select-selector {
        background-color: @form-error-input-bg;
        .active(@fluctuation-rise-rise, @fluctuation-rise-hover, @fluctuation-rise-rise-outline);
      }
    }

    // fixes https://github.com/ant-design/ant-design/issues/20482
    .@{wd-prefix}-input-group-addon,
    .@{wd-prefix}-input-number-group-addon {
      .@{wd-prefix}-select {
        &.@{wd-prefix}-select-single:not(.@{wd-prefix}-select-customize-input)
          .@{wd-prefix}-select-selector {
          background-color: inherit;
          border: 0;
          box-shadow: none;
        }
      }
    }

    .@{wd-prefix}-select.@{wd-prefix}-select-auto-complete {
      .@{wd-prefix}-input:focus {
        border-color: @fluctuation-rise-rise;
      }
    }

    // InputNumber, TimePicker
    .@{wd-prefix}-input-number,
    .@{wd-prefix}-picker {
      background-color: transparent;
      border-color: @fluctuation-rise-rise;

      &-focused,
      &:focus {
        background-color: @form-error-input-bg;
        .active(@fluctuation-rise-rise, @fluctuation-rise-hover, @fluctuation-rise-rise-outline);
      }

      &:not([disabled]):not(.@{wd-prefix}-picker-focused):hover {
        // background-color: @form-error-input-bg;
        border-color: @fluctuation-rise-hover;
      }
    }

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

    // Cascader
    .@{wd-prefix}-cascader-picker {
      &:hover
        .@{wd-prefix}-cascader-picker-label:hover
        + .@{wd-prefix}-cascader-input.@{wd-prefix}-input {
        border-color: @fluctuation-rise-rise;
      }

      &:focus .@{wd-prefix}-cascader-input {
        background-color: @form-error-input-bg;
        .active(@fluctuation-rise-rise, @fluctuation-rise-hover, @fluctuation-rise-rise-outline);
      }
    }

    // Transfer
    .@{wd-prefix}-transfer {
      &-list {
        border-color: @fluctuation-rise-rise;

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

          &:hover {
            .hover();
          }

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

    // Radio.Group
    .@{wd-prefix}-radio-button-wrapper {
      border-color: @fluctuation-rise-rise !important;

      &:not(:first-child) {
        &::before {
          background-color: @fluctuation-rise-rise;
        }
      }
    }

    // Mentions
    .@{wd-prefix}-mentions {
      border-color: @fluctuation-rise-rise !important;

      &-focused,
      &:focus {
        .active(@fluctuation-rise-rise, @fluctuation-rise-hover, @fluctuation-rise-rise-outline);
      }
    }
  }

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