'use client'

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

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

interface BoatReviewProps {
  order: Order
  fastboatProduct: FastboatProduct
  countries?: Country[]
}

const BoatReview: React.FC<BoatReviewProps> = ({
  order,
  fastboatProduct,
  countries = [],
}) => {
  return (
    <div className="flex flex-col items-center w-full max-w-3xl mx-auto p-4 md:p-6">
      {/* Header with visual elements */}
      <div className="text-center mb-4 mt-8 relative">
        <div className="absolute left-0 top-1/2 -translate-y-1/2 opacity-10 -z-10">
          <Ship className="w-16 h-16 text-blue-500" />
        </div>
        <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 max-w-lg mx-auto">
          Your feedback helps others make better choices and helps us improve
          our service.
        </p>
        <div className="absolute right-0 top-1/2 -translate-y-1/2 opacity-10 -z-10">
          <Ship className="w-16 h-16 text-blue-500" />
        </div>
      </div>

      {/* Product Details Card - More visually appealing */}
      <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">
            {/* Product Image */}
            <div className="w-full md:w-2/5 relative h-64 md:h-auto overflow-hidden">
              {fastboatProduct.product_image ? (
                <Image
                  src={fastboatProduct.product_image?.image}
                  alt={fastboatProduct.boat_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-gray-400">No image available</span>
                </div>
              )}
            </div>

            {/* Product Info */}
            <div className="md:w-3/5 p-6 flex flex-col justify-center">
              <div className="flex font-medium items-center gap-1 text-sm text-gray-600">
                <Star className="h-4 w-4 fill-current text-yellow-400" />
                <span>{fastboatProduct.rating}</span>
              </div>

              <h2 className="text-2xl font-medium mb-2">
                {fastboatProduct.boat_name}
              </h2>

              <div className="space-y-3">
                <div className="flex items-center">
                  <span className="w-24 text-sm font-medium">Route</span>
                  <span className="text-sm flex-1 space-x-2 space-y-2">
                    <span className="inline-block px-2 py-1 bg-blue-50 text-blue-700 rounded-md">
                      {fastboatProduct.route.departure_harbor}
                    </span>
                    <span className="mx-2">→</span>
                    <span className="inline-block px-2 py-1 bg-teal-50 text-teal-700 rounded-md">
                      {fastboatProduct.route.arrival_harbor}
                    </span>
                  </span>
                </div>

                <div className="flex items-center">
                  <span className="w-24 text-sm font-medium">Order #</span>
                  <span className="text-sm font-mono bg-gray-100 px-2 py-1 rounded">
                    {order?.invoice_number || '-'}
                  </span>
                </div>
              </div>
            </div>
          </div>
        </CardContent>
      </Card>

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

export default BoatReview
