import prisma from "@/lib/prisma";
import Link from "next/link";
import type { Metadata } from "next";
import EscortCard from "@/components/shared/escort-card";
import { withAvatarUrls } from "@/lib/media";

export const metadata: Metadata = {
  title: "Verified Escorts | AdultWorld",
  description:
    "Browse verified escorts who have completed our identity verification process. Every profile on this page has been checked for authenticity, so you can book with confidence.",
  alternates: { canonical: "/escorts/verified" },
  openGraph: {
    title: "Verified Escorts | AdultWorld",
    description:
      "Browse verified escorts who have completed our identity verification process.",
  },
};

export const revalidate = 600; // ISR (Stage 4): was force-dynamic

export default async function VerifiedEscortsPage() {
  const escortsRaw = await prisma.user.findMany({
    where: { user_type: "escort", active: true, banned_at: null, is_verified: true },
    include: { country: true, city: true, _count: { select: { photos: true } } },
    orderBy: { lastonline_at: "desc" },
    take: 48,
  });
  const escorts = await withAvatarUrls(escortsRaw);

  const totalCount = await prisma.user.count({
    where: { user_type: "escort", active: true, banned_at: null, is_verified: true },
  });

  return (
    <div className="space-y-6">
      <div className="space-y-4">
        <h1 className="text-2xl md:text-3xl font-bold">Verified Escorts</h1>

        <div className="bg-surface rounded-lg p-6 space-y-3 text-text-muted leading-relaxed">
          <p>
            Every escort on this page has completed our multi-step identity verification
            process. Verification means the person behind the profile has provided
            government-issued ID, a live selfie check, and confirmed their contact details.
            This protects both clients and escorts by ensuring every listing is genuine.
          </p>
          <p>
            Verified profiles display a blue checkmark badge, giving you instant confidence
            that the photos, description, and contact information are authentic. Our
            verification team reviews each submission manually — no automated shortcuts.
            Profiles that fail re-verification are removed.
          </p>
          <p>
            Booking a verified escort means fewer no-shows, accurate photos, and a safer
            experience overall. If trust and safety matter to you — and they should — start
            your search here. Want to learn more about how we verify profiles?{" "}
            <Link href="/how-verification-works" className="text-primary hover:underline">
              Read about our verification process
            </Link>
            .
          </p>
        </div>

        <p className="text-sm text-text-muted">
          Showing {escorts.length} of {totalCount.toLocaleString()} verified escorts
        </p>
      </div>

      <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
        {escorts.map((escort) => (
          <EscortCard key={escort.id} escort={escort} />
        ))}
      </div>

      {escorts.length === 0 && (
        <div className="text-center py-16 text-text-muted">
          <p className="text-lg">No verified escorts found</p>
        </div>
      )}

      <div className="flex flex-wrap gap-3 text-sm">
        <Link href="/escorts" className="text-primary hover:underline">
          All Escorts
        </Link>
        <Link href="/search" className="text-primary hover:underline">
          Advanced Search
        </Link>
        <Link href="/for-clients" className="text-primary hover:underline">
          Client Guide
        </Link>
      </div>
    </div>
  );
}
