import { useParams } from 'react-router-dom'
import { services } from '@/data/services'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card'

const ServiceDetail = () => {
  const { slug } = useParams()
  const service = services.find(s => s.id === slug)

  if (!service) {
    return (
      <div className="container mx-auto px-4 py-16 md:py-24">
        <div className="text-center">
          <h1 className="text-3xl font-bold text-primary-navy mb-4">Service Not Found</h1>
          <p className="text-xl text-soft-text mb-8">The service you're looking for doesn't exist.</p>
          <a href="/services" className="text-primary-navy hover:underline">
            Back to Services
          </a>
        </div>
      </div>
    )
  }

  return (
    <div className="container mx-auto px-4 py-16 md:py-24">
      {/* Page Hero */}
      <section className="mb-16">
        <h1 className="text-4xl md:text-5xl font-bold text-primary-navy mb-6">{service.name}</h1>
        <p className="text-xl text-soft-text max-w-3xl">{service.shortDesc}</p>
      </section>

      {/* Main Content */}
      <div className="grid grid-cols-1 lg:grid-cols-3 gap-12">
        {/* Left Column - Main Content */}
        <div className="lg:col-span-2">
          <section className="mb-12">
            <h2 className="text-2xl font-bold text-primary-navy mb-4">What This Solves</h2>
            <p className="text-lg text-soft-text mb-6 leading-relaxed">
              {service.fullDesc}
            </p>
          </section>

          <section className="mb-12">
            <h2 className="text-2xl font-bold text-primary-navy mb-4">Key Benefits</h2>
            <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
              {service.benefits.map((benefit, index) => (
                <div key={index} className="flex items-start gap-3">
                  <div className="h-6 w-6 rounded-full bg-primary-navy text-white flex items-center justify-center flex-shrink-0 mt-1">
                    <svg className="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M5 13l4 4L19 7" />
                    </svg>
                  </div>
                  <span className="text-lg text-text">{benefit}</span>
                </div>
              ))}
            </div>
          </section>

          <section className="mb-12">
            <h2 className="text-2xl font-bold text-primary-navy mb-4">Ideal For</h2>
            <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
              {service.idealFor.map((item, index) => (
                <div key={index} className="flex items-start gap-3">
                  <div className="h-6 w-6 rounded-full bg-primary-navy text-white flex items-center justify-center flex-shrink-0 mt-1">
                    <svg className="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
                    </svg>
                  </div>
                  <span className="text-lg text-text">{item}</span>
                </div>
              ))}
            </div>
          </section>
        </div>

        {/* Right Column - Sidebar */}
        <div className="lg:col-span-1">
          <Card className="sticky top-24">
            <CardHeader>
              <CardTitle className="text-primary-navy">Quick Info</CardTitle>
            </CardHeader>
            <CardContent className="space-y-4">
              <div>
                <h4 className="font-semibold text-text mb-2">Service</h4>
                <p className="text-soft-text">{service.name}</p>
              </div>
              <div>
                <h4 className="font-semibold text-text mb-2">Category</h4>
                <p className="text-soft-text capitalize">{service.id.replace('-', ' ')}</p>
              </div>
              <div className="pt-4 border-t border-border">
                <a href="/contact" className="block w-full bg-primary-navy text-white px-4 py-3 rounded-md text-center font-medium hover:bg-primary-navy-dark transition-colors">
                  Request This Service
                </a>
              </div>
              <div className="pt-2">
                <a href="/services" className="text-primary-navy hover:underline">
                  ← Back to Services
                </a>
              </div>
            </CardContent>
          </Card>
        </div>
      </div>
    </div>
  )
}

export default ServiceDetail
