"use client";

import { cn } from "@/app/lib/utils";
import type { ReactNode } from "react";

/**
 * Wraps non-datagrid page content in a centered max-width container.
 * Uses max-w-5xl (1024px) by default; pass `wide` for 1280px.
 */
export function PageShell({
  children,
  className,
  wide = false,
}: {
  children: ReactNode;
  className?: string;
  wide?: boolean;
}) {
  return (
    <div
      className={cn(
        "mx-auto w-full px-3 sm:px-6 py-4 sm:py-8",
        wide ? "max-w-[1280px]" : "max-w-[1024px]",
        className,
      )}
    >
      {children}
    </div>
  );
}

/**
 * Empty state block — icon + heading + description + optional CTA.
 */
export function EmptyState({
  icon: Icon,
  heading,
  description,
  action,
  className,
}: {
  icon: React.ElementType;
  heading: string;
  description?: string;
  action?: ReactNode;
  className?: string;
}) {
  return (
    <div
      className={cn(
        "flex flex-col items-center justify-center gap-3 rounded-lg border border-border border-dashed bg-card/40 px-8 py-16 text-center",
        className,
      )}
    >
      <div className="flex h-12 w-12 items-center justify-center rounded-lg bg-muted/60">
        <Icon className="h-6 w-6 text-muted-foreground/60" />
      </div>
      <div className="space-y-1">
        <p className="text-sm font-medium text-foreground">{heading}</p>
        {description && (
          <p className="text-xs text-muted-foreground max-w-xs">{description}</p>
        )}
      </div>
      {action && <div className="mt-1">{action}</div>}
    </div>
  );
}
