import React from 'react';
import { Head, Link } from '@inertiajs/react';
import { 
    Home, 
    MessageCircle, 
    User, 
    Search,
    ArrowLeft,
    CheckCheck,
    Compass,
    Bell
} from 'lucide-react';

export default function WorkerChatList() {
    const chats = [
        { id: 1, name: 'Al Mansoor', message: "Great! Let's connect at 10 AM.", time: '10:45 AM', unread: 2, avatar: 'M' },
        { id: 2, name: 'Maktoom Family', message: 'Thank you for the update.', time: 'Yesterday', unread: 0, avatar: 'S' },
        { id: 3, name: 'Zayed Household', message: 'Are you available for a trial?', time: '2 days ago', unread: 0, avatar: 'E' },
    ];

    return (
        <div className="min-h-screen bg-white font-sans text-slate-900 flex flex-col max-w-md mx-auto shadow-2xl relative overflow-hidden pb-24">
            <Head title="Messages" />
            
            {/* Header */}
            <div className="px-6 pt-12 pb-4 bg-white flex items-center justify-between border-b border-slate-50 sticky top-0 z-50">
                <button onClick={() => window.history.back()} className="w-10 h-10 flex items-center justify-center text-slate-900">
                    <ArrowLeft className="w-5 h-5" />
                </button>
                <h1 className="text-sm font-black uppercase tracking-widest">Messages</h1>
                <button className="w-10 h-10 flex items-center justify-center text-slate-900">
                    <Search className="w-5 h-5" />
                </button>
            </div>

            <div className="flex-1 overflow-y-auto px-6 py-6 space-y-2">
                {chats.map((chat) => (
                    <Link 
                        key={chat.id}
                        href="/mobile/worker/chat/detail"
                        className="flex items-center space-x-4 p-4 rounded-[24px] hover:bg-slate-50 transition-all border border-transparent active:border-slate-100 active:scale-[0.98]"
                    >
                        <div className="w-14 h-14 rounded-full bg-[#E0E7FF] flex items-center justify-center text-[#185FA5] font-black text-lg shadow-sm border-2 border-white">
                            {chat.avatar}
                        </div>
                        <div className="flex-1 space-y-1">
                            <div className="flex items-center justify-between">
                                <h3 className="font-black text-sm text-slate-900 uppercase tracking-tight">{chat.name}</h3>
                                <span className="text-[9px] font-bold text-slate-300 uppercase">{chat.time}</span>
                            </div>
                            <div className="flex items-center justify-between">
                                <p className={`text-xs line-clamp-1 ${chat.unread > 0 ? 'font-black text-slate-900' : 'text-slate-400'}`}>
                                    {chat.message}
                                </p>
                                {chat.unread > 0 ? (
                                    <div className="w-5 h-5 bg-[#185FA5] rounded-full flex items-center justify-center text-[10px] font-black text-white shadow-lg shadow-blue-500/20">
                                        {chat.unread}
                                    </div>
                                ) : (
                                    <CheckCheck className="w-4 h-4 text-[#185FA5]" />
                                )}
                            </div>
                        </div>
                    </Link>
                ))}
            </div>

            {/* Bottom Navigation */}
            <div className="fixed bottom-0 left-0 right-0 max-w-md mx-auto bg-white/90 backdrop-blur-xl border-t border-slate-100 px-6 py-4 flex items-center justify-between z-50">
                <Link href="/mobile/worker/home" className="flex flex-col items-center space-y-1 text-slate-300">
                    <Home className="w-5 h-5" />
                    <span className="text-[8px] font-black uppercase tracking-tight">Home</span>
                </Link>
                <Link href="#" className="flex flex-col items-center space-y-1 text-slate-300">
                    <Compass className="w-5 h-5" />
                    <span className="text-[8px] font-black uppercase tracking-tight">Explore</span>
                </Link>
                <Link href="/mobile/worker/announcements" className="flex flex-col items-center space-y-1 text-slate-300">
                    <Bell className="w-5 h-5" />
                    <span className="text-[8px] font-black uppercase tracking-tight">Updates</span>
                </Link>
                <Link href="/mobile/worker/chat" className="flex flex-col items-center space-y-1 text-[#185FA5]">
                    <MessageCircle className="w-5 h-5 fill-current" />
                    <span className="text-[8px] font-black uppercase tracking-tight">Chat</span>
                </Link>
                <Link href="/mobile/worker/profile" className="flex flex-col items-center space-y-1 text-slate-300">
                    <User className="w-5 h-5" />
                    <span className="text-[8px] font-black uppercase tracking-tight">Profile</span>
                </Link>
            </div>
        </div>
    );
}
