'use client';

import React from 'react';
import Link from 'next/link';
import { motion, Variants } from 'framer-motion';
import {
    Link as LinkIcon,
    User,
    Mail,
    Calendar,
    Facebook,
    Instagram,
    Phone,
    MessageSquare,
    Type,
    Music,
    Twitter,
    MessageCircle,
    Wifi,
    Youtube,
    Bitcoin,
    MapPin,
    CreditCard,
    Video,
    Users,
    Barcode,
    Star
} from 'lucide-react';

const TOOLS = [
    {
        icon: LinkIcon,
        name: 'URL',
        description: 'Open any website',
        href: '/tools/url-qr-code',
        color: 'text-blue-500',
        bg: 'bg-blue-50'
    },
    {
        icon: User,
        name: 'vCard',
        description: 'Share contact details',
        href: '/tools/vcard-qr-code',
        color: 'text-rose-500',
        bg: 'bg-rose-50'
    },
    {
        icon: Type,
        name: 'Text',
        description: 'Display plain text',
        href: '/tools/text-qr-code',
        color: 'text-slate-600',
        bg: 'bg-slate-50'
    },
    {
        icon: Mail,
        name: 'Email',
        description: 'Send an email',
        href: '/tools/email-qr-code',
        color: 'text-red-500',
        bg: 'bg-red-50'
    },
    {
        icon: MessageSquare,
        name: 'SMS',
        description: 'Send a text message',
        href: '/tools/sms-qr-code',
        color: 'text-green-500',
        bg: 'bg-green-50'
    },
    {
        icon: Wifi,
        name: 'WiFi',
        description: 'Connect to WiFi',
        href: '/tools/wifi-qr-code',
        color: 'text-indigo-500',
        bg: 'bg-indigo-50'
    },
    {
        icon: Bitcoin,
        name: 'Crypto',
        description: 'Receive payments',
        href: '/tools/crypto-qr-code',
        color: 'text-orange-500',
        bg: 'bg-orange-50'
    },
    {
        icon: Calendar,
        name: 'Event',
        description: 'Save calendar event',
        href: '/tools/event-qr-code',
        color: 'text-violet-500',
        bg: 'bg-violet-50'
    },
    {
        icon: Facebook,
        name: 'Facebook',
        description: 'Open Facebook page',
        href: '/tools/facebook-qr-code',
        color: 'text-blue-600',
        bg: 'bg-blue-50'
    },
    {
        icon: Instagram,
        name: 'Instagram',
        description: 'Open Instagram profile',
        href: '/tools/instagram-qr-code',
        color: 'text-pink-500',
        bg: 'bg-pink-50'
    },
    {
        icon: Twitter,
        name: 'Twitter',
        description: 'Open Twitter profile',
        href: '/tools/twitter-qr-code',
        color: 'text-sky-500',
        bg: 'bg-sky-50'
    },
    {
        icon: Youtube,
        name: 'YouTube',
        description: 'Open YouTube video',
        href: '/tools/youtube-qr-code',
        color: 'text-red-600',
        bg: 'bg-red-50'
    },
    {
        icon: MessageCircle,
        name: 'WhatsApp',
        description: 'Send WhatsApp message',
        href: '/tools/whatsapp-qr-code',
        color: 'text-green-600',
        bg: 'bg-green-50'
    },
    {
        icon: Music,
        name: 'TikTok',
        description: 'Open TikTok profile',
        href: '/tools/tiktok-qr-code',
        color: 'text-pink-600',
        bg: 'bg-pink-50'
    },
    {
        icon: MapPin,
        name: 'Location',
        description: 'Share GPS coordinates',
        href: '/tools/geolocation-qr-code',
        color: 'text-emerald-500',
        bg: 'bg-emerald-50'
    },
    {
        icon: Phone,
        name: 'Call',
        description: 'Start a phone call',
        href: '/tools/call-qr-code-generator',
        color: 'text-violet-500',
        bg: 'bg-violet-50'
    },
    {
        icon: CreditCard,
        name: 'PayPal',
        description: 'Receive PayPal payments',
        href: '/tools/paypal-qr-code',
        color: 'text-blue-700',
        bg: 'bg-blue-50'
    },
    {
        icon: Video,
        name: 'Zoom',
        description: 'Join Zoom meeting',
        href: '/tools/zoom-qr-code',
        color: 'text-sky-500',
        bg: 'bg-sky-50'
    },
    {
        icon: Users,
        name: 'Teams',
        description: 'Join Teams meeting',
        href: '/tools/teams-qr-code',
        color: 'text-violet-500',
        bg: 'bg-violet-50'
    },
    {
        icon: Barcode,
        name: 'Barcode',
        description: 'Create standard barcodes',
        href: '/tools/barcode-generator',
        color: 'text-slate-900',
        bg: 'bg-slate-100'
    },
    {
        icon: Star,
        name: 'Google Review',
        description: 'Get more Google reviews',
        href: '/tools/google-review-qr-code',
        color: 'text-yellow-500',
        bg: 'bg-yellow-50'
    }
];

// Animation variants
const containerVariants: Variants = {
    hidden: { opacity: 0 },
    visible: {
        opacity: 1,
        transition: {
            staggerChildren: 0.05
        }
    }
};

const itemVariants: Variants = {
    hidden: { opacity: 0, y: 20 },
    visible: {
        opacity: 1,
        y: 0,
        transition: {
            duration: 0.4
        }
    }
};

export function FreeToolsGrid() {
    return (
        <section id="tools" className="py-24 bg-slate-50/50 border-t border-slate-100">
            <div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-7xl">
                <motion.div
                    initial={{ opacity: 0, y: 20 }}
                    whileInView={{ opacity: 1, y: 0 }}
                    viewport={{ once: true, margin: "-100px" }}
                    transition={{ duration: 0.5 }}
                    className="text-center mb-16"
                >
                    <div className="flex flex-col md:flex-row items-center justify-center gap-3 mb-4">
                        <h2 className="text-3xl lg:text-4xl font-bold text-slate-900">
                            More Free QR Code Tools
                        </h2>
                        <div className="bg-gradient-to-r from-emerald-500 to-green-500 text-white px-3 py-1 rounded-full text-xs md:text-sm font-semibold shadow-lg shadow-emerald-500/20 flex items-center gap-2">
                            <span className="relative flex h-2 w-2">
                                <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-white opacity-75"></span>
                                <span className="relative inline-flex rounded-full h-2 w-2 bg-white"></span>
                            </span>
                            Free Forever
                        </div>
                    </div>
                    <p className="text-lg text-slate-600 max-w-2xl mx-auto">
                        Create specialized QR codes for every need. Completely free and no signup required.
                    </p>
                </motion.div>

                <motion.div
                    variants={containerVariants}
                    initial="hidden"
                    whileInView="visible"
                    viewport={{ once: true, margin: "-50px" }}
                    className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-4 md:gap-6"
                >
                    {TOOLS.map((tool) => (
                        <motion.div key={tool.name} variants={itemVariants}>
                            <Link
                                href={tool.href}
                                className="group flex flex-col items-center p-5 md:p-6 rounded-2xl border border-slate-200/80 bg-white hover:border-primary-200 hover:shadow-xl hover:shadow-primary-500/10 transition-all duration-300"
                            >
                                <div className={`w-12 h-12 md:w-14 md:h-14 rounded-xl ${tool.bg} flex items-center justify-center mb-3 md:mb-4 group-hover:scale-110 transition-transform duration-300`}>
                                    <tool.icon className={`w-6 h-6 md:w-7 md:h-7 ${tool.color}`} />
                                </div>
                                <h3 className="text-base md:text-lg font-semibold text-slate-900 mb-0.5">
                                    {tool.name}
                                </h3>
                                <p className="text-xs md:text-sm text-slate-600 text-center">
                                    {tool.description}
                                </p>
                            </Link>
                        </motion.div>
                    ))}
                </motion.div>
            </div>
        </section>
    );
}
