'use client';

import Image from 'next/image';
import Link from 'next/link';

interface FeaturedCollectionProps {
  title: string;
  description: string;
  image: string;
  imageAlt?: string;
  ctaText?: string;
  ctaLink?: string;
  imagePosition?: 'left' | 'right';
}

export default function FeaturedCollection({
  title,
  description,
  image,
  imageAlt,
  ctaText = 'SHOP NOW',
  ctaLink = '/',
  imagePosition = 'left',
}: FeaturedCollectionProps) {
  const isImageLeft = imagePosition === 'left';

  return (
    <section className="bg-white py-0">
      <div className="">
        {/* Mobile: Text overlaid on image */}
        <div className="relative block md:hidden px-4">
          <div className="relative h-[700px] overflow-hidden">
            <Image
              src={image}
              alt={imageAlt || title}
              fill
              className="object-cover"
              sizes="100vw"
              loading="lazy"
              quality={90}
            />
            {/* Text overlay at bottom */}
            <div className="absolute bottom-0 left-0 right-0 m-2 md:m-0 bg-white px-6 py-8">
              <h2 className="text-xl font-serif text-gray-900 uppercase tracking-wide mb-4">
                {title}
              </h2>
              <p className="text-sm text-gray-700 leading-relaxed mb-6">
                {description}
              </p>
              {ctaLink && (
                <Link
                  href={ctaLink}
                  className="inline-block w-full text-center bg-black text-white px-8 py-3 text-sm font-semibold uppercase tracking-wide hover:bg-gray-800 transition-colors"
                >
                  {ctaText}
                </Link>
              )}
            </div>
          </div>
        </div>

        {/* Desktop: Side-by-side layout */}
        <div className={`hidden md:grid md:grid-cols-2 gap-8 lg:gap-10 items-center ${
          isImageLeft ? '' : 'md:flex-row-reverse'
        }`}>
          {/* Image Section */}
          <div className={`relative h-[600px] lg:h-[700px] overflow-hidden col-span-1 ${
            isImageLeft ? 'order-1' : 'order-2'
          }`}>
            <Link href={"/ramz-luxury-formals"}>
            <Image
              src={image}
              alt={imageAlt || title}
              fill
              className="object-cover"
              sizes="70vw"
              loading="lazy"
              quality={90}
            />
            </Link>
          </div>

          {/* Text Content Section */}
          <div className={`flex flex-col justify-center space-y-6 ${
            isImageLeft ? 'order-2' : 'order-1'
          }`}>
            <h2 className="text-3xl md:text-4xl lg:text-5xl font-serif text-gray-900 uppercase tracking-wide">
              {title}
            </h2>
            <p className="text-base md:text-lg text-gray-700 leading-relaxed max-w-lg">
              {description}
            </p>
            {ctaLink && (
              <Link
                href={ctaLink}
                className="inline-block w-fit bg-black text-white px-8 py-3 text-sm font-semibold uppercase tracking-wide hover:bg-gray-800 transition-colors"
              >
                {ctaText}
              </Link>
            )}
          </div>
        </div>
      </div>
    </section>
  );
}

