// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

@use '../mixins';
@use '../variables';

.Input {
  &__container {
    @include mixins.font-body-1;
    border-radius: 6px;
    border-style: solid;
    border-width: 2px;
    margin-block: 16px;
    margin-inline: 0;
    padding-block: 2px;
    padding-inline: 12px;
    display: flex;
    position: relative;

    @include mixins.light-theme {
      background: variables.$color-white;
      border-color: variables.$color-gray-15;
      color: variables.$color-black;
    }

    @include mixins.dark-theme {
      background: variables.$color-gray-80;
      border-color: variables.$color-gray-45;
      color: variables.$color-gray-05;
    }

    &--disabled {
      @include mixins.light-theme {
        background: variables.$color-gray-02;
        border-color: variables.$color-gray-05;
        color: variables.$color-gray-90;
      }

      @include mixins.dark-theme {
        background: variables.$color-gray-95;
        border-color: variables.$color-gray-60;
        color: variables.$color-gray-20;
      }
    }

    &:focus-within {
      outline: none;

      @include mixins.light-theme {
        border-color: variables.$color-ultramarine;
      }
      @include mixins.dark-theme {
        border-color: variables.$color-ultramarine-light;
      }
    }
  }

  &__icon {
    font-size: 24px;
    height: 32px;
    width: 32px;
    margin-inline-end: 8px;
  }

  &__input {
    @include mixins.font-body-1;

    background: inherit;
    border: none;
    resize: none;
    width: 100%;

    &--large {
      height: 280px;
    }

    &--textarea {
      margin-top: 4px;
    }

    &:placeholder {
      color: variables.$color-gray-45;
    }

    @include mixins.light-theme {
      color: variables.$color-black;
    }

    @include mixins.dark-theme {
      color: variables.$color-gray-05;
    }

    &:focus {
      outline: none;
    }
  }

  &__controls {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    height: 22px;
    justify-content: flex-end;
    min-height: 32px;
  }

  &__clear-icon {
    height: 18px;
    width: 18px;

    @include mixins.light-theme {
      @include mixins.color-svg(
        '../images/icons/v3/x/x.svg',
        variables.$color-gray-60
      );
    }
    @include mixins.dark-theme {
      @include mixins.color-svg(
        '../images/icons/v3/x/x.svg',
        variables.$color-gray-25
      );
    }
  }

  &__remaining-count {
    @include mixins.font-subtitle;
    color: variables.$color-gray-45;

    &--large {
      position: absolute;
      bottom: 0;
      inset-inline-end: 0;

      margin: 12px;
    }

    &--warn {
      color: variables.$color-accent-red;
    }
  }
}
