import * as React from 'react'
import { cn } from '@/lib/utils'

interface TextareaProps
  extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
  error?: boolean
}

const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
  ({ className, error, ...props }, ref) => {
    return (
      <textarea
        className={cn(
          'flex min-h-[80px] w-full rounded-card border bg-surface-raised px-3 py-2 text-sm text-fg placeholder:text-fg-subtle transition-colors resize-none',
          'border-border hover:border-border/80',
          'focus:outline-none focus:ring-2 focus:ring-accent/30 focus:border-accent/50',
          'disabled:cursor-not-allowed disabled:opacity-50',
          error && 'border-rose-500/50 focus:ring-rose-500/30 focus:border-rose-500/50',
          className
        )}
        ref={ref}
        {...props}
      />
    )
  }
)
Textarea.displayName = 'Textarea'

export { Textarea }
