@root-entry-name: 'default';
@import (reference) '~antd/es/style/themes/index.less';
@import (reference) '~antd/lib/input/style/mixin.less';
@import './grid.less';
@import './animation.less';

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

.@{form-item-cls} {
  display: flex;
  margin-bottom: @form-item-margin-bottom - 2;
  position: relative;
  font-size: @font-size-base;

  &-label {
    line-height: @height-base;
    min-height: @height-base - 2;
    label {
      cursor: text;
    }
  }

  textarea.@{ant-prefix}-input {
    height: auto;
  }

  // input[type=file]
  .@{ant-prefix}-upload {
    background: transparent;
  }

  .@{ant-prefix}-upload.@{ant-prefix}-upload-drag {
    background: @background-color-light;
  }

  input[type='radio'],
  input[type='checkbox'] {
    width: @font-size-base;
    height: @font-size-base;
  }

  // Radios and checkboxes on same line
  .@{ant-prefix}-radio-inline,
  .@{ant-prefix}-checkbox-inline {
    display: inline-block;
    margin-left: 8px;
    font-weight: normal;
    vertical-align: middle;
    cursor: pointer;

    &:first-child {
      margin-left: 0;
    }
  }

  .@{ant-prefix}-checkbox-vertical,
  .@{ant-prefix}-radio-vertical {
    display: block;
  }

  .@{ant-prefix}-checkbox-vertical + .@{ant-prefix}-checkbox-vertical,
  .@{ant-prefix}-radio-vertical + .@{ant-prefix}-radio-vertical {
    margin-left: 0;
  }

  .@{ant-prefix}-input-number {
    width: 100%;

    + .@{ant-prefix}-form-text {
      margin-left: 8px;
    }

    &-handler-wrap {
      z-index: 2; // https://github.com/ant-design/ant-design/issues/6289
    }
  }

  .@{ant-prefix}-select,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker {
    width: 100%;
  }

  // Don't impact select inside input group
  .@{ant-prefix}-input-group .@{ant-prefix}-select,
  .@{ant-prefix}-input-group .@{ant-prefix}-cascader-picker {
    width: auto;
  }
}

.@{form-item-cls}-label {
  position: relative;
  display: flex;

  &-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &-tooltip {
    cursor: help;

    * {
      cursor: help;
    }

    label {
      border-bottom: 1px dashed currentColor;
    }
  }
}

.@{form-item-cls}-label {
  color: @heading-color;
}

.@{form-item-cls}-label-align-left {
  > .@{form-item-cls}-label {
    justify-content: flex-start;
  }
}

.@{form-item-cls}-label-align-right {
  > .@{form-item-cls}-label {
    justify-content: flex-end;
  }
}

.@{form-item-cls}-label-wrap {
  .@{form-item-cls}-label {
    label {
      white-space: pre-line;
      word-break: break-all;
    }
  }
}

.@{form-item-cls}-feedback-layout-terse {
  margin-bottom: 8px;

  &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
    margin-bottom: 0;
  }
}

.@{form-item-cls}-feedback-layout-loose {
  margin-bottom: 22px;

  &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
    margin-bottom: 0;
  }
}

.@{form-item-cls}-feedback-layout-none {
  margin-bottom: 0px;

  &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
    margin-bottom: 0;
  }
}

.@{form-item-cls}-control {
  flex: 1;
  max-width: 100%;

  .@{form-item-cls}-control-content {
    display: flex;

    .@{form-item-cls}-control-content-component {
      width: 100%;
      min-height: @height-base - 2;
      line-height: @height-base + 2;

      &-has-feedback-icon {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
      }
    }

    .@{form-item-cls}-addon-before {
      margin-right: 8px;
      display: inline-flex;
      align-items: center;
      min-height: @height-base;
      flex-shrink: 0;
    }

    .@{form-item-cls}-addon-after {
      margin-left: 8px;
      display: inline-flex;
      align-items: center;
      min-height: @height-base;
      flex-shrink: 0;
    }
  }

  .@{form-item-cls}-help,
  .@{form-item-cls}-extra {
    min-height: 22px;
    line-height: 22px;
    color: @text-color-secondary;
  }
}

.@{form-item-cls}-size-small {
  font-size: @font-size-sm;

  line-height: @height-sm;

  .@{form-item-cls}-label {
    line-height: @height-sm;
    min-height: @height-sm - 2;
  }

  .@{form-item-cls}-control-content {
    .@{form-item-cls}-control-content-component {
      min-height: @height-sm - 2;
      line-height: @height-sm + 2;
    }
  }

  .@{form-item-cls}-help,
  .@{form-item-cls}-extra {
    min-height: @height-sm - 4;
    line-height: @height-sm - 4;
  }

  .@{form-item-cls}-control-content {
    min-height: @height-sm - 2;
  }

  .@{form-item-cls}-label > label {
    height: @height-sm - 2;
  }

  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker {
    padding: 0px 11px;

    input {
      height: @height-sm - 2;
      font-size: @font-size-sm;
    }
  }

  .@{ant-prefix}-cascader-picker {
    height: @height-sm - 2;

    input {
      padding: 0 7px;
      height: @height-sm - 2;
      font-size: @font-size-sm;
    }
  }

  .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector {
    padding: 0px 11px;
    height: @height-sm - 2;
    font-size: @font-size-sm;
    line-height: @height-sm;

    .@{ant-prefix}-select-selection-search {
      height: @height-sm;
      line-height: @height-sm - 2;

      &-input {
        height: @height-sm;
        line-height: @height-sm - 2;
      }
    }

    .@{ant-prefix}-select-selection-placeholder {
      line-height: @height-sm - 2;
      height: @height-sm;
    }

    .@{ant-prefix}-select-selection-item {
      line-height: @height-sm - 2;
      height: @height-sm;
    }
  }

  .@{ant-prefix}-select-multiple:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector {
    padding: 0px 2px;
    height: @height-sm - 2;
    font-size: @font-size-sm;
    line-height: @height-sm;

    &::after {
      height: @height-sm - 8;
      line-height: @height-sm - 8;
    }

    .@{ant-prefix}-select-selection-search {
      height: @height-sm - 8;
      line-height: @height-sm - 8;
      margin-inline-start: 0;

      &-input {
        height: @height-sm - 12;
        line-height: @height-sm - 12;
      }
    }

    .@{ant-prefix}-select-selection-placeholder {
      line-height: @height-sm - 8;
      height: @height-sm - 8;
      left: 4px;
    }

    .@{ant-prefix}-select-selection-overflow-item {
      align-self: flex-start;
    }

    .@{ant-prefix}-select-selection-item {
      line-height: @height-sm - 10;
      height: @height-sm - 8;
    }
  }

  &.@{form-item-cls}-feedback-layout-terse {
    margin-bottom: 8px;

    &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
      margin-bottom: 0;
    }
  }

  &.@{form-item-cls}-feedback-layout-loose {
    margin-bottom: @height-sm - 4;

    &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
      margin-bottom: 0;
    }
  }
}

.@{form-item-cls}-size-large {
  font-size: @font-size-lg;
  line-height: @height-lg;

  .@{form-item-cls}-label {
    line-height: @height-lg;
    min-height: @height-lg - 2;
  }

  .@{form-item-cls}-control-content {
    .@{form-item-cls}-control-content-component {
      min-height: @height-lg - 2;
      line-height: @height-lg;
    }
  }

  .@{form-item-cls}-help,
  .@{form-item-cls}-extra {
    min-height: @form-item-margin-bottom;
    line-height: @form-item-margin-bottom;
  }

  .@{form-item-cls}-control-content {
    min-height: @height-lg - 2;
  }

  .@{ant-prefix}-input {
    font-size: @font-size-lg;
  }

  .@{ant-prefix}-input-number {
    font-size: @font-size-lg;

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

  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-picker {
    padding: 0px 11px;
    line-height: @height-lg - 2;

    input {
      height: @height-lg - 2;
      font-size: @font-size-lg;
    }
  }

  .@{ant-prefix}-btn {
    height: @height-lg;
    padding: 0px 8px;
  }

  .@{ant-prefix}-radio-button-wrapper {
    height: @height-lg;
    line-height: @height-lg;
  }

  .@{ant-prefix}-cascader-picker {
    height: @height-lg - 2;

    input {
      padding: 0px 11px;
      height: @height-lg - 2;
      font-size: @font-size-lg;
    }
  }

  .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector {
    padding: 0px 11px;
    height: @height-lg;
    font-size: @font-size-lg;
    line-height: @height-lg;

    .@{ant-prefix}-select-selection-search {
      height: @height-lg;
      line-height: @height-lg - 2;

      &-input {
        height: @height-lg;
        line-height: @height-lg - 2;
      }
    }

    .@{ant-prefix}-select-selection-placeholder {
      line-height: @height-lg - 2;
      height: @height-lg;
    }

    .@{ant-prefix}-select-selection-item {
      line-height: @height-lg - 2;
      height: @height-lg;
    }
  }

  .@{ant-prefix}-select-multiple:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector {
    padding: 0px 2px;
    height: @height-lg - 2;
    font-size: @font-size-lg;
    line-height: @height-lg;

    &::after {
      height: @height-lg - 8;
      line-height: @height-lg - 8;
    }

    .@{ant-prefix}-select-selection-search {
      height: @height-lg - 8;
      line-height: @height-lg - 8;

      &-input {
        height: @height-lg - 12;
        line-height: @height-lg - 12;
      }
    }

    .@{ant-prefix}-select-selection-placeholder {
      line-height: @height-lg - 8;
      height: @height-lg - 8;
    }

    .@{ant-prefix}-select-selection-overflow-item {
      align-self: flex-start;
    }

    .@{ant-prefix}-select-selection-item {
      line-height: @height-lg - 10;
      height: @height-lg - 8;
    }
  }

  &.@{form-item-cls}-feedback-layout-terse {
    margin-bottom: 8px;

    &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
      margin-bottom: 0;
    }
  }

  &.@{form-item-cls}-feedback-layout-loose {
    margin-bottom: @form-item-margin-bottom;

    &.@{form-item-cls}-feedback-has-text:not(.@{form-item-cls}-inset) {
      margin-bottom: 0;
    }
  }
}

.@{form-item-cls} {
  &-layout-vertical {
    display: block;

    .@{form-item-cls}-label {
      min-height: @height-base - 10;
      line-height: 1.5715;
    }
  }
}

.@{form-item-cls}-feedback-layout-popover {
  margin-bottom: 8px;
}

.@{form-item-cls}-label-tooltip-icon {
  margin-left: 4px;
  color: #00000073;
  display: flex;
  align-items: center;
  max-height: @height-base;

  span {
    display: inline-flex;
  }
}

.@{form-item-cls}-control-align-left {
  .@{form-item-cls}-control-content {
    justify-content: flex-start;
  }
}

.@{form-item-cls}-control-align-right {
  .@{form-item-cls}-control-content {
    justify-content: flex-end;
  }
}

.@{form-item-cls}-control-wrap {
  .@{form-item-cls}-control {
    white-space: pre-line;
    word-break: break-all;
  }
}

.@{form-item-cls}-asterisk {
  color: @error-color;
  margin-right: 4px;
  display: inline-block;
  font-family: SimSun, sans-serif;
}

.@{form-item-cls}-optional {
  color: rgba(0, 0, 0, 0.45);
}

.@{form-item-cls}-colon {
  margin-left: 2px;
  margin-right: 8px;
}

.@{form-item-cls}-help,
.@{form-item-cls}-extra {
  clear: both;
  min-height: @form-item-margin-bottom - 2;
  color: rgba(0, 0, 0, 0.45);
  transition: color 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
  padding-top: 0px;
}

.@{form-item-cls}-fullness {
  > .@{form-item-cls}-control {
    > .@{form-item-cls}-control-content {
      > .@{form-item-cls}-control-content-component {
        > *:first-child {
          width: 100%;
        }
      }
    }
  }
}

.@{form-item-cls}-control-content-component-has-feedback-icon {
  border-radius: 2px;
  border: 1px solid @border-color-base;
  padding-right: 8px;
  transition: all 0.3s;
  touch-action: manipulation;
  outline: none;

  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input,
  .@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input {
    border: none !important;
    box-shadow: none !important;
  }
}

.@{form-item-cls}-bordered-none {
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input,
  .@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector,
  .@{ant-prefix}-input {
    border: none !important;
    box-shadow: none !important;
  }

  .@{ant-prefix}-input-number-handler-wrap {
    border: none !important;

    .@{ant-prefix}-input-number-handler {
      border: none !important;
    }
  }
}

.@{form-item-cls}-inset {
  border-radius: 2px;
  border: 1px solid @border-color-base;
  padding-left: 12px;
  transition: 0.3s all;

  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input,
  .@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input {
    border: none !important;
    box-shadow: none !important;
  }

  .@{ant-prefix}-input-number-handler-wrap {
    border: none !important;

    .@{ant-prefix}-input-number-handler {
      border: none !important;
    }
  }

  &:hover {
    .hover();
  }
}

.@{form-item-cls}-inset-active {
  .active();
}

.@{form-item-cls}-active {
  .@{form-item-cls}-control-content-component-has-feedback-icon {
    .active();
  }

  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-cascader-picker:focus .@{ant-prefix}-cascader-input,
  .@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
    .@{ant-prefix}-select-selector,
  .@{ant-prefix}-input {
    .active();
  }
}

.@{form-item-cls} {
  &:hover {
    .@{form-item-cls}-control-content-component-has-feedback-icon {
      .hover();
    }
  }
}

.@{form-item-cls}-error {
  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input {
    border-color: @error-color !important;
  }

  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper:hover,
  .@{ant-prefix}-input:hover {
    border-color: @error-color !important;
  }

  .@{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: @error-color !important;
    }

    &.@{ant-prefix}-select-open .@{ant-prefix}-select-selector,
    &.@{ant-prefix}-select-focused .@{ant-prefix}-select-selector {
      .active(@error-color);
    }
  }

  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker {
    background-color: @form-error-input-bg;
    border-color: @error-color;

    &-focused,
    &:focus {
      .active(@error-color);
    }

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

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

  .@{ant-prefix}-input-affix-wrapper-focused,
  .@{ant-prefix}-input-affix-wrapper:focus,
  .@{ant-prefix}-input-focused,
  .@{ant-prefix}-input:focus {
    .active(@error-color);
  }
}

.@{form-item-cls}-error-help {
  color: @error-color !important;
}

.@{form-item-cls}-warning-help {
  color: @warning-color !important;
}

.@{form-item-cls}-success-help {
  color: @success-color !important;
}

.@{form-item-cls}-warning {
  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input {
    border-color: @warning-color !important;
  }

  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper:hover,
  .@{ant-prefix}-input:hover {
    border-color: @warning-color !important;
  }

  .@{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: @warning-color !important;
    }

    &.@{ant-prefix}-select-open .@{ant-prefix}-select-selector,
    &.@{ant-prefix}-select-focused .@{ant-prefix}-select-selector {
      .active(@warning-color);
    }
  }

  .@{ant-prefix}-input-number,
  .@{ant-prefix}-picker {
    background-color: @form-warning-input-bg;
    border-color: @warning-color;

    &-focused,
    &:focus {
      .active(@warning-color);
    }

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

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

  .@{ant-prefix}-input-affix-wrapper-focused,
  .@{ant-prefix}-input-affix-wrapper:focus,
  .@{ant-prefix}-input-focused,
  .@{ant-prefix}-input:focus {
    .active(@warning-color);
  }
}

.@{form-item-cls}-success {
  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input {
    border-color: @success-color !important;
  }

  .@{ant-prefix}-select-selector,
  .@{ant-prefix}-cascader-picker,
  .@{ant-prefix}-picker,
  .@{ant-prefix}-input,
  .@{ant-prefix}-input-number,
  .@{ant-prefix}-input-affix-wrapper,
  .@{ant-prefix}-input-affix-wrapper:hover,
  .@{ant-prefix}-input:hover {
    border-color: @success-color !important;
  }

  .@{ant-prefix}-input-affix-wrapper-focused,
  .@{ant-prefix}-input-affix-wrapper:focus,
  .@{ant-prefix}-input-focused,
  .@{ant-prefix}-input:focus {
    border-color: @success-color !important;
    border-right-width: 1px !important;
    outline: 0;
  }
}
