"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,
  Mail,
  Clock,
  Phone,
  MessageSquare,
  ArrowRight,
  Home,
  Search,
  Heart,
  Star,
  Calendar
} from "lucide-react"
import Image from "next/image"
import Link from "next/link"
import { motion } from "framer-motion"

// Mock inquiry data - in real app this would come from URL params or API
const mockInquiryData = {
  confirmationNumber: "INQ-2024-002847",
  facility: {
    name: "Sunrise Senior Living",
    type: "Assisted Living",
    image: "/senior-living-facility-exterior.jpg",
    responseTime: "24 hours"
  },
  inquiryType: "General Information",
  submittedAt: new Date().toISOString(),
  contactInfo: {
    name: "John Smith",
    email: "john.smith@example.com",
    phone: "(555) 987-6543",
    preferredContact: "email"
  }
}

export default function ContactSuccessPage() {
  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">Sending Your Message</h3>
          <p className="font-body text-lg text-slate-600">Processing your inquiry...</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">
              Message Sent Successfully!
            </h1>

            <p className="font-body text-xl text-gray-600 max-w-2xl mx-auto leading-relaxed">
              Your inquiry has been sent to the facility. They'll respond within their typical response time.
            </p>

            <Badge className="mt-4 bg-green-100 text-green-800 text-lg px-4 py-2">
              Reference #{mockInquiryData.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">
              {/* Facility Information */}
              <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 Inquiry Details
                  </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={mockInquiryData.facility.image}
                        alt={mockInquiryData.facility.name}
                        fill
                        className="object-cover"
                      />
                    </div>
                    <div className="flex-1">
                      <h3 className="font-primary text-2xl font-bold text-gray-900 mb-2">
                        {mockInquiryData.facility.name}
                      </h3>
                      <Badge variant="secondary" className="mb-3 bg-blue-100 text-blue-800">
                        {mockInquiryData.facility.type}
                      </Badge>
                      <div className="space-y-3">
                        <div className="flex items-center gap-2 text-gray-600">
                          <MessageSquare className="h-4 w-4" />
                          <span className="font-body">Inquiry Type: {mockInquiryData.inquiryType}</span>
                        </div>
                        <div className="flex items-center gap-2 text-gray-600">
                          <Clock className="h-4 w-4" />
                          <span className="font-body">
                            Submitted: {new Date(mockInquiryData.submittedAt).toLocaleString()}
                          </span>
                        </div>
                        <div className="flex items-center gap-2 text-green-600">
                          <CheckCircle className="h-4 w-4" />
                          <span className="font-body font-medium">
                            Expected response within {mockInquiryData.facility.responseTime}
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>

              {/* Contact Information Used */}
              <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">
                    <Mail className="h-6 w-6 text-[#3F5CEA]" />
                    Contact Information
                  </CardTitle>
                </CardHeader>
                <CardContent className="p-6">
                  <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div className="space-y-4">
                      <div className="bg-gradient-to-r from-blue-50 to-indigo-50 p-4 rounded-lg border border-blue-200/50">
                        <div className="flex items-center gap-3 mb-2">
                          <Mail className="h-5 w-5 text-[#3F5CEA]" />
                          <span className="font-body font-medium text-gray-900">Email Address</span>
                        </div>
                        <p className="font-primary text-lg font-bold text-gray-900">
                          {mockInquiryData.contactInfo.email}
                        </p>
                      </div>

                      <div className="bg-gradient-to-r from-green-50 to-blue-50 p-4 rounded-lg border border-green-200/50">
                        <div className="flex items-center gap-3 mb-2">
                          <Phone className="h-5 w-5 text-[#3F5CEA]" />
                          <span className="font-body font-medium text-gray-900">Phone Number</span>
                        </div>
                        <p className="font-primary text-lg font-bold text-gray-900">
                          {mockInquiryData.contactInfo.phone}
                        </p>
                      </div>
                    </div>

                    <div className="space-y-4">
                      <div className="bg-gradient-to-r from-purple-50 to-pink-50 p-4 rounded-lg border border-purple-200/50">
                        <div className="flex items-center gap-3 mb-2">
                          <MessageSquare className="h-5 w-5 text-[#3F5CEA]" />
                          <span className="font-body font-medium text-gray-900">Preferred Contact</span>
                        </div>
                        <p className="font-primary text-lg font-bold text-gray-900 capitalize">
                          {mockInquiryData.contactInfo.preferredContact}
                        </p>
                      </div>

                      <div className="bg-gradient-to-r from-orange-50 to-red-50 p-4 rounded-lg border border-orange-200/50">
                        <div className="flex items-center gap-3 mb-2">
                          <CheckCircle className="h-5 w-5 text-[#3F5CEA]" />
                          <span className="font-body font-medium text-gray-900">Status</span>
                        </div>
                        <Badge className="bg-green-100 text-green-800">
                          Message Delivered
                        </Badge>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>
            </div>

            {/* Sidebar */}
            <div className="space-y-6">
              {/* What Happens Next */}
              <AnimatedCard className="bg-gradient-to-br from-blue-50 to-indigo-50 border-blue-200">
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-blue-900">What Happens Next?</CardTitle>
                </CardHeader>
                <CardContent>
                  <div className="space-y-4">
                    <div className="flex items-start gap-3">
                      <div className="w-6 h-6 rounded-full bg-blue-600 text-white flex items-center justify-center text-sm font-bold">1</div>
                      <div>
                        <p className="font-body font-medium text-blue-900">Facility Review</p>
                        <p className="font-body text-sm text-blue-700">The facility team reviews your inquiry</p>
                      </div>
                    </div>
                    <div className="flex items-start gap-3">
                      <div className="w-6 h-6 rounded-full bg-blue-600 text-white flex items-center justify-center text-sm font-bold">2</div>
                      <div>
                        <p className="font-body font-medium text-blue-900">Personal Response</p>
                        <p className="font-body text-sm text-blue-700">They'll contact you directly with answers</p>
                      </div>
                    </div>
                    <div className="flex items-start gap-3">
                      <div className="w-6 h-6 rounded-full bg-blue-600 text-white flex items-center justify-center text-sm font-bold">3</div>
                      <div>
                        <p className="font-body font-medium text-blue-900">Schedule Visit</p>
                        <p className="font-body text-sm text-blue-700">Plan a facility tour if interested</p>
                      </div>
                    </div>
                  </div>
                </CardContent>
              </AnimatedCard>

              {/* Quick Actions */}
              <AnimatedCard>
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-gray-900">While You Wait</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" />
                      Continue Searching
                    </AnimatedButton>
                  </Link>

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

                  <Link href="/reviews" className="block">
                    <Button
                      variant="outline"
                      className="w-full border-gray-300 text-gray-700 hover:bg-gray-50"
                    >
                      <Star className="h-4 w-4 mr-2" />
                      Read More Reviews
                    </Button>
                  </Link>
                </CardContent>
              </AnimatedCard>

              {/* Tips */}
              <AnimatedCard className="bg-gradient-to-br from-yellow-50 to-orange-50 border-yellow-200">
                <CardHeader>
                  <CardTitle className="font-primary text-xl text-orange-900">Pro Tips</CardTitle>
                </CardHeader>
                <CardContent>
                  <div className="space-y-3">
                    <div className="flex items-start gap-2">
                      <div className="w-1.5 h-1.5 rounded-full bg-orange-500 mt-2 flex-shrink-0"></div>
                      <p className="font-body text-sm text-orange-800">
                        Prepare a list of questions about care services and pricing
                      </p>
                    </div>
                    <div className="flex items-start gap-2">
                      <div className="w-1.5 h-1.5 rounded-full bg-orange-500 mt-2 flex-shrink-0"></div>
                      <p className="font-body text-sm text-orange-800">
                        Consider scheduling tours at multiple facilities
                      </p>
                    </div>
                    <div className="flex items-start gap-2">
                      <div className="w-1.5 h-1.5 rounded-full bg-orange-500 mt-2 flex-shrink-0"></div>
                      <p className="font-body text-sm text-orange-800">
                        Read reviews from other families for insights
                      </p>
                    </div>
                  </div>
                </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" />
                Explore More 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>
  )
}
