import { Card } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Github, ExternalLink, Star } from "lucide-react"
import Link from "next/link"

export function OpenSourceSection() {
  const projects = [
    {
      name: "conding",
      description:
        "Python library for modeling, simulation, and analysis of bonding curves. Features data loading from Dune and interactive visualization dashboards.",
      link: "https://github.com/bonding-curves/conding",
      topics: ["Python", "Data Science", "Modeling"],
    },
    {
      name: "Research Papers",
      description:
        "Collection of our research publications exploring bonding curves, PAMMs, SAMMs, and their applications in token engineering.",
      link: "https://mirror.xyz/0x8fF6Fe58b468B1F18d2C54e2B0870b4e847C730d",
      topics: ["Research", "Token Engineering", "DeFi"],
    },
    {
      name: "Library Documentation",
      description:
        "Comprehensive documentation and guides for understanding and implementing bonding curves in your projects.",
      link: "https://bonding-curve-research-group.gitbook.io/bonding-curve-research-group-library",
      topics: ["Documentation", "Tutorials", "Guides"],
    },
  ]

  return (
    <section id="open-source" className="py-20 px-4 sm:px-6 lg:px-8">
      <div className="max-w-7xl mx-auto">
        <div className="max-w-2xl mb-16">
          <h2 className="text-4xl md:text-5xl font-bold mb-6 text-balance">Open Source Contributions</h2>
          <p className="text-lg text-muted-foreground leading-relaxed text-pretty">
            All of our work is open source and freely available to the community. We believe in building in public and
            contributing to the knowledge commons of crypto-economic primitives.
          </p>
        </div>

        <div className="grid grid-cols-1 gap-6 mb-12">
          {projects.map((project, index) => (
            <Card key={index} className="p-6 hover:shadow-lg transition-shadow">
              <div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
                <div className="flex-1">
                  <div className="flex items-center gap-2 mb-2">
                    <Github className="h-5 w-5" />
                    <h3 className="text-xl font-semibold">{project.name}</h3>
                  </div>
                  <p className="text-muted-foreground mb-3 leading-relaxed">{project.description}</p>
                  <div className="flex flex-wrap gap-2">
                    {project.topics.map((topic, i) => (
                      <span key={i} className="px-3 py-1 bg-accent/10 text-accent text-sm rounded-full">
                        {topic}
                      </span>
                    ))}
                  </div>
                </div>
                <Button asChild variant="outline" className="self-start md:self-center bg-transparent">
                  <Link href={project.link} target="_blank">
                    View Project
                    <ExternalLink className="ml-2 h-4 w-4" />
                  </Link>
                </Button>
              </div>
            </Card>
          ))}
        </div>

        <Card className="p-8 bg-primary text-primary-foreground">
          <div className="flex flex-col md:flex-row items-center justify-between gap-6">
            <div className="flex-1">
              <h3 className="text-2xl font-bold mb-3">Join Our Community</h3>
              <p className="text-primary-foreground/90 leading-relaxed">
                Follow our research, contribute to our projects, and join the conversation about bonding curves and
                token engineering on GitHub and Twitter.
              </p>
            </div>
            <div className="flex flex-col sm:flex-row gap-3">
              <Button asChild variant="secondary" size="lg">
                <Link href="https://github.com/bonding-curves" target="_blank">
                  <Github className="mr-2 h-5 w-5" />
                  GitHub
                </Link>
              </Button>
              <Button asChild variant="secondary" size="lg">
                <Link href="https://x.com/Bonding_Curves" target="_blank">
                  <Star className="mr-2 h-5 w-5" />
                  Twitter
                </Link>
              </Button>
            </div>
          </div>
        </Card>
      </div>
    </section>
  )
}
