'use client';

import { useRouter } from 'next/navigation';
import { PageState } from '@/components/common/feedback/PageState';

/**
 * 404 页面（规则 §5.3.6 "不可见即不存在"）
 *
 * 当后端返回 404：可能是记录真不存在，也可能是 DataScope 不覆盖。
 * 规则要求不告诉用户"存在但无权访问"，统一展示"资源不存在"。
 */
export function NotFoundPage({
  title,
  description,
  onBack,
}: {
  title?: string;
  description?: string;
  onBack?: () => void;
}) {
  const router = useRouter();
  const handleBack = onBack || (() => router.back());

  return (
    <div className="flex min-h-[60vh] items-center justify-center p-6">
      <div className="w-full max-w-md">
        <PageState
          variant="empty"
          layout="card"
          title={title || '资源不存在'}
          description={description || '您访问的资源不存在或已被移除。'}
          actionLabel="返回"
          onAction={handleBack}
        />
      </div>
    </div>
  );
}
