'use client'
import Link from 'next/link'
import { ExternalLink, Package, Settings, ShoppingCart, Users } from 'lucide-react'

export default function AdminPortalPage() {
  const adminUrl = process.env.NEXT_PUBLIC_MEDUSA_ADMIN_URL
    ? process.env.NEXT_PUBLIC_MEDUSA_ADMIN_URL + '/app'
    : null

  return (
    <main className="min-h-screen bg-background flex items-center justify-center p-4">
      <div className="max-w-sm w-full text-center">
        <div className="bg-card border border-border rounded-2xl p-8 shadow-sm">
          <Settings className="h-12 w-12 mx-auto mb-4 text-primary" />
          <h1 className="text-2xl font-bold text-foreground mb-2">Store Administration</h1>
          <p className="text-muted-foreground text-sm mb-8">
            Manage your products, orders, customers, and inventory through the Medusa dashboard.
          </p>
          {adminUrl ? (
            <a href={adminUrl} target="_blank" rel="noopener noreferrer"
              className="inline-flex items-center gap-2 bg-primary text-primary-foreground px-6 py-3 rounded-lg hover:bg-primary/90 transition-colors font-medium w-full justify-center">
              Open Medusa Dashboard
              <ExternalLink className="h-4 w-4" />
            </a>
          ) : (
            <p className="text-destructive text-sm">Admin URL not configured. Set NEXT_PUBLIC_MEDUSA_ADMIN_URL in .env.local</p>
          )}
          <div className="mt-8 grid grid-cols-3 gap-4 text-xs text-muted-foreground">
            <div className="flex flex-col items-center gap-1"><Package className="h-5 w-5" /><span>Products</span></div>
            <div className="flex flex-col items-center gap-1"><ShoppingCart className="h-5 w-5" /><span>Orders</span></div>
            <div className="flex flex-col items-center gap-1"><Users className="h-5 w-5" /><span>Customers</span></div>
          </div>
        </div>
        <Link href="/" className="block mt-4 text-sm text-muted-foreground hover:text-foreground transition-colors">← Back to Store</Link>
      </div>
    </main>
  )
}
