:root {
  --content-editable-padding: 0.85rem;
}
/* Container styles */
.container {
  width: 100%;
}

/* Label styles */
.label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: inherit;
}

.label[data-error="true"] {
  color: #ef4444;
}

/* Visually hidden but accessible to screen readers */
.visuallyHidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Base textarea styles */
.textarea {
  display: flex;
  flex-direction: column;
  gap: var(--clover-ai-sizes-2);
  border-radius: 0.5rem;
  outline: none;
  transition:
    border-color 0.2s ease-in-out,
    box-shadow 0.2s ease-in-out;
  font-family: inherit;
  font-size: inherit;
  resize: none;
  overflow-wrap: break-word;
  word-wrap: break-word;
  border-width: calc(var(--clover-ai-sizes-1) / calc(var(--golden-ratio) * 2));
  border-style: solid;
  background-color: transparent;

  /* configurable styles */
  --textarea-border-color: var(--clover-ai-colors-accent, #e6e8eb);
  border-color: var(--textarea-border-color);

  &:has(*:focus) {
    --textarea-border-color: var(--clover-ai-colors-accentMuted);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
}

.textarea[data-error="true"] {
  --textarea-border-color: var(--clover-ai-colors-error);
}

/* Variant styles */
.textarea[data-variant="bordered"] {
  border: 2px solid var(--colors-border, #e5e7eb);
  background-color: transparent;
}

.textarea[data-variant="filled"] {
  border: 1px solid transparent;
  background-color: var(--colors-background, #f9fafb);
}

/* Size styles */
.textarea[data-size="small"] {
  padding: 0.5rem;
  font-size: 0.875rem;
  min-height: 1.5rem;
}

.textarea[data-size="medium"] {
  padding: 0.618rem;
  font-size: 1rem;
  min-height: 3rem;
}

.textarea[data-size="large"] {
  padding: 0.75rem;
  font-size: 1.125rem;
  min-height: 3.5rem;
}

.contentEditableContainer {
  cursor: pointer;
  margin: 0;

  & > *[contenteditable] {
    white-space: pre-wrap;
    outline: 0px solid transparent;
    padding: 0;
    width: 100%;
  }
}

.placeholder {
  color: var(--colors-text-placeholder, #9ca3af);
  pointer-events: none;
  /* the ContentEditable injects inline styles, this number helps the placeholder line up */
  padding-inline-start: var(--content-editable-padding);
}

.childrenContainer {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  /* the ContentEditable injects inline styles, this number helps the placeholder line up */
  padding-inline: var(--content-editable-padding);
  > * {
    display: flex;
    gap: 0.5rem;
  }
}

.helperText {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--colors-text-secondary, #6b7280);
}

.helperText[data-error="true"] {
  color: var(--clover-ai-colors-error);
}
