import { RefreshCw } from "lucide-react";
import { PageHeader } from "@/components/ui/PageHeader";
import { ErrorMessage } from "@/components/ui/ErrorMessage";
import {
  REPORT_PAGE_CONTAINER_ALT,
  REPORT_PRIMARY,
  REPORT_PRIMARY_HOVER,
} from "@/app/reports/constants";

interface ReportStateProps {
  title: string;
  breadcrumbs: { label: string; href?: string }[];
}

/** Full-page spinner shown while a report has no data to render yet. */
export function ReportLoadingState({ title, breadcrumbs }: ReportStateProps) {
  return (
    <div className={REPORT_PAGE_CONTAINER_ALT}>
      <PageHeader title={title} description="Loading…" breadcrumbs={breadcrumbs} />
      <div className="flex h-64 items-center justify-center">
        <RefreshCw className="h-8 w-8 animate-spin" style={{ color: REPORT_PRIMARY }} />
      </div>
    </div>
  );
}

/** Full-page failure/empty state with a retry button. */
export function ReportRetryState({
  title,
  breadcrumbs,
  description,
  error,
  onRetry,
}: ReportStateProps & {
  description: string;
  error?: string | null;
  onRetry: () => void;
}) {
  return (
    <div className={REPORT_PAGE_CONTAINER_ALT}>
      <PageHeader title={title} description={description} breadcrumbs={breadcrumbs} />
      {error && (
        <div className="mt-6">
          <ErrorMessage error={error} />
        </div>
      )}
      <div className="flex h-64 items-center justify-center">
        <button
          type="button"
          onClick={onRetry}
          className="rounded-lg px-6 py-3 font-medium text-white transition-colors"
          style={{ backgroundColor: REPORT_PRIMARY }}
          onMouseEnter={(e) => {
            e.currentTarget.style.backgroundColor = REPORT_PRIMARY_HOVER;
          }}
          onMouseLeave={(e) => {
            e.currentTarget.style.backgroundColor = REPORT_PRIMARY;
          }}
        >
          Retry
        </button>
      </div>
    </div>
  );
}
