@import '../common/abstracts/variable';
@import '../common/abstracts/mixin';

.wot-theme-dark {
  @include b(textarea) {
    background: $-dark-background2;

    &::after {
      background: $-dark-color-gray;
    }

    @include when(not-empty) {
      &:not(.is-disabled) {
        &::after {
          background-color: $-dark-color;
        }
      }
    }

    @include e(value) {
      background: $-dark-background2;
    }

    @include e(inner) {
      color: $-dark-color;

      &::-webkit-input-placeholder {
        color: $-dark-color3;
      }
    }

    @include e(placeholder) {
      color: $-dark-color3;
    }

    @include e(count) {
      color: $-dark-color3;
      background: transparent;
    }

    @include e(count-current) {
      color: $-dark-color;
    }

    :deep(.wd-textarea__icon),
    :deep(.wd-textarea__clear) {
      color: $-dark-color;
      background: transparent;
    }

    @include when(cell) {
      background-color: $-dark-background2;

      @include when(border) {
        @include halfPixelBorder('top', $-textarea-cell-padding, $-dark-border-color);
      }
    }

    @include when(disabled) {
      .wd-textarea__inner {
        color: $-dark-color-gray;
        background: transparent;
      }
    }

    @include e(label) {
      color: $-dark-color;
    }
  }
}

@include b(textarea) {
  position: relative;
  padding: $-textarea-cell-padding $-textarea-padding;
  text-align: left;
  background: $-textarea-bg;
  -webkit-tap-highlight-color: transparent;

  &::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    height: 1px;
    content: '';
    background: $-textarea-border-color;
    transition: background-color 0.2s ease-in-out;
    transform: scaleY(0.5);
  }

  @include e(label) {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-shrink: 0;
    width: $-input-cell-label-width;
    margin-right: $-cell-padding;
    font-size: $-textarea-fs;
    color: $-cell-title-color;

    @include when(required) {
      .wd-input__label-inner {
        position: relative;
        &::after {
          position: absolute;
          top: 2px;
          right: -12px;
          font-size: $-cell-required-size;
          line-height: 1.1;
          color: $-cell-required-color;
          content: '*';
        }
      }
    }
  }

  @include e(label-inner) {
    display: inline-block;
    font-size: $-textarea-fs;
    line-height: $-cell-line-height;
  }

  @include e(prefix) {
    margin-right: $-textarea-icon-margin;
    font-size: $-textarea-fs;
    line-height: initial;

    :deep(.wd-textarea__icon) {
      margin-left: 0;
    }
  }

  @include e(suffix) {
    flex-shrink: 0;
    line-height: initial;
  }

  @include e(value) {
    position: relative;
    box-sizing: border-box;
    padding: 0;
    font-size: 0;
    background: $-textarea-bg;

    @include when(show-limit) {
      padding-bottom: 36px;
    }

    @include when(suffix) {
      padding-right: calc($-textarea-icon-size + 8px);
    }
  }

  @include e(inner) {
    box-sizing: border-box;
    width: 100%;
    min-height: 24px;
    padding: 0;
    font-size: $-textarea-fs;
    line-height: $-cell-line-height;
    color: $-textarea-color;
    word-break: break-word;
    background: none;
    border: none;
    outline: none;

    &::-webkit-input-placeholder {
      color: $-input-placeholder-color;
    }
  }

  @include e(suffix) {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }

  @include edeep(icon) {
    margin-left: $-textarea-icon-margin;
    font-size: $-textarea-icon-size;
    color: $-textarea-icon-color;
    background: $-textarea-bg;
  }

  @include edeep(clear) {
    margin-left: $-textarea-icon-margin;
    font-size: $-textarea-icon-size;
    line-height: $-cell-line-height;
    color: $-textarea-clear-color;
    vertical-align: middle;
    background: $-textarea-bg;
  }

  @include e(count) {
    position: absolute;
    right: 0;
    bottom: 8px;
    display: inline-flex;
    font-size: $-textarea-count-fs;
    line-height: 20px;
    color: $-textarea-count-color;
    background: $-textarea-bg;
  }

  @include e(count-current) {
    color: $-textarea-count-current-color;

    @include when(error) {
      color: $-input-error-color;
    }
  }

  @include e(placeholder) {
    color: $-input-placeholder-color;

    &.is-error {
      color: $-input-error-color;
    }
  }

  @include e(readonly-mask) {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
  }

  @include e(error-message) {
    font-size: $-form-item-error-message-font-size;
    line-height: $-form-item-error-message-line-height;
    color: $-form-item-error-message-color;
    text-align: left;
    vertical-align: middle;
  }

  @include when(not-empty) {
    &:not(.is-disabled) {
      &::after {
        background-color: $-textarea-not-empty-border-color;
      }
    }
  }

  @include when(disabled) {
    .wd-textarea__inner {
      color: $-input-disabled-color;
      background: transparent;
    }
  }

  @include when(error) {
    .wd-textarea__inner {
      color: $-input-error-color;
      background: transparent;
    }
  }

  @include when(auto-height) {
    &:not(.is-cell) {
      padding: 5px 0;
    }

    &::after {
      display: block;
    }
  }

  @include when(no-border) {
    &::after {
      display: none;
    }
  }

  @include when(cell) {
    display: flex;
    line-height: $-cell-line-height;

    &.is-error::after {
      background: $-textarea-cell-border-color;
    }

    .wd-textarea__value {
      flex: 1;
    }

    :deep(.wd-textarea__icon) {
      display: inline-flex;
      align-items: center;
      height: $-textarea-cell-height;
      line-height: $-textarea-cell-height;
    }

    .wd-textarea__prefix {
      display: inline-block;
      margin-right: $-cell-icon-right;
    }

    &.wd-textarea::after {
      display: none;
    }

    .wd-textarea__suffix {
      right: 0;
    }

    @include when(center) {
      align-items: center;
    }

    @include when(border) {
      @include halfPixelBorder('top', $-textarea-cell-padding);
    }
  }

  @include when(large) {
    padding: $-textarea-cell-padding-large;

    .wd-textarea__prefix {
      font-size: $-textarea-fs-large;
    }

    .wd-textarea__label-inner {
      font-size: $-textarea-fs-large;
    }

    .wd-textarea__inner {
      font-size: $-textarea-fs-large;
    }

    .wd-textarea__count {
      font-size: $-textarea-count-fs-large;
    }

    :deep(.wd-textarea__icon),
    :deep(.wd-textarea__clear) {
      font-size: $-textarea-icon-size-large;
    }
  }
}
