import { css } from 'lit';
import componentStyles from '../../styles/component.styles.mjs';
import formControlStyles from '../../styles/form-control.styles.mjs';

const styles = css`
  ${componentStyles}
  ${formControlStyles}

  :host {
    display: block;
  }

  .form-control .form-control__input {
    height: unset;
  }

  .textarea {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
    font-family: var(--flow-ui-control-font-family);
    font-weight: var(--flow-ui-control-font-weight);
    line-height: var(--flow-ui-line-height-normal);
    letter-spacing: var(--flow-ui-control-letter-spacing);
    vertical-align: middle;
    transition:
      var(--flow-ui-transition-fast) color,
      var(--flow-ui-transition-fast) border,
      var(--flow-ui-transition-fast) box-shadow,
      var(--flow-ui-transition-fast) background-color;
    cursor: text;
  }

  /* Standard textareas */
  .textarea--standard {
    background-color: var(--flow-ui-control-background-color);
    border: solid var(--flow-ui-control-border-width) var(--flow-ui-control-border-color);
  }

  .textarea--standard:hover:not(.textarea--disabled) {
    background-color: var(--flow-ui-control-background-color-hover);
    border-color: var(--flow-ui-control-border-color-hover);
  }
  .textarea--standard:hover:not(.textarea--disabled) .textarea__control {
    color: var(--flow-ui-control-color-hover);
  }

  .textarea--standard.textarea--focused:not(.textarea--disabled) {
    background-color: var(--flow-ui-control-background-color-focus);
    border-color: var(--flow-ui-control-border-color-focus);
    color: var(--flow-ui-control-color-focus);
    box-shadow: 0 0 0 var(--flow-ui-focus-ring-width) var(--flow-ui-control-focus-ring-color);
  }

  .textarea--standard.textarea--focused:not(.textarea--disabled) .textarea__control {
    color: var(--flow-ui-control-color-focus);
  }

  .textarea--standard.textarea--disabled {
    background-color: var(--flow-ui-control-background-color-disabled);
    border-color: var(--flow-ui-control-border-color-disabled);
    opacity: 0.5;
    cursor: not-allowed;
  }

  .textarea--standard.textarea--disabled .textarea__control {
    color: var(--flow-ui-control-color-disabled);
  }

  .textarea--standard.textarea--disabled .textarea__control::placeholder {
    color: var(--flow-ui-control-placeholder-color-disabled);
  }

  /* Filled textareas */
  .textarea--filled {
    border: none;
    background-color: var(--flow-ui-control-filled-background-color);
    color: var(--flow-ui-control-color);
  }

  .textarea--filled:hover:not(.textarea--disabled) {
    background-color: var(--flow-ui-control-filled-background-color-hover);
  }

  .textarea--filled.textarea--focused:not(.textarea--disabled) {
    background-color: var(--flow-ui-control-filled-background-color-focus);
    outline: var(--flow-ui-focus-ring);
    outline-offset: var(--flow-ui-focus-ring-offset);
  }

  .textarea--filled.textarea--disabled {
    background-color: var(--flow-ui-control-filled-background-color-disabled);
    opacity: 0.5;
    cursor: not-allowed;
  }

  .textarea__control {
    flex: 1 1 auto;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1.4;
    color: var(--flow-ui-control-color);
    border: none;
    background: none;
    box-shadow: none;
    cursor: inherit;
    -webkit-appearance: none;
  }

  .textarea__control::-webkit-search-decoration,
  .textarea__control::-webkit-search-cancel-button,
  .textarea__control::-webkit-search-results-button,
  .textarea__control::-webkit-search-results-decoration {
    -webkit-appearance: none;
  }

  .textarea__control::placeholder {
    color: var(--flow-ui-control-placeholder-color);
    user-select: none;
  }

  .textarea__control:focus {
    outline: none;
  }

  /*
   * Size modifiers
   */

  .textarea--small {
    border-radius: var(--flow-ui-control-border-radius-small);
    font-size: var(--flow-ui-control-font-size-small);
  }

  .textarea--small .textarea__control {
    padding: 0.5em var(--flow-ui-control-spacing-small);
  }

  .textarea--medium {
    border-radius: var(--flow-ui-control-border-radius-medium);
    font-size: var(--flow-ui-control-font-size-medium);
  }

  .textarea--medium .textarea__control {
    padding: 0.5em var(--flow-ui-control-spacing-medium);
  }

  .textarea--large {
    border-radius: var(--flow-ui-control-border-radius-large);
    font-size: var(--flow-ui-control-font-size-large);
  }

  .textarea--large .textarea__control {
    padding: 0.5em var(--flow-ui-control-spacing-large);
  }

  /*
   * Resize types
   */

  .textarea--resize-none .textarea__control {
    resize: none;
  }

  .textarea--resize-vertical .textarea__control {
    resize: vertical;
  }

  .textarea--resize-auto .textarea__control {
    height: auto;
    resize: none;
    overflow-y: hidden;
  }
`;

export { styles as default };
