'use client'

import React from 'react'
import { Order } from '@/lib/types/order'
import { Country } from '@/lib/types/country'
import { Clock, Star } from 'lucide-react'

import { Card, CardContent } from '@/components/shadcn/ui/card'
import ReviewForm from '@/components/form/ReviewForm'
import { ActivityProduct } from '@/lib/types/activity'
import Image from 'next/image'

interface ActivityReviewProps {
  order: Order
  activityProduct: ActivityProduct
  countries?: Country[]
}

const ActivityReview: React.FC<ActivityReviewProps> = ({
  order,
  activityProduct,
  countries = [],
}) => {
  return (
    <div className="flex flex-col items-center w-full max-w-3xl mx-auto p-4 md:p-6">
      {/* Activity Info Summary */}
      <div className="mb-4 mt-8 text-center">
        <h1 className="text-2xl sm:text-3xl md:text-4xl font-semibold mb-2 bg-gradient-to-r from-blue-600 to-teal-500 text-transparent bg-clip-text">
          Share Your Experience
        </h1>
        <p className="text-slate-500 mb-6">
          Your honest feedback helps others make better travel decisions
        </p>
      </div>

      <Card className="w-full mb-8 border-none shadow-lg overflow-hidden">
        <div className="bg-gradient-to-r from-blue-500 to-teal-400 h-2" />
        <CardContent className="p-0">
          <div className="flex flex-col md:flex-row px-4">
            {/* Activity Image */}
            <div className="w-full md:w-2/5 h-48 relative overflow-hidden">
              {activityProduct.featured_image ? (
                <Image
                  src={activityProduct.featured_image?.image}
                  alt={activityProduct.name}
                  className="w-full h-full object-cover"
                  fill
                />
              ) : (
                <div className="w-full h-full bg-gray-200 flex items-center justify-center">
                  <span className="text-slate-500">No image available</span>
                </div>
              )}
              {activityProduct.badge && (
                <div className="absolute top-2 left-2 bg-blue-600 text-white px-3 py-1 rounded-full text-xs font-medium">
                  {activityProduct.badge.name}
                </div>
              )}
            </div>

            {/* Activity Details */}
            <div className="w-full md:w-5/5 p-5">
              <div className="flex font-medium items-center gap-1 text-sm text-slate-500">
                <Star className="h-4 w-4 fill-current text-yellow-400" />
                <span>{activityProduct.rating}</span>
              </div>

              <h3 className="text-xl font-semibold mb-2">
                {activityProduct.name}
              </h3>

              <div className="flex items-center text-slate-500 mb-3">
                <Clock className="w-4 h-4 mr-2" />
                <span className="text-sm">
                  Duration: {activityProduct.activity_duration_text}{' '}
                  {activityProduct.activity_duration_unit}
                </span>
              </div>

              {/* Features List */}
              <div className="flex flex-wrap gap-2 mt-3">
                {activityProduct.features?.slice(0, 3).map((feature, index) => (
                  <span
                    key={index}
                    className="bg-gray-100 text-blue-800 text-xs px-2 py-1 rounded-md"
                  >
                    {feature.name}
                  </span>
                ))}
              </div>
            </div>
          </div>
        </CardContent>
      </Card>

      <ReviewForm
        order={order}
        countries={countries}
        productCategory="activity"
        productId={activityProduct.id}
      />
    </div>
  )
}

export default ActivityReview
