import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import Link from "next/link"
import Image from "next/image"

function FallbackIcon({ className }: { className?: string }) {
  return <div className={`${className} bg-muted rounded`} />
}

function DynamicIcon({ name, className, fallback = true }: { name: string; className?: string; fallback?: boolean }) {
  try {
    // This will be handled by the bundler
    const icons = require("lucide-react")
    const IconComponent = icons[name]
    if (IconComponent) {
      return <IconComponent className={className} />
    }
  } catch (error) {
    console.log(`[v0] Failed to load icon ${name}:`, error)
  }

  return fallback ? <FallbackIcon className={className} /> : null
}

export default function LandingPage() {
  return (
    <div className="min-h-screen bg-background">
      {/* Header */}
      <header className="border-b border-border bg-background">
        <div className="container mx-auto px-4 py-8">
          <div className="flex items-center justify-center">
            <div className="flex items-center gap-4">
              <Image
                src="/images/fanaka-logo.png"
                alt="Fanaka International University College Logo"
                width={80}
                height={80}
                className="h-20 w-auto"
              />
              <div className="text-center">
                <span className="text-5xl font-black text-primary tracking-tight block leading-tight">
                  Fanaka International
                </span>
                <span className="text-4xl font-black text-primary tracking-tight block leading-tight">
                  University College
                </span>
              </div>
            </div>
          </div>
        </div>
      </header>

      {/* Hero Section */}
      <section className="relative py-20 lg:py-32">
        <div className="absolute inset-0 bg-gradient-to-br from-muted/50 to-background"></div>
        <div className="container mx-auto px-4 relative">
          <div className="max-w-4xl mx-auto text-center">
            <h1 className="text-4xl lg:text-6xl font-bold text-primary mb-6 text-balance">
              Your Journey to Academic Excellence Begins Here
            </h1>
            <p className="text-xl text-muted-foreground mb-8 text-pretty max-w-2xl mx-auto">
              Join thousands of students who have chosen Fanaka International University College for world-class
              education, innovative research, and a vibrant campus community.
            </p>
            <div className="flex flex-col sm:flex-row gap-4 justify-center">
              <Button asChild size="lg" className="bg-accent hover:bg-accent/90 text-accent-foreground">
                <Link href="/purchase-voucher">
                  <DynamicIcon name="CreditCard" className="mr-2 h-5 w-5" />
                  Purchase Application Voucher
                </Link>
              </Button>
              <Button asChild variant="outline" size="lg">
                <Link href="/login">
                  <DynamicIcon name="LogIn" className="mr-2 h-5 w-5" />
                  Login to Portal
                </Link>
              </Button>
            </div>
          </div>
        </div>
      </section>

      {/* Features Section */}
      <section className="py-16 bg-muted/30">
        <div className="container mx-auto px-4">
          <div className="text-center mb-12">
            <h2 className="text-3xl font-bold text-primary mb-4">
              Why Choose Fanaka International University College?
            </h2>
            <p className="text-muted-foreground max-w-2xl mx-auto">
              Discover what makes our institution a leader in higher education and student success.
            </p>
          </div>
          <div className="grid md:grid-cols-3 gap-8">
            <Card className="text-center">
              <CardHeader>
                <div className="mx-auto w-12 h-12 bg-accent/10 rounded-lg flex items-center justify-center mb-4">
                  <DynamicIcon name="BookOpen" className="h-6 w-6 text-accent" />
                </div>
                <CardTitle>Diverse Programs</CardTitle>
              </CardHeader>
              <CardContent>
                <CardDescription>
                  Choose from over 100 undergraduate and graduate programs across multiple faculties, designed to meet
                  industry demands and your career aspirations.
                </CardDescription>
              </CardContent>
            </Card>

            <Card className="text-center">
              <CardHeader>
                <div className="mx-auto w-12 h-12 bg-accent/10 rounded-lg flex items-center justify-center mb-4">
                  <DynamicIcon name="Users" className="h-6 w-6 text-accent" />
                </div>
                <CardTitle>Vibrant Campus Life</CardTitle>
              </CardHeader>
              <CardContent>
                <CardDescription>
                  Experience a rich campus culture with over 50 student organizations, sports teams, cultural events,
                  and leadership opportunities that shape well-rounded graduates.
                </CardDescription>
              </CardContent>
            </Card>

            <Card className="text-center">
              <CardHeader>
                <div className="mx-auto w-12 h-12 bg-accent/10 rounded-lg flex items-center justify-center mb-4">
                  <DynamicIcon name="Award" className="h-6 w-6 text-accent" />
                </div>
                <CardTitle>Student Support</CardTitle>
              </CardHeader>
              <CardContent>
                <CardDescription>
                  Benefit from comprehensive academic support, career counseling, financial aid, and mentorship programs
                  designed to ensure your success throughout your journey.
                </CardDescription>
              </CardContent>
            </Card>
          </div>
        </div>
      </section>

      {/* Application Process Section */}
      <section className="py-16">
        <div className="container mx-auto px-4">
          <div className="max-w-3xl mx-auto text-center">
            <h2 className="text-3xl font-bold text-primary mb-6">Ready to Apply?</h2>
            <p className="text-muted-foreground mb-8">
              Start your application process in just two simple steps. Purchase your application voucher and gain access
              to our comprehensive online application portal.
            </p>
            <div className="grid sm:grid-cols-2 gap-6">
              <Card className="p-6">
                <div className="text-center">
                  <div className="mx-auto w-16 h-16 bg-accent/10 rounded-full flex items-center justify-center mb-4">
                    <DynamicIcon name="CreditCard" className="h-8 w-8 text-accent" />
                  </div>
                  <h3 className="text-xl font-semibold mb-2">Step 1: Purchase Voucher</h3>
                  <p className="text-muted-foreground mb-4">
                    Secure your application voucher through our safe and convenient payment system.
                  </p>
                  <Button asChild className="w-full bg-accent hover:bg-accent/90">
                    <Link href="/purchase-voucher">Purchase Now</Link>
                  </Button>
                </div>
              </Card>

              <Card className="p-6">
                <div className="text-center">
                  <div className="mx-auto w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center mb-4">
                    <DynamicIcon name="LogIn" className="h-8 w-8 text-primary" />
                  </div>
                  <h3 className="text-xl font-semibold mb-2">Step 2: Complete Application</h3>
                  <p className="text-muted-foreground mb-4">
                    Use your voucher credentials to access the portal and complete your application.
                  </p>
                  <Button asChild variant="outline" className="w-full bg-transparent">
                    <Link href="/login">Login to Portal</Link>
                  </Button>
                </div>
              </Card>
            </div>
          </div>
        </div>
      </section>

      {/* Footer */}
      <footer className="bg-primary text-primary-foreground py-12">
        <div className="container mx-auto px-4">
          <div className="grid md:grid-cols-4 gap-8">
            <div>
              <div className="flex items-center gap-2 mb-4">
                <Image
                  src="/images/fanaka-logo.png"
                  alt="Fanaka International University College Logo"
                  width={24}
                  height={24}
                  className="h-6 w-auto brightness-0 invert"
                />
                <span className="text-lg font-bold">Fanaka International University College</span>
              </div>
              <p className="text-primary-foreground/80">
                Empowering minds, shaping futures, and building tomorrow's leaders through excellence in education and
                research.
              </p>
            </div>
            <div>
              <h4 className="font-semibold mb-4">Quick Links</h4>
              <ul className="space-y-2 text-primary-foreground/80">
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Admissions
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Academic Programs
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Student Life
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Research
                  </Link>
                </li>
              </ul>
            </div>
            <div>
              <h4 className="font-semibold mb-4">Support</h4>
              <ul className="space-y-2 text-primary-foreground/80">
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Help Center
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Contact Us
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    FAQs
                  </Link>
                </li>
                <li>
                  <Link href="#" className="hover:text-primary-foreground transition-colors">
                    Technical Support
                  </Link>
                </li>
              </ul>
            </div>
            <div>
              <h4 className="font-semibold mb-4">Contact Info</h4>
              <div className="space-y-2 text-primary-foreground/80">
                <p>123 University Avenue</p>
                <p>Academic City, AC 12345</p>
                <p>Phone: (555) 123-4567</p>
                <p>Email: admissions@fanaka.edu</p>
              </div>
            </div>
          </div>
          <div className="border-t border-primary-foreground/20 mt-8 pt-8 text-center text-primary-foreground/80">
            <p>&copy; 2025 Fanaka International University College. All rights reserved.</p>
          </div>
        </div>
      </footer>
    </div>
  )
}
