import React from 'react';
import { Head, Link, usePage } from '@inertiajs/react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import {
    Star,
    MapPin,
    Sparkles,
    Navigation,
    Users,
    Globe,
    ArrowRight,
    Clock,
    TrendingUp
} from 'lucide-react';
import AppLayout from '@/layouts/app-layout';
import { useLaravelReactI18n } from 'laravel-react-i18n';
import ExperienceCard from '@/components/experience-card';
import PointOfInterestCard from '@/components/point-of-interest-card';

interface Experience {
    id: number;
    content: string;
    location: string;
    image_url?: string;
    engagement_rate: number;
    is_featured: boolean;
    user?: {
        name?: string;
        id: number;
    };
    stats?: {
        likes_count: number;
        comments_count: number;
        shares_count: number;
        views_count: number;
        total_engagement: number;
    };
}

interface PointOfInterest {
    id: number;
    name: string;
    description: string;
    location: string;
    image_url?: string;
    is_featured?: boolean;
    category?: {
        name: string;
    };
    engagement_rate: number;
}

interface WelcomeProps {
    auth?: any;
    latestExperiences: Experience[];
    latestPointsOfInterest: PointOfInterest[];
}

const Welcome = ({ latestExperiences, latestPointsOfInterest }: WelcomeProps) => {

    return (
        <AppLayout>
            <Head title="Smartsense - Smart Tourism Platform">
                <link rel="preconnect" href="https://fonts.bunny.net" />
                <link href="https://fonts.bunny.net/css?family=instrument-sans:400,500,600" rel="stylesheet" />
            </Head>
            
            <div className="flex flex-col min-h-screen">
                {/* Hero Section */}
                <section className="relative px-4 py-12 lg:py-16 mx-auto max-w-[1400px] w-full overflow-hidden">
                    {/* Background Pattern */}
                    <div className="absolute inset-0 opacity-5">
                        <div className="absolute inset-0" style={{
                            backgroundImage: `url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`
                        }} />
                    </div>
                    
                    <div className="relative text-center">
                        <Badge className="bg-gradient-to-r from-blue-600 to-purple-600 text-white border-0 px-4 py-2 text-sm font-medium mb-6">
                            <Globe className="h-4 w-4 mr-2" />
                            Smart Tourism Platform
                        </Badge>
                        
                        <h1 className="text-3xl sm:text-4xl lg:text-5xl font-bold text-foreground mb-6 leading-tight">
                            Discover the World with
                            <span className="block bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">
                                AI-Powered Trip Planning
                            </span>
                        </h1>
                        
                        <p className="text-muted-foreground text-lg lg:text-xl max-w-3xl mx-auto mb-10 leading-relaxed">
                            Let our AI create personalized travel experiences just for you. Describe your dream trip and discover authentic local experiences and fascinating points of interest.
                        </p>

                        {/* CTA Button - Made Much Bigger */}
                        <div className="flex justify-center">
                            <Button size="lg" className="bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-700 hover:to-purple-700 px-16 py-6 text-2xl font-bold shadow-2xl hover:shadow-3xl transform hover:scale-105 transition-all duration-300" asChild>
                                <Link href="/trip-planner">
                                    <Navigation className="h-8 w-8 mr-4" />
                                    Plan My Perfect Trip
                                </Link>
                            </Button>
                        </div>
                    </div>
                </section>

                {/* Newest Experiences Section */}
                <section className="px-4 py-12 mx-auto max-w-[1400px] w-full">
                    <div className="flex items-center justify-between mb-8">
                        <div>
                            <h2 className="text-2xl lg:text-3xl font-bold text-foreground mb-2 flex items-center gap-2">
                                <TrendingUp className="h-6 w-6 text-green-600" />
                                Newest Experiences
                            </h2>
                            <p className="text-muted-foreground">
                                Fresh authentic experiences shared by our community
                            </p>
                        </div>
                        <Button variant="outline" className="gap-2" asChild>
                            <Link href="/experiences">
                                View All
                                <ArrowRight className="h-4 w-4" />
                            </Link>
                        </Button>
                    </div>
                    
                    <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
                        {latestExperiences.map((experience) => (
                            <Link key={experience.id} href={`/experiences/${experience.id}`} className="block group">
                                <div className="transform transition-all duration-300 group-hover:scale-105 group-hover:shadow-xl">
                                    <ExperienceCard
                                        image={experience.image_url || ''}
                                        title={experience.content.substring(0, 50) + (experience.content.length > 50 ? '...' : '')}
                                        description={experience.content}
                                        category="Experience"
                                        rating={experience.engagement_rate}
                                        price="Free"
                                        duration=""
                                        location={experience.location}
                                    />
                                </div>
                            </Link>
                        ))}
                    </div>
                </section>

                {/* Newest Points of Interest Section */}
                <section className="px-4 py-12 mx-auto max-w-[1400px] w-full">
                    <div className="flex items-center justify-between mb-8">
                        <div>
                            <h2 className="text-2xl lg:text-3xl font-bold text-foreground mb-2 flex items-center gap-2">
                                <TrendingUp className="h-6 w-6 text-purple-600" />
                                Newest Points of Interest
                            </h2>
                            <p className="text-muted-foreground">
                                Discover the latest must-visit destinations
                            </p>
                        </div>
                        <Button variant="outline" className="gap-2" asChild>
                            <Link href="/points-of-interest">
                                View All
                                <ArrowRight className="h-4 w-4" />
                            </Link>
                        </Button>
                    </div>
                    
                    <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
                        {latestPointsOfInterest.map((poi) => (
                            <Link key={poi.id} href={`/points-of-interest/${poi.id}`} className="block group">
                                <div className="transform transition-all duration-300 group-hover:scale-105 group-hover:shadow-xl">
                                    <PointOfInterestCard
                                        image={poi.image_url || ''}
                                        title={poi.name}
                                        description={poi.description}
                                        category={poi.category?.name || 'General'}
                                        rating={poi.engagement_rate}
                                        priceRange=""
                                        openingHours=""
                                        location={poi.location}
                                        features={[]}
                                    />
                                </div>
                            </Link>
                        ))}
                    </div>
                </section>

            </div>
        </AppLayout>
    );
};

export default Welcome;