import type { Metadata } from "next";
import { getPublicPageSeo } from "@/lib/public-page-seo";
import { resolveOgImageUrl } from "@/lib/site-og-image";

const SITE_URL = (process.env.NEXT_PUBLIC_SITE_URL || "https://nizamify.com").replace(/\/$/, "");

export async function generateMetadata(): Promise<Metadata> {
  const seo = await getPublicPageSeo("privacy");
  const title = seo?.metaTitle?.trim() || seo?.title?.trim() || "Privacy Policy";
  const description =
    seo?.metaDescription?.trim() || "Learn how Nizamify collects, uses, and protects your information.";
  const canonical = "/privacy";
  const keywords =
    Array.isArray(seo?.metaKeywords) && seo.metaKeywords.length > 0
      ? seo.metaKeywords
      : ["Nizamify privacy policy"];
  const image = resolveOgImageUrl(seo?.image);

  return {
    title,
    description,
    keywords,
    alternates: { canonical },
    openGraph: {
      title,
      description,
      url: `${SITE_URL}${canonical}`,
      type: "website",
      images: [{ url: image }],
    },
    twitter: {
      card: "summary_large_image",
      title,
      description,
      images: [image],
    },
  };
}

export default function PrivacyPage() {
  return (
    <section className="bg-slate-50 pb-10 pt-3">
      <div className="container">
        <div className="mx-auto max-w-4xl rounded-xl border bg-white p-6 shadow-sm md:p-10">
          <h1 className="text-3xl font-bold text-slate-900 md:text-4xl">Privacy Policy</h1>
          <p className="mt-2 text-sm text-slate-600">
            Last updated: May 7, 2026
          </p>

          <div className="prose prose-slate mt-5 max-w-none">
            <p>
              This Privacy Policy explains how Nizamify collects, uses, and protects your information when
              you use our website and services.
            </p>

            <h2>1. Information We Collect</h2>
            <ul>
              <li>
                <strong>Contact details</strong>: name, email, phone number, subject, and message you submit via
                our contact form.
              </li>
              <li>
                <strong>Usage data</strong>: basic technical data such as pages visited and device/browser information
                (where available through standard server logs/analytics).
              </li>
            </ul>

            <h2>2. How We Use Your Information</h2>
            <ul>
              <li>To respond to inquiries and provide requested information.</li>
              <li>To improve our website, products, and services.</li>
              <li>To prevent fraud, abuse, and security incidents.</li>
            </ul>

            <h2>3. Sharing of Information</h2>
            <p>
              We do not sell your personal information. We may share information with service providers (e.g. email
              delivery providers) only as needed to operate the Service.
            </p>

            <h2>4. Data Retention</h2>
            <p>
              We retain contact messages for as long as necessary to respond and maintain business records, unless a
              longer retention period is required by law.
            </p>

            <h2>5. Security</h2>
            <p>
              We use reasonable safeguards to protect your information. However, no method of transmission over the
              internet is completely secure.
            </p>

            <h2>6. Your Choices</h2>
            <p>
              You can contact us to request updates or deletion of your contact submissions where applicable.
            </p>

            <h2>7. Contact</h2>
            <p>
              If you have questions about this Privacy Policy, please reach us via the{" "}
              <a href="/contact-us">Contact Us</a> page.
            </p>
          </div>
        </div>
      </div>
    </section>
  );
}