/**
* 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 '../mixins/input.less';
@import '../mixins/common.less';
@import '../custom.less';
@import './vars.less';
@import '../transition/icon.less';

@textarea-prefix-cls: ~'@{css-prefix}textarea';
@input-prefix-cls: ~'@{css-prefix}input';

.@{textarea-prefix-cls} {
  .inject-Textarea-vars();

  position: relative;
  display: inline-block;
  width: 100%;
  vertical-align: bottom;
  font-size: var(--tv-Textarea-font-size);

  &.is-disabled &__inner {
    background-color: var(--tv-Textarea-disabled-bg-color);
    border-color: var(--tv-Textarea-disabled-border-color);
    color: var(--tv-Textarea-disabled-text-color);
    cursor: not-allowed;
    .placeholder(@color: var(--tv-Textarea-placeholder-text-color));
  }

  &.is-disabled {
    &:hover {
      border-color: var(--tv-Textarea-disabled-border-color);
    }
  }

  &.is-exceed {
    .@{textarea-prefix-cls}__inner {
      border-color: var(--tv-Textarea-exceed-text-color);
    }

    .@{input-prefix-cls}__count {
      color: var(--tv-Textarea-exceed-text-color);

      &-text-length {
        color: var(--tv-Textarea-exceed-text-color);
      }
    }
  }

  .@{input-prefix-cls}__count {
    color: var(--tv-Textarea-count-color);
    font-size: var(--tv-Textarea-count-font-size);
    text-align: right;
    position: absolute;
    z-index: 2;
    line-height: 1.5;
    bottom: 1px;
    right: var(--tv-Textarea-count-right);
    padding-right: var(--tv-Textarea-count-padding-right);
    background-color: var(--tv-Textarea-count-bg-color);

    &-text-length {
      color: var(--tv-Textarea-count-text-length-color);
    }
  }

  &__inner {
    display: block;
    width: 100%;
    min-height: 60px;
    min-height: calc(var(--tv-Textarea-height, 30px) * 2);
    color: var(--tv-Textarea-text-color);
    border: 1px solid var(--tv-Textarea-border-color);
    border-radius: var(--tv-Textarea-border-radius);
    background: var(--tv-Textarea-bg-color);
    padding: var(--tv-Textarea-padding-y) var(--tv-Textarea-padding-x);
    padding-bottom: var(--tv-Textarea-padding-bottom);
    line-height: 1.5;
    font-size: var(--tv-Textarea-font-size);
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    .placeholder(@color: var(--tv-Textarea-placeholder-text-color));

    &:hover {
      border-color: var(--tv-Textarea-inner-hover-border-color);
    }

    &:focus {
      border-color: var(--tv-Textarea-inner-active-border-color);
    }

    .@{textarea-prefix-cls}:has(&:focus) {
      border-color: var(--tv-Textarea-active-border-color);
    }

    &:hover,
    &:focus {
      outline: 0;
    }

    &.@{textarea-prefix-cls}__fix-height {
      min-height: 30px;
      height: 30px;
      padding: 0 8px;
      line-height: 30px;
      overflow: hidden;
    }
  }

  .@{textarea-prefix-cls}__inner {
    &::-webkit-scrollbar {
      width: 16px;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 8px;
      background-clip: content-box;
      border: 4px solid transparent;
    }
  }

  .@{textarea-prefix-cls}__inner-con {
    position: relative;
    display: block;
    height: 30px;
    width: 100%;

    .@{textarea-prefix-cls}__inner {
      min-width: 160px;
      position: absolute;
      z-index: 2000;
      top: 0;
      left: 0;
    }
  }

  &.is-display-only {
    .@{textarea-prefix-cls}__inner-con {
      height: auto;

      .@{textarea-prefix-cls}__inner {
        display: none;
      }
    }

    .@{textarea-prefix-cls}-display-only {
      .@{textarea-prefix-cls}-display-only__wrap {
        display: flex;
      }

      .@{textarea-prefix-cls}-display-only__content {
        left: 0;
        color: var(--tv-Textarea-text-color);
        max-width: 100%;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 5;
        overflow: hidden;
        word-wrap: break-word;
        white-space: pre-wrap;
        line-height: 1.5;

        &:before {
          content: '';
          float: right;
          height: 100%;
          margin-bottom: -14px;
        }

        .more-btn {
          float: right;
          clear: both;
          color: var(--tv-Textarea-more-btn-text-color);
          font-size: 12px;
          line-height: 12px;
          cursor: pointer;
        }
      }
    }

    .@{textarea-prefix-cls}__inner {
      height: 0;
      padding: 0;
      border-style: none;
      visibility: hidden;
    }
  }
}
