"use client";

import { AlertTriangle, RotateCcw } from "lucide-react";
import { Button } from "@/components/ui/button";

interface ErrorStateProps {
  title?: string;
  description?: string;
  onRetry?: () => void;
}

export function ErrorState({
  title = "Unable to load this section",
  description = "An unexpected error occurred while retrieving records. Your data remains safe.",
  onRetry,
}: ErrorStateProps) {
  return (
    <div className="flex flex-col items-center justify-center rounded-xl border border-red-200 bg-red-50/40 px-6 py-12 text-center">
      <div className="flex h-11 w-11 items-center justify-center rounded-xl border border-red-200 bg-white text-status-danger">
        <AlertTriangle className="h-5 w-5" />
      </div>
      <h3 className="mt-3.5 text-sm font-semibold text-[#111827]">{title}</h3>
      <p className="mt-1 max-w-md text-xs leading-relaxed text-[#64748B]">{description}</p>
      {onRetry && (
        <Button variant="outline" size="sm" onClick={onRetry} className="mt-4">
          <RotateCcw className="h-3.5 w-3.5" />
          Try again
        </Button>
      )}
    </div>
  );
}
