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: "VIP Escorts | AdultWorld",
  description:
    "Discover our premium VIP escorts offering an elevated, discreet, and luxurious companionship experience on AdultWorld.",
  alternates: { canonical: "/escorts/vip" },
  openGraph: {
    title: "VIP Escorts | AdultWorld",
    description:
      "Discover our premium VIP escorts offering an elevated, discreet, and luxurious companionship experience.",
  },
};

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

export default async function VipEscortsPage() {
  const escortsRaw = await prisma.user.findMany({
    where: { user_type: "escort", active: true, banned_at: null, is_vip: 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_vip: true },
  });

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

        <div className="bg-surface rounded-lg p-6 space-y-3 text-text-muted leading-relaxed">
          <p>
            VIP escorts represent the highest tier on AdultWorld. These companions have
            earned VIP status through consistently outstanding reviews, professional
            presentation, and a commitment to providing an exceptional experience. VIP
            members receive priority placement, a gold badge on their profile, and access
            to exclusive platform features.
          </p>
          <p>
            Choosing a VIP escort means you can expect premium service from start to
            finish — prompt communication, punctuality, upscale presentation, and complete
            discretion. Many VIP escorts cater to high-end clientele, offering dinner dates,
            travel companionship, and bespoke experiences tailored to your preferences.
          </p>
          <p>
            Whether you are looking for a sophisticated companion for a business event or an
            unforgettable private encounter, our VIP escorts deliver a level of quality that
            sets them apart. Browse the selection below and experience the difference.
          </p>
        </div>

        <p className="text-sm text-text-muted">
          Showing {escorts.length} of {totalCount.toLocaleString()} VIP 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 VIP 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="/escorts/verified" className="text-primary hover:underline">
          Verified 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>
  );
}
