'use client';

import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { ExternalLink, Sparkles, Wind, Pill, Coffee, Star, Quote } from 'lucide-react';
import Image from 'next/image';
import { useTheme } from '@/lib/theme-context';
import { Badge } from '@/components/ui/badge';

const smokingAids = [
    {
        id: 'breathing-necklace',
        title: '528Hz Anxiety Relief Breathing Necklace',
        category: 'Mindfulness',
        rating: 4.6,
        description: 'A discreet mindfulness tool designed to help you manage cravings and anxiety through deep breathing exercises. The 528Hz frequency is associated with relaxation and healing.',
        benefit: 'Helps replace the physical hand-to-mouth habit while promoting calming deep breaths during stressful moments or cravings.',
        image: 'https://m.media-amazon.com/images/I/51VJ5HANaRL._AC_SY695_.jpg',
        url: 'https://amzn.to/3Z2BuCk',
        icon: Wind,
        color: 'text-sky-400',
        bgColor: 'bg-sky-500/10',
        borderColor: 'border-sky-500/20',
        buttonColor: 'bg-sky-500 hover:bg-sky-600',
    },
    {
        id: 'nicotine-lozenge',
        title: 'Nicotine Polacrilex Lozenge (2mg)',
        category: 'NRT',
        rating: 4.5,
        description: 'Effective nicotine replacement therapy to help control withdrawal symptoms. These lozenges provide a controlled dose of nicotine to ease you off cigarettes.',
        benefit: 'Reduces physical withdrawal symptoms like irritability and intense cravings, making the transition to being smoke-free smoother.',
        image: 'https://m.media-amazon.com/images/I/61h+Z88Ev9S._AC_SX679_.jpg',
        url: 'https://amzn.to/4rfQl8s',
        icon: Pill,
        color: 'text-red-400',
        bgColor: 'bg-red-500/10',
        borderColor: 'border-red-500/20',
        buttonColor: 'bg-red-500 hover:bg-red-600',
    },
    {
        id: 'recovery-complex',
        title: 'QuitK Recovery Complex',
        category: 'Supplement',
        rating: 4.4,
        description: 'A comprehensive supplement blend containing Magnesium, Ashwagandha, and GABA designed specifically to support your body during the detox process.',
        benefit: 'Supports mood stability and relaxation while your body clears out toxins, helping to minimize the mental strain of quitting.',
        image: 'https://m.media-amazon.com/images/I/51HWgmCW1-L._AC_SX679_.jpg',
        url: 'https://amzn.to/3NFU1Sx',
        icon: Sparkles,
        color: 'text-purple-400',
        bgColor: 'bg-purple-500/10',
        borderColor: 'border-purple-500/20',
        buttonColor: 'bg-purple-500 hover:bg-purple-600',
    },
    {
        id: 'mullein-tea',
        title: 'Tarbust Mullein Tea for Lung Detox',
        category: 'Herbal',
        rating: 4.7,
        description: 'Organic herbal tea formulated with Mullein leaf, traditionally used to support respiratory health and clear congestion.',
        benefit: 'Aids in clearing mucus and toxins from your lungs, supporting your body\'s natural healing process as you recover from smoking.',
        image: 'https://m.media-amazon.com/images/I/81NU8bv72uL._SX679_PIbundle-20,TopRight,0,0_SX679SY693SH20_.jpg',
        url: 'https://amzn.to/3LzNpEM',
        icon: Coffee,
        color: 'text-green-400',
        bgColor: 'bg-green-500/10',
        borderColor: 'border-green-500/20',
        buttonColor: 'bg-green-500 hover:bg-green-600',
    },
];

export default function SmokingAidsPage() {
    const { theme } = useTheme();

    return (
        <div className="min-h-screen pb-24 pt-28 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto space-y-16">
            {/* Hero Section */}
            <div className="relative text-center space-y-6 max-w-4xl mx-auto animate-in fade-in slide-in-from-bottom-8 duration-700">
                <div className="absolute top-0 left-1/2 -translate-x-1/2 w-32 h-32 bg-purple-500/20 rounded-full blur-3xl -z-10" />

                <h1 className="text-4xl sm:text-6xl font-extrabold tracking-tight">
                    Tools for Your <span className="text-transparent bg-clip-text bg-gradient-to-r from-purple-400 via-pink-400 to-orange-400">Freedom</span>
                </h1>
                <p className="text-lg sm:text-xl text-muted-foreground leading-relaxed max-w-2xl mx-auto">
                    Transform your journey with tools designed to support your physical recovery and mental resilience. You don't have to do this alone.
                </p>
            </div>

            {/* Grid Section */}
            <div className="grid grid-cols-1 lg:grid-cols-2 gap-6 sm:gap-8">
                {smokingAids.map((item, index) => (
                    <div
                        key={item.id}
                        className="group animate-in fade-in slide-in-from-bottom-12 fill-mode-both"
                        style={{ animationDelay: `${index * 150}ms` }}
                    >
                        <Card className="h-full flex flex-col overflow-hidden border-border/40 hover:border-border/80 transition-all duration-300 hover:shadow-2xl hover:-translate-y-1 bg-card/30 backdrop-blur-xl relative group">
                            {/* Full card gradient overlay on hover */}
                            <div className={`absolute inset-0 bg-gradient-to-br ${item.bgColor.replace('bg-', 'from-').split('/')[0]}/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none z-0`} />

                            <div className="flex flex-col sm:flex-row h-full relative z-10">
                                {/* Image Section - Top on mobile, Left on desktop */}
                                <div className="relative w-full sm:w-2/5 h-64 sm:h-auto bg-gradient-to-br from-white/5 to-white/0 p-6 flex items-center justify-center shrink-0">
                                    <div className="relative w-40 h-40 sm:w-48 sm:h-48 transition-transform duration-500 group-hover:scale-105 bg-white rounded-full shadow-lg flex items-center justify-center overflow-hidden">
                                        <div className="relative w-3/4 h-3/4">
                                            <Image
                                                src={item.image}
                                                alt={item.title}
                                                fill
                                                className="object-contain drop-shadow-sm"
                                                sizes="(max-width: 640px) 100vw, 300px"
                                            />
                                        </div>
                                    </div>
                                    <Badge variant="secondary" className="absolute top-4 left-4 backdrop-blur-md bg-white text-black border-white/20 shadow-sm px-3 py-1 text-sm font-medium">
                                        {item.category}
                                    </Badge>
                                </div>

                                {/* Content Section */}
                                <div className="flex flex-col flex-grow p-6 sm:p-8">
                                    <div className="flex items-start justify-between gap-4 mb-4">
                                        <div>
                                            <h3 className="text-xl font-bold group-hover:text-primary transition-colors line-clamp-2">
                                                {item.title}
                                            </h3>
                                            <div className="flex items-center gap-1 mt-2">
                                                {[...Array(5)].map((_, i) => (
                                                    <Star
                                                        key={i}
                                                        className={`w-3.5 h-3.5 ${i < Math.floor(item.rating) ? 'fill-yellow-400 text-yellow-400' : 'text-muted'}`}
                                                    />
                                                ))}
                                                <span className="text-xs text-muted-foreground ml-2">({item.rating})</span>
                                            </div>
                                        </div>
                                        <div className={`p-2.5 rounded-xl ${item.bgColor} ${item.color} shrink-0`}>
                                            <item.icon className="w-5 h-5" />
                                        </div>
                                    </div>

                                    <p className="text-muted-foreground text-sm leading-relaxed mb-6 line-clamp-3">
                                        {item.description}
                                    </p>

                                    <div className={`mt-auto p-4 rounded-xl ${item.bgColor} border ${item.borderColor} mb-6`}>
                                        <div className="flex gap-3">
                                            <Quote className={`w-4 h-4 ${item.color} shrink-0 flip-x`} />
                                            <p className="text-xs font-medium italic opacity-90">
                                                {item.benefit}
                                            </p>
                                        </div>
                                    </div>

                                    <Button
                                        asChild
                                        className={`w-full text-white font-semibold shadow-lg transition-all duration-300 hover:ring-2 hover:ring-offset-2 hover:ring-offset-background ${item.buttonColor} rounded-xl h-12`}
                                    >
                                        <a href={item.url} target="_blank" rel="noopener noreferrer" className="flex items-center justify-center gap-2">
                                            View on Amazon
                                            <ExternalLink className="w-4 h-4 ml-1" />
                                        </a>
                                    </Button>
                                </div>
                            </div>
                        </Card>
                    </div>
                ))}
            </div>

            {/* Trust/Disclaimer Section */}
            <div className="border-t border-border/40 py-12 text-center space-y-4">
                <p className="text-sm text-muted-foreground max-w-2xl mx-auto px-4">
                    <span className="block font-medium mb-1 text-foreground/80">Transparency Note</span>
                    As an Amazon Associate, we earn from qualifying purchases. This helps support the development of QuitTraq at no extra cost to you.
                    Always consult with a healthcare professional before starting any new supplement or nicotine replacement therapy.
                </p>
            </div>
        </div>
    );
}
