type SkeletonVariant = 'text' | 'card' | 'table-row'

export interface SkeletonProps {
  variant?: SkeletonVariant
  lines?: number
  className?: string
}

export function Skeleton({ variant = 'text', lines = 3, className = '' }: SkeletonProps) {
  if (variant === 'card') {
    return (
      <div className={`animate-pulse rounded-lg border border-[var(--border)] p-5 ${className}`}>
        <div className="bg-muted mb-3 h-4 w-1/3 rounded" />
        <div className="space-y-2">
          <div className="bg-muted h-3 w-full rounded" />
          <div className="bg-muted h-3 w-2/3 rounded" />
        </div>
      </div>
    )
  }

  if (variant === 'table-row') {
    return (
      <div className={`animate-pulse ${className}`}>
        {Array.from({ length: lines }, (_, i) => (
          <div key={i} className="flex gap-4 border-b border-[var(--border)] px-4 py-3">
            <div className="bg-muted h-4 w-8 rounded" />
            <div className="bg-muted h-4 flex-1 rounded" />
            <div className="bg-muted h-4 w-20 rounded" />
            <div className="bg-muted h-4 w-24 rounded" />
          </div>
        ))}
      </div>
    )
  }

  return (
    <div className={`animate-pulse space-y-2 ${className}`}>
      {Array.from({ length: lines }, (_, i) => (
        <div
          key={i}
          className="bg-muted h-3 rounded"
          style={{ width: `${Math.max(40, 100 - i * 15)}%` }}
        />
      ))}
    </div>
  )
}
