'use client';

import Image from 'next/image';
import { useTranslations } from 'next-intl';
import RequestQuoteForm from '@/components/RequestQuoteForm';
import DatasheetDownload from '@/components/DatasheetDownload';
import Scribble from '@/components/Scribble';
import { cn } from '@/components/ui/utils';

interface ProductSidebarProps {
  productName: string;
  productImage?: string;
  datasheetPath?: string | null;
  className?: string;
}

export default function ProductSidebar({
  productName,
  productImage,
  datasheetPath,
  className,
}: ProductSidebarProps) {
  const t = useTranslations('Products');

  return (
    <aside className={cn('flex flex-col gap-4 animate-slight-fade-in-from-bottom', className)}>
      {/* Request Quote Form Card */}
      <div className="bg-white rounded-3xl border border-neutral-medium shadow-sm transition-all duration-500 hover:shadow-2xl hover:-translate-y-1 overflow-hidden group/card">
        <div className="bg-primary p-6 text-white relative overflow-hidden">
          {/* Background Accent - Saturated Blue Glow */}
          <div className="absolute top-0 right-0 w-40 h-40 bg-saturated/30 rounded-full -translate-y-1/2 translate-x-1/2 blur-[80px] pointer-events-none" />

          {/* Product Thumbnail with Reflection */}
          {productImage && (
            <div className="relative w-full aspect-[16/10] mb-6 rounded-2xl overflow-hidden bg-white/5 backdrop-blur-md p-4 border border-white/10 z-10 group">
              <div className="relative w-full h-full transition-transform duration-1000 ease-out group-hover:scale-105">
                <Image
                  src={productImage.split('?')[0]}
                  alt={productName}
                  fill
                  className="object-contain p-2 drop-shadow-[0_20px_30px_rgba(0,0,0,0.4)]"
                />
                {/* Subtle Reflection Overlay */}
                <div className="absolute inset-0 bg-gradient-to-tr from-white/20 via-transparent to-transparent opacity-30 pointer-events-none" />
              </div>
            </div>
          )}

          <div className="relative z-10">
            <div className="inline-block relative mb-2">
              <h3 className="text-lg md:text-xl font-heading font-black m-0 tracking-tighter uppercase leading-none">
                {t('requestQuote')}
              </h3>
              <Scribble
                variant="underline"
                className="w-full h-3 -bottom-3 left-0 text-accent/80"
                color="var(--color-accent)"
              />
            </div>
            <p className="text-white/60 text-xs md:text-sm m-0 mt-2 leading-relaxed font-medium max-w-[90%]">
              {t('requestQuoteDesc')}
            </p>
          </div>
        </div>

        <div className="p-6 bg-neutral-light/50">
          <RequestQuoteForm productName={productName} />
        </div>
      </div>

      {/* Datasheet Download */}
      {datasheetPath && <DatasheetDownload datasheetPath={datasheetPath} className="mt-0" />}
    </aside>
  );
}
