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

interface EmptyStateProps {
  icon?: React.ReactNode;
  title: string;
  description?: string;
  action?: React.ReactNode;
  className?: string;
  compact?: boolean;
}

/** Shown when a collection has no rows yet. */
export function EmptyState({
  icon,
  title,
  description,
  action,
  className,
  compact = false,
}: EmptyStateProps) {
  return (
    <div
      className={cn(
        "flex flex-col items-center justify-center border border-dashed border-line bg-surface/50 text-center",
        compact ? "gap-2 p-6" : "gap-3 p-10",
        className
      )}
    >
      {icon ? (
        <div
          className={cn(
            "flex items-center justify-center border border-subtle bg-sunken text-tertiary",
            compact ? "size-9" : "size-12"
          )}
        >
          {icon}
        </div>
      ) : null}
      <div className="space-y-1">
        <p className={cn("font-semibold text-primary", compact ? "text-sm" : "text-base")}>{title}</p>
        {description ? (
          <p className={cn("mx-auto max-w-sm text-secondary", compact ? "text-xs" : "text-sm")}>
            {description}
          </p>
        ) : null}
      </div>
      {action ? <div className="mt-1">{action}</div> : null}
    </div>
  );
}
