import React from 'react';
import { Link } from '@inertiajs/react';
import { PublicHeader } from '@/Components/PublicHeader';
import { PublicFooter } from '@/Components/PublicFooter';
import { SEOHead } from '@/Components/SEOHead';
import { Search as SearchIcon, ArrowRight } from 'lucide-react';

interface SearchProps {
    query: string;
    results: any[];
}

export default function SearchPage({ query, results }: SearchProps) {
    return (
        <div className="min-h-screen bg-[#060B18] text-slate-100 flex flex-col font-sans">
            <SEOHead
                title={`Search Results for "${query}" | Tech in Soul`}
                description="Search across Tech in Soul services, portfolio projects, blog articles, and help center."
            />

            <PublicHeader />

            <main className="flex-grow pt-32 pb-20">
                <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-8">
                    <div className="space-y-2">
                        <span className="text-xs font-bold text-[#00F2FE] uppercase tracking-widest block">
                            GLOBAL SEARCH
                        </span>
                        <h1 className="text-3xl font-extrabold text-white">
                            Results for "<span className="text-[#00F2FE]">{query}</span>"
                        </h1>
                        <p className="text-xs text-slate-400">Found {results.length} matching entry(s)</p>
                    </div>

                    <div className="space-y-4">
                        {results.length > 0 ? (
                            results.map((item, idx) => (
                                <div key={idx} className="glass-card rounded-2xl p-6 space-y-2 group">
                                    <div className="flex items-center justify-between">
                                        <span className="text-[11px] font-semibold px-2.5 py-0.5 rounded-full bg-[#00F2FE]/10 text-[#00F2FE] border border-[#00F2FE]/20">
                                            {item.type}
                                        </span>
                                        <Link href={item.url} className="text-xs text-[#00F2FE] group-hover:underline flex items-center gap-1">
                                            View Page <ArrowRight className="w-3 h-3" />
                                        </Link>
                                    </div>
                                    <h3 className="text-lg font-bold text-white group-hover:text-[#00F2FE] transition-colors">
                                        <Link href={item.url}>{item.title}</Link>
                                    </h3>
                                    <p className="text-xs text-slate-400 leading-relaxed">{item.snippet}</p>
                                </div>
                            ))
                        ) : (
                            <div className="glass-card rounded-2xl p-12 text-center text-slate-400">
                                No results matching "{query}". Try searching with different keywords.
                            </div>
                        )}
                    </div>
                </div>
            </main>

            <PublicFooter />
        </div>
    );
}
