"use client";

import { X, Maximize2 } from "lucide-react";
import * as React from "react";
import { motion, AnimatePresence } from "framer-motion";

interface GalleryItem {
  id: string;
  image: string;
  prompt: string;
  category: string;
}

const galleryItems: GalleryItem[] = [
  {
    id: "1",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1759050858509.png",
    prompt:
      "Create an advertisement for this container. Highlight its smooth taste and rich heritage, capturing its essence against a dramatic background of rocky textures. Emphasize quality craftsmanship and the iconic label design.",
    category: "Commercial",
  },
  {
    id: "2",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1759056864060.png",
    prompt:
      "I need luxurious design & premium look poster for this product Creating a luxurious and premium look for your poster can be achieved by focusing on design elements, color schemes, and typography. Here's a guide to help you:Color Palette- Deep Reds and Metallics: Use shades like burgundy or wine paired with gold or silver accents to convey luxury.- Neutral Background: A soft cream or light beige can enhance the elegant appeal.Typography- Elegant Fonts: Opt for serif fonts for the product name (“Glycool”) to give a classic look. Use a modern sans-serif for supporting text to maintain clarity.- Hierarchy: Make the product name prominent. Secondary information should be smaller but legible.Layout Ideas- Center the Product: Place the bottle at the center of the poster. Consider an angled view for added depth.- Text Placement: Position the product name directly below or above the bottle. Include a brief tagline or benefits in a smaller font.- Highlight Key Ingredients: Use icons or small graphics for “Glycolic Acid” and “Peppermint Oil” to draw attention.Visual Elements- Textures: Incorporate subtle textures in the background (like silk or marble) to add richness.- Shadows and Highlights: Use soft shadows around the bottle for a three-dimensional effect.Call-to-Action- Incorporate a Stylish CTA: Phrases like Experience The Luxury or Elevate Your Care Routine in an elegant script can encourage action",
    category: "Product Ad",
  },
  {
    id: "3",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1759049845391.png",
    prompt:
      "Capture the essence of a joyful cooking moment in a modern kitchen. In the foreground, a woman is skillfully chopping a vibrant red bell pepper on a wooden cutting board, wearing a pink print saree. To the side, there’s a colorful assortment of fresh vegetables in a bowl, and a sleek countertop with a stylish kitchen appliance this product prominently displayed. The backdrop features a warm, inviting atmosphere with soft lighting and a tastefully designed kitchen. Emphasize the harmony of cooking and the role of your product in enhancing the culinary experience.",
    category: "Product Ad",
  },
  {
    id: "4",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1759049616791.png",
    prompt:
      "Imagine a striking bottle of these containers, elegantly showcased against a backdrop of shimmering black and gold. The containers, with its smooth curves and a polished finish, captures the eye, reflecting the soft glow of surrounding lights. The label stands out prominently, boasting the special edition designation and an inviting name: Flavia Infused with the rich essence of these container, it hints at the unique flavor profile waiting within. Above the containers, tiny golden stars and confetti rain down, creating an atmosphere of celebration and festivity. Below, a layer of sparkling gold adds a touch of extravagance, inviting onlookers to envision the perfect occasion for this delightful spirit. This image captures not just a containers, but the essence of indulgence and joy, evoking a sensory experience of warmth, flavor, and the magic of special moments shared over a glass. The image will be landscape and high quality.",
    category: "Product Commercial",
  },
  {
    id: "5",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1758985411195.png",
    prompt:
      "Create an elegant mockup for a wedding invitation card featuring a white background adorned with vibrant, hand-painted floral elements such as zinnias and lavender. The invitation text should be prominently displayed in an artistic, romantic font, with two intertwined red hearts framing the names 'Alex' and 'Jasi'. For the background, use a soft pastel gradient blending hues of lavender, mint green, and soft peach to create a dreamy ambiance. Incorporate subtle decorative elements like delicate lace or a light bokeh effect for added elegance. Ensure the overall composition is eye-catching and invites viewers to envision this invitation for their own special day, enhancing its clickbait appeal.",
    category: "Card",
  },
  {
    id: "6",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1758978282321.png",
    prompt:
      "I want a background that used pink and light yellow. Also product showing on dressing table",
    category: "Product Background",
  },
  {
    id: "7",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1758912444519.png",
    prompt:
      "Remove the existing background from the image of the combo product consisting of a jar of orange paste, a coconut, and a bowl of white flour. Replace it with a vibrant and inviting kitchen backdrop that enhances the freshness and appeal of the ingredients. The new background should feature soft, warm colors with subtle kitchen elements like herbs, utensils, and a wooden countertop to create a cozy and homely atmosphere. ",
    category: "Product Background",
  },
  {
    id: "8",
    image:
      "https://supabase-db.planpostai.com/storage/v1/object/public/image-gen/generated_1758570239324.png",
    prompt:
      "A Bangladeshi woman aged 25 to 30 wearing a traditional salwar kameez. The kameez (top) must look exactly like the first reference image: soft grey color with white floral printed patterns, long sleeves with lace on the edges, and detailed turquoise-blue and golden embroidery around the neckline. The pajama (bottom) design must follow the second reference image: loose fit with elastic on the waist and ankles, same printed floral pattern style as shown. But the pajama color must match the soft grey color of the kameez (first image) instead of red. The full outfit should look graceful, elegant, and culturally authentic. The model should have natural light makeup, small earrings, and simple hairstyle (either open or softly tied). Background should be softly lit—indoor or natural daylight outdoor—so that the outfit's design and colors are clearly visible for fashion promotion.",
    category: "Clothing",
  },
];

export default function GallerySection() {
  const [selectedImage, setSelectedImage] = React.useState<GalleryItem | null>(
    null
  );

  return (
    <div className="py-16 px-4 md:px-6 lg:px-8 bg-[#f5f1ff]">
      <div className="max-w-7xl mx-auto">
        <div className="text-center mb-12">
          <h2 className="text-3xl md:text-4xl font-bold mb-4">
            Clients <span className="text-[#7c3aed]">Generation</span>
          </h2>
          <p className="text-gray-600 text-lg max-w-2xl mx-auto">
            Explore stunning images created with our AI image generation tool.
            Our user just created from their normal product image to
            advertisement, see whats possible.
          </p>
        </div>

        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
          {galleryItems.map((item, index) => (
            <motion.div
              key={item.id}
              initial={{ opacity: 0, y: 20 }}
              whileInView={{ opacity: 1, y: 0 }}
              viewport={{ once: true }}
              transition={{ duration: 0.4, delay: index * 0.1 }}
              className="group relative aspect-square rounded-lg overflow-hidden bg-white cursor-pointer"
              onClick={() => setSelectedImage(item)}
            >
              <img
                src={item.image}
                alt={item.prompt}
                className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"
              />

              <div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300">
                <div className="absolute bottom-0 left-0 right-0 p-4">
                  <span className="inline-block px-3 py-1 bg-[#7c3aed] text-white text-xs rounded-full mb-2">
                    {item.category}
                  </span>
                  <p className="text-white text-sm line-clamp-2">
                    {item.prompt}
                  </p>
                </div>
                <div className="absolute top-4 right-4">
                  <Maximize2 className="w-5 h-5 text-white" />
                </div>
              </div>
            </motion.div>
          ))}
        </div>

        <AnimatePresence>
          {selectedImage && (
            <motion.div
              initial={{ opacity: 0 }}
              animate={{ opacity: 1 }}
              exit={{ opacity: 0 }}
              className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/90"
              onClick={() => setSelectedImage(null)}
            >
              <motion.button
                initial={{ opacity: 0, scale: 0.8 }}
                animate={{ opacity: 1, scale: 1 }}
                exit={{ opacity: 0, scale: 0.8 }}
                className="absolute top-4 right-4 w-10 h-10 rounded-full bg-white/10 backdrop-blur-sm hover:bg-white/20 flex items-center justify-center transition-colors z-10"
                onClick={() => setSelectedImage(null)}
              >
                <X className="w-6 h-6 text-white" />
              </motion.button>

              <motion.div
                initial={{ opacity: 0, scale: 0.9, y: 20 }}
                animate={{ opacity: 1, scale: 1, y: 0 }}
                exit={{ opacity: 0, scale: 0.9, y: 20 }}
                transition={{ type: "spring", damping: 25, stiffness: 300 }}
                className="relative max-w-6xl w-full max-h-[90vh] bg-white rounded-lg overflow-hidden"
                onClick={(e) => e.stopPropagation()}
              >
                <div className="relative aspect-video w-full bg-gray-100">
                  <img
                    src={selectedImage.image}
                    alt={selectedImage.prompt}
                    className="w-full h-full object-contain"
                  />
                </div>

                <div className="p-6 bg-white">
                  <div className="flex items-center gap-2 mb-3">
                    <span className="px-3 py-1 bg-[#7c3aed] text-white text-sm rounded-full">
                      {selectedImage.category}
                    </span>
                  </div>
                  <div className="bg-[#f5f1ff] rounded-lg p-4">
                    <h3 className="text-sm font-semibold text-[#7c3aed] mb-2">
                      Prompt Used:
                    </h3>
                    <p className="text-gray-700 text-sm leading-relaxed">
                      {selectedImage.prompt}
                    </p>
                  </div>
                </div>
              </motion.div>
            </motion.div>
          )}
        </AnimatePresence>
      </div>
    </div>
  );
}
