import { prisma } from '@/lib/db';
import { getSession } from '@/lib/auth';
import { redirect } from 'next/navigation';
import { ImageIcon, Briefcase, Mail } from 'lucide-react';
import Link from 'next/link';

export default async function AdminDashboard() {
  const session = await getSession();
  if (!session) {
    redirect('/admin/login');
  }

  const galleryCount = await prisma.gallery.count();
  const serviceCount = await prisma.service.count();
  const unreadMessages = await prisma.contactMessage.count({ where: { isRead: false } });

  return (
    <div>
      <h1 className="text-3xl font-bold mb-8">Dashboard Özeti</h1>
      
      <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
        <Link href="/admin/gallery" className="block">
          <div className="bg-white dark:bg-slate-900 p-6 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-800 hover:border-blue-500 dark:hover:border-blue-500 transition-colors">
            <div className="flex items-center space-x-4">
              <div className="p-3 bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 rounded-xl">
                <ImageIcon className="w-8 h-8" />
              </div>
              <div>
                <p className="text-sm font-medium text-slate-500 dark:text-slate-400">Galeri Resimleri</p>
                <p className="text-2xl font-bold">{galleryCount}</p>
              </div>
            </div>
          </div>
        </Link>
        
        <Link href="/admin/services" className="block">
          <div className="bg-white dark:bg-slate-900 p-6 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-800 hover:border-purple-500 dark:hover:border-purple-500 transition-colors">
            <div className="flex items-center space-x-4">
              <div className="p-3 bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400 rounded-xl">
                <Briefcase className="w-8 h-8" />
              </div>
              <div>
                <p className="text-sm font-medium text-slate-500 dark:text-slate-400">Hizmetlerimiz</p>
                <p className="text-2xl font-bold">{serviceCount}</p>
              </div>
            </div>
          </div>
        </Link>
        
        <Link href="/admin/contact" className="block">
          <div className="bg-white dark:bg-slate-900 p-6 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-800 hover:border-green-500 dark:hover:border-green-500 transition-colors">
            <div className="flex items-center space-x-4">
              <div className="p-3 bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded-xl">
                <Mail className="w-8 h-8" />
              </div>
              <div>
                <p className="text-sm font-medium text-slate-500 dark:text-slate-400">Okunmamış Mesaj</p>
                <p className="text-2xl font-bold">{unreadMessages}</p>
              </div>
            </div>
          </div>
        </Link>
      </div>
    </div>
  );
}
