"use client"

import { useState, useEffect } from "react"
import { Button } from "@/components/ui/button"
import { AnimatedButton } from "@/components/ui/animated-button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { AnimatedCard } from "@/components/ui/animated-card"
import { Badge } from "@/components/ui/badge"
import { Header } from "@/components/ui/header"
import { Footer } from "@/components/ui/footer"
import {
  CheckCircle,
  Star,
  Clock,
  Eye,
  ArrowRight,
  Home,
  Search,
  MessageSquare,
  Share2,
  ThumbsUp,
  Heart,
  Gift
} from "lucide-react"
import Image from "next/image"
import Link from "next/link"
import { motion } from "framer-motion"

// Mock review data - in real app this would come from URL params or API
const mockReviewData = {
  confirmationNumber: "REV-2024-003982",
  facility: {
    name: "Sunrise Senior Living",
    type: "Assisted Living",
    image: "/senior-living-facility-exterior.jpg"
  },
  review: {
    rating: 5,
    title: "Excellent care for my mother",
    content: "The staff at Sunrise is incredibly caring and professional. My mother has been here for 8 months and has thrived. The activities keep her engaged and the meals are delicious.",
    submittedAt: new Date().toISOString()
  },
  reviewer: {
    name: "John Smith",
    relationship: "Son"
  }
}

export default function ReviewSuccessPage() {
  const [isLoading, setIsLoading] = useState(true)

  useEffect(() => {
    // Simulate loading
    const timer = setTimeout(() => {
      setIsLoading(false)
    }, 1000)
    return () => clearTimeout(timer)
  }, [])

  if (isLoading) {
    return (
      <div className="min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50/30 flex items-center justify-center">
        <div className="text-center">
          <div className="w-16 h-16 border-4 border-[#3F5CEA] border-t-transparent rounded-full animate-spin mx-auto mb-4"></div>
          <h3 className="font-primary text-2xl font-bold text-slate-800 mb-2">Submitting Your Review</h3>
          <p className="font-body text-lg text-slate-600">Processing your feedback...</p>
        </div>
      </div>
    )
  }

  return (
    <div className="min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50/30">
      <Header />

      <div className="container mx-auto px-4 py-12">
        <div className="max-w-4xl mx-auto">
          {/* Success Animation */}
          <motion.div
            initial={{ opacity: 0, scale: 0.8 }}
            animate={{ opacity: 1, scale: 1 }}
            transition={{ duration: 0.6, type: "spring", stiffness: 300 }}
            className="text-center mb-8"
          >
            <div className="mx-auto mb-6 w-24 h-24 rounded-full bg-gradient-to-br from-green-500 to-green-600 flex items-center justify-center shadow-lg">
              <CheckCircle className="h-12 w-12 text-white" />
            </div>

            <h1 className="font-primary text-4xl md:text-5xl font-bold text-gray-900 mb-4">
              Thank You for Your Review!
            </h1>

            <p className="font-body text-xl text-gray-600 max-w-2xl mx-auto leading-relaxed">
              Your review has been submitted and is being reviewed by our moderation team. It will be published once approved.
            </p>

            <Badge className="mt-4 bg-green-100 text-green-800 text-lg px-4 py-2">
              Review ID: {mockReviewData.confirmationNumber}
            </Badge>
          </motion.div>

          <div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
            {/* Main Content */}
            <div className="lg:col-span-2 space-y-6">
              {/* Review Summary */}
              <AnimatedCard className="overflow-hidden">
                <CardHeader className="bg-gradient-to-r from-blue-50 to-indigo-50 border-b border-blue-200/50">
                  <CardTitle className="font-primary text-2xl text-gray-900 flex items-center gap-3">
                    <MessageSquare className="h-6 w-6 text-[#3F5CEA]" />
                    Your Review Summary
                  </CardTitle>
                </CardHeader>
                <CardContent className="p-6">
                  <div className="flex flex-col md:flex-row gap-6">
                    <div className="md:w-48 h-32 relative rounded-lg overflow-hidden">
                      <Image
                        src={mockReviewData.facility.image}
                        alt={mockReviewData.facility.name}
                        fill
                        className="object-cover"
                      />
                    </div>
                    <div className="flex-1">
                      <h3 className="font-primary text-2xl font-bold text-gray-900 mb-2">
                        {mockReviewData.facility.name}
                      </h3>
                      <Badge variant="secondary" className="mb-3 bg-blue-100 text-blue-800">
                        {mockReviewData.facility.type}
                      </Badge>

                      <div className="space-y-3">
                        <div className="flex items-center gap-2">
                          <div className="flex items-center">
                            {[...Array(5)].map((_, i) => (
                              <Star
                                key={i}
                                className={`h-5 w-5 ${i < mockReviewData.review.rating
                                    ? "fill-yellow-400 text-yellow-400"
                                    : "text-gray-300"
                                  }`}
                              />
                            ))}
                          </div>
                          <span className="font-body font-semibold text-lg">{mockReviewData.review.rating} stars</span>
                        </div>

                        <div>
                          <h4 className="font-body font-semibold text-gray-900 mb-1">
                            "{mockReviewData.review.title}"
                          </h4>
                          <p className="font-body text-gray-700 leading-relaxed">
                            {mockReviewData.review.content}
                          </p>
                        </div>

                        <div className="flex items-center gap-2 text-gray-600">
                          <Clock className="h-4 w-4" />
                          <span className="font-body text-sm">
                            Submitted: {new Date(mockReviewData.review.submittedAt).toLocaleString()}
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>

              {/* What's Next */}
              <AnimatedCard>
                <CardHeader className="bg-gradient-to-r from-green-50 to-blue-50 border-b border-green-200/50">
                  <CardTitle className="font-primary text-2xl text-gray-900 flex items-center gap-3">
                    <Eye className="h-6 w-6 text-[#3F5CEA]" />
                    Review Process
                  </CardTitle>
                </CardHeader>
                <CardContent className="p-6">
                  <div className="space-y-6">
                    <div className="flex items-start gap-4">
                      <div className="w-8 h-8 rounded-full bg-blue-600 text-white flex items-center justify-center text-sm font-bold flex-shrink-0">1</div>
                      <div>
                        <h4 className="font-body font-semibold text-gray-900 mb-1">Review Submitted</h4>
                        <p className="font-body text-gray-600">Your review has been received and is in our moderation queue.</p>
                        <div className="flex items-center gap-2 mt-2">
                          <CheckCircle className="h-4 w-4 text-green-600" />
                          <span className="font-body text-sm text-green-700 font-medium">Complete</span>
                        </div>
                      </div>
                    </div>

                    <div className="flex items-start gap-4">
                      <div className="w-8 h-8 rounded-full bg-yellow-500 text-white flex items-center justify-center text-sm font-bold flex-shrink-0">2</div>
                      <div>
                        <h4 className="font-body font-semibold text-gray-900 mb-1">Moderation Review</h4>
                        <p className="font-body text-gray-600">Our team reviews all submissions to ensure they meet our community guidelines.</p>
                        <div className="flex items-center gap-2 mt-2">
                          <Clock className="h-4 w-4 text-yellow-600" />
                          <span className="font-body text-sm text-yellow-700 font-medium">In Progress (24-48 hours)</span>
                        </div>
                      </div>
                    </div>

                    <div className="flex items-start gap-4">
                      <div className="w-8 h-8 rounded-full bg-gray-300 text-white flex items-center justify-center text-sm font-bold flex-shrink-0">3</div>
                      <div>
                        <h4 className="font-body font-semibold text-gray-900 mb-1">Review Published</h4>
                        <p className="font-body text-gray-600">Once approved, your review will be visible to other families searching for care.</p>
                        <div className="flex items-center gap-2 mt-2">
                          <Clock className="h-4 w-4 text-gray-500" />
                          <span className="font-body text-sm text-gray-500">Pending</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>
            </div>

            {/* Sidebar */}
            <div className="space-y-6">
              {/* Impact Message */}
              <AnimatedCard className="bg-gradient-to-br from-purple-50 to-pink-50 border-purple-200">
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-purple-900 flex items-center gap-2">
                    <ThumbsUp className="h-5 w-5" />
                    Making a Difference
                  </CardTitle>
                </CardHeader>
                <CardContent>
                  <div className="space-y-4">
                    <div className="text-center">
                      <div className="w-16 h-16 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 text-white flex items-center justify-center mx-auto mb-3">
                        <Heart className="h-8 w-8" />
                      </div>
                      <h3 className="font-body font-semibold text-purple-900 mb-2">
                        Your Voice Matters
                      </h3>
                      <p className="font-body text-sm text-purple-700">
                        Your honest review helps other families make informed decisions about senior care.
                      </p>
                    </div>

                    <div className="grid grid-cols-2 gap-4 text-center">
                      <div className="bg-white/50 p-3 rounded-lg">
                        <div className="font-primary text-lg font-bold text-purple-900">2,847</div>
                        <div className="font-body text-xs text-purple-700">Families Helped</div>
                      </div>
                      <div className="bg-white/50 p-3 rounded-lg">
                        <div className="font-primary text-lg font-bold text-purple-900">98%</div>
                        <div className="font-body text-xs text-purple-700">Find Reviews Helpful</div>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>

              {/* Share Your Experience */}
              <AnimatedCard>
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-gray-900">Share Your Experience</CardTitle>
                </CardHeader>
                <CardContent className="space-y-3">
                  <Button variant="outline" className="w-full border-[#3F5CEA] text-[#3F5CEA] hover:bg-[#3F5CEA] hover:text-white">
                    <Share2 className="h-4 w-4 mr-2" />
                    Share This Review
                  </Button>

                  <Button variant="outline" className="w-full border-gray-300 text-gray-700 hover:bg-gray-50">
                    <MessageSquare className="h-4 w-4 mr-2" />
                    Write Another Review
                  </Button>
                </CardContent>
              </AnimatedCard>

              {/* Rewards */}
              <AnimatedCard className="bg-gradient-to-br from-green-50 to-emerald-50 border-green-200">
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-green-900 flex items-center gap-2">
                    <Gift className="h-5 w-5" />
                    Thank You Rewards
                  </CardTitle>
                </CardHeader>
                <CardContent>
                  <div className="space-y-3">
                    <div className="flex items-center gap-3 p-3 bg-white/50 rounded-lg">
                      <CheckCircle className="h-5 w-5 text-green-600" />
                      <div>
                        <p className="font-body text-sm font-medium text-green-900">Review Points Earned</p>
                        <p className="font-body text-xs text-green-700">+50 Community Points</p>
                      </div>
                    </div>

                    <div className="flex items-center gap-3 p-3 bg-white/50 rounded-lg">
                      <Star className="h-5 w-5 text-green-600" />
                      <div>
                        <p className="font-body text-sm font-medium text-green-900">Reviewer Badge</p>
                        <p className="font-body text-xs text-green-700">Community Contributor</p>
                      </div>
                    </div>

                    <p className="font-body text-xs text-green-600 text-center">
                      Keep sharing to unlock more rewards!
                    </p>
                  </div>
                </CardContent>
              </AnimatedCard>

              {/* Next Steps */}
              <AnimatedCard>
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-gray-900">Continue Your Search</CardTitle>
                </CardHeader>
                <CardContent className="space-y-3">
                  <Link href="/search" className="block">
                    <AnimatedButton className="w-full bg-gradient-to-r from-[#3F5CEA] to-[#5B73F0] hover:from-[#09183D] hover:to-[#3F5CEA] text-white">
                      <Search className="h-4 w-4 mr-2" />
                      Find More Facilities
                    </AnimatedButton>
                  </Link>

                  <Link href="/dashboard" className="block">
                    <Button variant="outline" className="w-full border-[#3F5CEA] text-[#3F5CEA] hover:bg-[#3F5CEA] hover:text-white">
                      <ArrowRight className="h-4 w-4 mr-2" />
                      View Dashboard
                    </Button>
                  </Link>

                  <Link href="/favorites" className="block">
                    <Button variant="outline" className="w-full border-gray-300 text-gray-700 hover:bg-gray-50">
                      <Heart className="h-4 w-4 mr-2" />
                      View Saved Facilities
                    </Button>
                  </Link>
                </CardContent>
              </AnimatedCard>
            </div>
          </div>

          {/* Navigation */}
          <div className="mt-12 flex flex-col sm:flex-row gap-4 justify-center">
            <Link href="/search">
              <AnimatedButton variant="outline" className="border-[#3F5CEA] text-[#3F5CEA] hover:bg-[#3F5CEA] hover:text-white">
                <ArrowRight className="h-4 w-4 mr-2" />
                Continue Exploring Facilities
              </AnimatedButton>
            </Link>
            <Link href="/">
              <Button variant="outline" className="border-gray-300 text-gray-700 hover:bg-gray-50">
                <Home className="h-4 w-4 mr-2" />
                Back to Home
              </Button>
            </Link>
          </div>
        </div>
      </div>

      <Footer />
    </div>
  )
}
