import prisma from '@/lib/prisma'
import { Package, Tags, Eye, TrendingUp } from 'lucide-react'
import Link from 'next/link'

export const metadata = {
  title: 'Admin Dashboard - Kite Beach',
}

export default async function AdminDashboard() {
  const [totalCategories, totalProducts, activeProducts] = await Promise.all([
    prisma.categories.count(),
    prisma.products.count(),
    prisma.products.count({ where: { status: 1 } }),
  ])

  return (
    <div className="space-y-6">
      <h1 className="text-2xl font-bold text-gray-900">Dashboard</h1>

      {/* Stats Cards */}
      <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
        <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex items-center gap-4">
          <div className="p-3 bg-blue-100 text-blue-600 rounded-lg">
            <Tags size={24} />
          </div>
          <div>
            <p className="text-sm text-gray-500 font-medium">Kategori Sayısı</p>
            <p className="text-2xl font-bold text-gray-900">{totalCategories}</p>
          </div>
        </div>

        <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex items-center gap-4">
          <div className="p-3 bg-indigo-100 text-indigo-600 rounded-lg">
            <Package size={24} />
          </div>
          <div>
            <p className="text-sm text-gray-500 font-medium">Toplam Ürün</p>
            <p className="text-2xl font-bold text-gray-900">{totalProducts}</p>
          </div>
        </div>

        <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex items-center gap-4">
          <div className="p-3 bg-green-100 text-green-600 rounded-lg">
            <TrendingUp size={24} />
          </div>
          <div>
            <p className="text-sm text-gray-500 font-medium">Aktif Ürünler</p>
            <p className="text-2xl font-bold text-gray-900">{activeProducts}</p>
          </div>
        </div>
      </div>

      {/* Quick Actions */}
      <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
        <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
          <h2 className="text-lg font-semibold mb-4">Hızlı Kısayollar</h2>
          <div className="flex flex-col gap-3">
            <Link href="/admin/products" className="text-blue-600 hover:text-blue-800 font-medium flex items-center gap-2">
              <Package size={18} /> Ürünleri Yönet
            </Link>
            <Link href="/admin/categories" className="text-blue-600 hover:text-blue-800 font-medium flex items-center gap-2">
              <Tags size={18} /> Kategorileri Yönet
            </Link>
            <Link href="/" target="_blank" className="text-gray-600 hover:text-gray-800 font-medium flex items-center gap-2">
              <Eye size={18} /> Canlı Menüyü Görüntüle
            </Link>
          </div>
        </div>
      </div>
    </div>
  )
}
