/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import '../mixins/common.less';
@import './vars.less';

@form-item-prefix-cls: ~'@{css-prefix}mobile-form-item';
@input-prefix-cls: ~'@{css-prefix}mobile-input';
@input-group-prefix-cls: ~'@{css-prefix}mobile-input-group';
@textarea-prefix-cls: ~'@{css-prefix}mobile-textarea';
@button-prefix-cls: ~'@{css-prefix}mobile-button';
@numeric-prefix-cls: ~'@{css-prefix}mobile-numeric';

.@{form-item-prefix-cls} {
  margin-bottom: 12px;
  .clearfix();

  & & {
    margin-bottom: 0;
  }

  &&--mini,
  &&--small {
    margin-bottom: 8px;
  }

  &--medium &__content,
  &--medium &__label {
    line-height: var(--ti-form-item-medium-line-height, 36px);
  }

  &--small &__content,
  &--small &__label {
    line-height: var(--ti-form-item-small-line-height, 28px);
  }

  &--small &__error {
    padding-top: 2px;
  }

  &--mini &__content,
  &--mini &__label {
    line-height: var(--ti-form-item-mini-line-height, 24px);
  }

  &--mini &__error {
    padding-top: 1px;
  }

  &__label-wrap {
    float: left;

    .@{form-item-prefix-cls}__label {
      display: inline-block;
      float: none;
    }
  }

  &__label {
    text-align: right;
    vertical-align: middle;
    float: left;
    font-size: 16px;
    color: var(--ti-form-item-label-color, #333);
    line-height: 48px;
    padding-right: 8px;
    box-sizing: border-box;
  }

  &__value {
    float: right;

    .tiny-mobile-input-form__input {
      text-align: left;
    }
  }

  &__content {
    line-height: 48px;
    position: relative;
    font-size: var(--ti-form-item-label-font-size, 14px);
    .clearfix();

    .@{input-group-prefix-cls} {
      vertical-align: top;
    }

    .@{button-prefix-cls} + .@{button-prefix-cls} {
      margin-left: 8px;
    }
  }

  &__label.is-ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: initial;
  }

  &.is-error .is-vertical {
    margin-bottom: 36px;
  }

  .is-vertical {
    border-bottom: 1px solid #ddd;
  }

  &__error {
    color: var(--ti-form-item-error-color, #f5222d);
    font-size: var(--ti-form-item-error-font-size, 12px);
    line-height: 1;
    padding-top: 4px;
    position: absolute;
    top: 100%;
    left: 0;
  }

  &__error--inline {
    position: relative;
    top: auto;
    left: auto;
    display: inline-block;
    margin-left: 10px;
  }

  &.is-required:not(.is-no-asterisk) {
    .@{form-item-prefix-cls}__label-wrap > .@{form-item-prefix-cls}__label:before,
    .@{form-item-prefix-cls}__label:before {
      content: '*';
      color: var(--ti-form-item-error-color, #f5222d);
      margin-right: 4px;
    }
  }

  &.is-error {
    .@{input-prefix-cls}__inner,
    .@{input-prefix-cls}__inner:focus,
    .@{textarea-prefix-cls}__inner,
    .@{textarea-prefix-cls}__inner:focus {
      border-color: var(--ti-form-item-error-color, #f5222d);
    }

    .@{input-group-prefix-cls}__append,
    .@{input-group-prefix-cls}__prepend {
      .@{input-prefix-cls}__inner {
        border-color: transparent;
      }
    }

    .@{input-prefix-cls}__validateIcon {
      color: var(--ti-form-item-error-color, #f5222d);
    }

    .@{numeric-prefix-cls}__input-inner {
      &,
      &:focus {
        border-color: var(--ti-form-item-error-color, #f5222d);
      }
    }
  }

  &--feedback .@{input-prefix-cls}__validateIcon {
    display: inline-block;
  }

  .@{input-prefix-cls}__validateIcon {
    display: none;
  }
}

.@{css-prefix} {
  &mobile-zoom-in-top-enter-active,
  &mobile-zoom-in-top-leave-active {
    opacity: 1;
    transform: scaleY(1);
    transition:
      transform 0.3s cubic-bezier(0.23, 1, 0.32, 1),
      opacity 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    transform-origin: center top;
  }

  &mobile-zoom-in-top-enter,
  &mobile-zoom-in-top-leave-active {
    opacity: 0;
    transform: scaleY(0);
  }
}
