import { PublicLayout } from '@/components/layout/public-layout'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { Code, Star, Download, ExternalLink } from 'lucide-react'

export default function DeveloperMarketplacePage() {
  const tools = [
    {
      id: '1',
      name: 'Phoenix CLI',
      author: 'Sankofa Team',
      description: 'Command-line interface for managing Phoenix resources',
      rating: 4.9,
      downloads: 5000,
      category: 'CLI Tools',
      language: 'TypeScript',
    },
    {
      id: '2',
      name: 'Terraform Provider',
      author: 'Community',
      description: 'Terraform provider for infrastructure as code',
      rating: 4.7,
      downloads: 3200,
      category: 'IaC',
      language: 'Go',
    },
    {
      id: '3',
      name: 'Python SDK',
      author: 'Sankofa Team',
      description: 'Official Python SDK for Phoenix API',
      rating: 4.8,
      downloads: 2800,
      category: 'SDK',
      language: 'Python',
    },
  ]

  return (
    <PublicLayout>
      <div className="min-h-screen bg-studio-black py-24 px-4">
        <div className="mx-auto max-w-7xl">
          <div className="mb-12">
            <h1 className="mb-4 text-5xl font-bold text-white">Developer Marketplace</h1>
            <p className="text-xl text-gray-400">
              Tools, libraries, and integrations built by the community
            </p>
          </div>

          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            {tools.map((tool) => (
              <Card key={tool.id} className="hover:border-phoenix-fire transition-colors">
                <CardHeader>
                  <div className="flex items-start justify-between mb-2">
                    <Code className="h-8 w-8 text-phoenix-fire" />
                    <span className="px-2 py-1 text-xs bg-studio-dark text-gray-400 rounded">
                      {tool.category}
                    </span>
                  </div>
                  <CardTitle className="text-white">{tool.name}</CardTitle>
                  <CardDescription className="text-gray-400">
                    by {tool.author}
                  </CardDescription>
                </CardHeader>
                <CardContent>
                  <p className="text-sm text-gray-300 mb-4">{tool.description}</p>
                  
                  <div className="flex items-center gap-4 mb-4 text-sm text-gray-400">
                    <div className="flex items-center gap-1">
                      <Star className="h-4 w-4 text-yellow-400 fill-yellow-400" />
                      <span>{tool.rating}</span>
                    </div>
                    <div className="flex items-center gap-1">
                      <Download className="h-4 w-4" />
                      <span>{tool.downloads.toLocaleString()}</span>
                    </div>
                    <span className="text-xs">{tool.language}</span>
                  </div>

                  <div className="flex gap-2">
                    <Button variant="outline" className="flex-1" asChild>
                      <Link href={`/marketplace/developers/${tool.id}`}>
                        View Details
                      </Link>
                    </Button>
                    <Button variant="phoenix" asChild>
                      <Link href={`/marketplace/developers/${tool.id}/install`}>
                        Install
                      </Link>
                    </Button>
                  </div>
                </CardContent>
              </Card>
            ))}
          </div>

          <div className="mt-12 text-center">
            <h2 className="mb-4 text-2xl font-bold text-white">Publish Your Tool</h2>
            <p className="mb-6 text-gray-400">
              Share your tools and libraries with the developer community
            </p>
            <Button variant="phoenix" size="lg" asChild>
              <Link href="/developers/marketplace/publish">Publish Tool</Link>
            </Button>
          </div>
        </div>
      </div>
    </PublicLayout>
  )
}

