'use client';

export const dynamic = 'force-dynamic';

import { useState } from 'react';
import Link from 'next/link';
import { Users, Car, Flower2, Utensils, Shield, Sparkles, ChevronRight, Maximize } from 'lucide-react';
import AnimatedSection from '@/components/ui/AnimatedSection';
import GoldDivider from '@/components/ui/GoldDivider';
import Lightbox from '@/components/ui/Lightbox';
import InquiryForm from '@/components/InquiryForm';
import { lounge } from '@/data/venues';

const lawnFeatures = [
  { icon: Users, title: '800–1,500 Guests', desc: 'Flexible capacity for intimate gatherings to large-scale events' },
  { icon: Car, title: 'Parking for ~3,000', desc: 'Ample shared parking for high-footfall events' },
  { icon: Flower2, title: 'Versatile Layout', desc: 'Open canvas for marquee setups, stage arrangements, and custom configurations' },
  { icon: Utensils, title: 'Waitering Service', desc: 'Trained waitering staff for smooth guest service throughout the event' },
  { icon: Sparkles, title: 'Décor Coordination', desc: 'Styling support including lighting, floral arrangements, and stage setup' },
  { icon: Shield, title: 'On-Ground Support', desc: 'Professional team managing event-day operations from setup to conclusion' },
];

const eventTypes = [
  'Weddings & Receptions',
  'Outdoor Mehndi & Baraat',
  'Corporate Events',
  'Brand Activations',
  'Concerts & Performances',
  'Pop-Up Markets & Festivals',
  'Public Gatherings',
  'Institutional Events',
];

const galleryImages = lounge.gallery;

export default function OpenAirLawn() {
  const [lightboxOpen, setLightboxOpen] = useState(false);
  const [lightboxIdx, setLightboxIdx] = useState(0);

  const openLightbox = (i) => { setLightboxIdx(i); setLightboxOpen(true); };
  const closeLightbox = () => setLightboxOpen(false);
  const prevImg = () => setLightboxIdx((p) => (p - 1 + galleryImages.length) % galleryImages.length);
  const nextImg = () => setLightboxIdx((p) => (p + 1) % galleryImages.length);

  return (
    <div style={{ background: 'var(--bg-main)' }}>
      {/* Hero */}
      <section
        className="relative flex items-center justify-center"
        style={{
          minHeight: '100vh',
          backgroundImage: `url(${lounge.image})`,
          backgroundSize: 'cover',
          backgroundPosition: 'center',
        }}
      >
        <div className="absolute inset-0 hero-overlay" />
        <div className="relative z-10 text-center max-w-4xl mx-auto px-6 pt-44">
          <AnimatedSection delay={200}>
            <p className="section-label mb-6">Outdoor Event Venue — DHA, Karachi</p>
          </AnimatedSection>
          <AnimatedSection delay={400}>
            <h1
              className="font-display text-light font-bold mb-6"
              style={{ fontSize: 'clamp(3rem, 8vw, 6rem)', lineHeight: 1.05 }}
            >
              The <span className="text-gold-shimmer">Open-Air</span>
              <br />Lawn
            </h1>
          </AnimatedSection>
          <AnimatedSection delay={600}>
            <GoldDivider className="mx-auto mb-6" />
            <p className="text-whisper text-xl leading-relaxed mb-10 max-w-2xl mx-auto">
              {lounge.tagline}
            </p>
          </AnimatedSection>
          <AnimatedSection delay={800} className="flex flex-wrap gap-4 justify-center">
            <a href="#events" className="btn-gold px-10 py-4">
              <span>Explore Events</span>
            </a>
            <Link href="/contact" className="btn-outline-gold px-10 py-4">
              Book the Lawn
            </Link>
          </AnimatedSection>
        </div>
      </section>

      {/* Overview */}
      <section className="py-32 max-w-7xl mx-auto px-6">
        <div className="grid grid-cols-1 lg:grid-cols-2 gap-20 items-center">
          <AnimatedSection>
            <div className="relative">
              <img
                src="https://images.unsplash.com/photo-1469371670807-013ccf25f16a?w=800&q=80"
                alt="Open-Air Lawn"
                className="w-full object-cover"
                style={{ height: '600px' }}
              />
              <div
                className="absolute -bottom-6 -right-6 glass-card p-8"
                style={{ width: '200px' }}
              >
                <div className="text-gold font-display font-bold text-4xl mb-1">1,500</div>
                <div className="text-whisper text-xs tracking-widest uppercase">Max Guests</div>
                <div className="gold-divider my-3" />
                <div className="text-light text-xs">Expansive outdoor lawn</div>
              </div>
            </div>
          </AnimatedSection>

          <AnimatedSection delay={200}>
            <p className="section-label mb-4">The Lawn Experience</p>
            <h2
              className="font-display text-light font-bold mb-6"
              style={{ fontSize: 'clamp(2.5rem, 4vw, 3.5rem)', lineHeight: 1.15 }}
            >
              Open Space,{' '}
              <span className="text-gold-gradient">Endless Possibilities</span>
            </h2>
            <GoldDivider className="mb-8" />
            <p className="text-whisper leading-relaxed mb-6">{lounge.description}</p>
            <div className="flex items-center gap-4 mt-8">
              <Maximize size={16} className="text-gold flex-shrink-0" />
              <span className="text-light text-sm">Flexible layout — marquee, stage, open seating, or custom configuration</span>
            </div>
          </AnimatedSection>
        </div>
      </section>

      {/* Features */}
      <section className="py-32" style={{ background: 'var(--bg-foundation)' }}>
        <div className="max-w-7xl mx-auto px-6">
          <AnimatedSection className="text-center mb-20">
            <p className="section-label mb-4">Venue Capabilities</p>
            <h2
              className="font-display text-light font-bold"
              style={{ fontSize: 'clamp(2.5rem, 4vw, 3.5rem)' }}
            >
              What the Lawn <span className="text-gold-gradient">Offers</span>
            </h2>
          </AnimatedSection>

          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            {lawnFeatures.map(({ icon: Icon, title, desc }, i) => (
              <AnimatedSection key={i} delay={i * 80}>
                <div className="glass-card p-8 h-full hover:border-gold/50 transition-all duration-500">
                  <div
                    className="w-12 h-12 flex items-center justify-center mb-6"
                    style={{ border: '1px solid rgba(212,175,55,0.4)' }}
                  >
                    <Icon size={20} className="text-gold" />
                  </div>
                  <h3 className="font-display text-light font-semibold text-xl mb-3">{title}</h3>
                  <p className="text-whisper text-sm leading-relaxed">{desc}</p>
                </div>
              </AnimatedSection>
            ))}
          </div>
        </div>
      </section>

      {/* Gallery */}
      <section className="py-32 max-w-7xl mx-auto px-6">
        <AnimatedSection className="mb-16">
          <p className="section-label mb-4">Gallery</p>
          <h2
            className="font-display text-light font-bold"
            style={{ fontSize: 'clamp(2.5rem, 4vw, 3.5rem)' }}
          >
            The Lawn <span className="text-gold-gradient">Unveiled</span>
          </h2>
        </AnimatedSection>

        <div className="grid grid-cols-2 lg:grid-cols-4 gap-3">
          {galleryImages.map((src, i) => (
            <div
              key={i}
              className={`img-zoom-container relative overflow-hidden cursor-pointer group ${i === 0 ? 'lg:col-span-2 lg:row-span-2' : ''}`}
              style={{ height: i === 0 ? '420px' : '200px' }}
              onClick={() => openLightbox(i)}
              data-cursor="view"
            >
              <img src={src} alt="" className="w-full h-full object-cover img-bg" />
              <div className="absolute inset-0 opacity-0 group-hover:opacity-100 transition-opacity duration-500 flex items-center justify-center"
                style={{ background: 'rgba(212,175,55,0.15)' }}>
                <span className="section-label border border-gold/60 px-4 py-2" style={{ background: 'rgba(10,10,10,0.55)', backdropFilter: 'blur(4px)' }}>View</span>
              </div>
            </div>
          ))}
        </div>
      </section>

      {/* Event Types */}
      <section
        id="events"
        className="py-32"
        style={{ background: 'linear-gradient(135deg, var(--bg-main) 0%, var(--bg-foundation) 50%, var(--bg-main) 100%)' }}
      >
        <div className="relative z-10 max-w-7xl mx-auto px-6">
          <div className="grid grid-cols-1 lg:grid-cols-2 gap-20">
            <AnimatedSection>
              <p className="section-label mb-4">Suitable For</p>
              <h2
                className="font-display text-light font-bold mb-6"
                style={{ fontSize: 'clamp(2.5rem, 4vw, 3.5rem)' }}
              >
                Events We <span className="text-gold-gradient">Host</span>
              </h2>
              <GoldDivider className="mb-8" />
              <p className="text-whisper leading-relaxed mb-10">
                The Open-Air Lawn is a versatile outdoor space designed to accommodate a wide range of events — from grand weddings and corporate functions to concerts, brand activations, and public gatherings.
              </p>
              <Link href="/contact" className="btn-gold px-10 py-4">
                <span>Plan Your Event</span>
              </Link>
            </AnimatedSection>

            <AnimatedSection delay={200}>
              <div className="space-y-4">
                {eventTypes.map((type, i) => (
                  <div key={i} className="flex items-center gap-4 pb-4"
                    style={{ borderBottom: '1px solid rgba(212,175,55,0.1)' }}>
                    <div className="w-5 h-5 border border-gold flex items-center justify-center flex-shrink-0">
                      <ChevronRight size={10} className="text-gold" />
                    </div>
                    <span className="text-light text-sm">{type}</span>
                  </div>
                ))}
              </div>
            </AnimatedSection>
          </div>
        </div>
      </section>

      {/* Inquiry */}
      <section className="py-32 max-w-7xl mx-auto px-6">
        <AnimatedSection className="text-center mb-16">
          <p className="section-label mb-4">Get In Touch</p>
          <h2
            className="font-display text-light font-bold"
            style={{ fontSize: 'clamp(2.5rem, 4vw, 3.5rem)' }}
          >
            Book the <span className="text-gold-gradient">Lawn</span>
          </h2>
          <GoldDivider className="mx-auto mt-6" />
        </AnimatedSection>
        <InquiryForm venueName="Open-Air Lawn" />
      </section>

      {lightboxOpen && (
        <Lightbox
          images={galleryImages}
          currentIndex={lightboxIdx}
          onClose={closeLightbox}
          onPrev={prevImg}
          onNext={nextImg}
        />
      )}
    </div>
  );
}
