// Renders admin-editable footer pages (About, Contact, Terms, Privacy,
// Refund Policy). Content is stored as plain text in Settings, with a very
// small convention so admins don't need to learn Markdown:
//   - A line starting with "## " becomes a subheading
//   - A blank line starts a new paragraph
//   - Everything else wraps as normal paragraph text
export default function InfoPage({ title, content }: { title: string; content: string }) {
  const blocks = content.split(/\n{2,}/).map((b) => b.trim()).filter(Boolean);

  return (
    <div className="max-w-2xl mx-auto">
      <h1 className="text-2xl font-bold mb-6">{title}</h1>
      <div className="space-y-4 text-sm leading-relaxed text-neutral-300">
        {blocks.length === 0 && (
          <p className="text-neutral-500">This page hasn't been set up yet.</p>
        )}
        {blocks.map((block, i) => {
          if (block.startsWith("## ")) {
            return (
              <h2 key={i} className="text-lg font-semibold text-white pt-2">
                {block.replace(/^##\s*/, "")}
              </h2>
            );
          }
          return (
            <p key={i} className="whitespace-pre-line">
              {block}
            </p>
          );
        })}
      </div>
    </div>
  );
}
