"use client";

import { useState, useEffect } from 'react';
import styles from './HeroSection.module.css';

const slides = [
  {
    image: '/images/hero-dosa.png',
    title: 'The Comfort of Home',
    highlight: 'Pure Vegetarian Flavours',
    subtitle: 'Welcome to My Dosa Place. We bring you the authentic, soul-warming tastes of traditional South Indian kitchens. Every dish is crafted with passion and nostalgia.',
    primaryBtn: 'Explore Menu 🍽️',
    secondaryBtn: 'Book a Table',
  },
  {
    image: '/images/south-indian-thali.jpeg',
    title: 'Experience the Royal',
    highlight: 'South Indian Thali',
    subtitle: 'A magnificent traditional feast of authentic curries, rice, and desserts served exclusively on weekends. A true celebration of Southern culinary diversity.',
    primaryBtn: 'View Weekend Specials',
    secondaryBtn: 'Reserve Now',
  },
  {
    image: '/images/crispy-masala.png',
    title: 'Crispy, Golden &',
    highlight: 'Perfectly Spiced',
    subtitle: 'Taste our signature dosas (savory fermented crepes), stone-ground and made fresh every day with heritage batter and our secret spice blends.',
    primaryBtn: 'Order Online',
    secondaryBtn: 'Our Story',
  }
];

export default function HeroSection() {
  const [currentSlide, setCurrentSlide] = useState(0);

  useEffect(() => {
    const timer = setInterval(() => {
      setCurrentSlide((prev) => (prev + 1) % slides.length);
    }, 5000); // Change slide every 5 seconds
    return () => clearInterval(timer);
  }, []);

  return (
    <section className={styles.hero}>
      {slides.map((slide, index) => (
        <div
          key={index}
          className={`${styles.slideBg} ${index === currentSlide ? styles.activeBg : ''}`}
          style={{ backgroundImage: `url(${slide.image})` }}
        />
      ))}
      <div className={styles.heroOverlay}></div>
      <div className={styles.heroContent}>
        {slides.map((slide, index) => (
          <div
            key={index}
            className={`${styles.textContent} ${index === currentSlide ? styles.activeText : ''}`}
          >
            <h1 className={styles.heroTitle}>
              {slide.title}<br />
              <span className={styles.highlight}>{slide.highlight}</span> in Waterloo
            </h1>
            <p className={styles.heroSubtitle}>
              {slide.subtitle}
            </p>
            <div className={styles.heroActions}>
              <a href="/menu" className={styles.btnPrimary}>
                {slide.primaryBtn}
              </a>
              <a href="/contact" className={styles.btnSecondary}>
                {slide.secondaryBtn}
              </a>
            </div>
          </div>
        ))}
        {/* <div className={styles.heroMeta}>
          <div className={styles.metaItem}>
            <span className={styles.metaIcon}>⭐</span>
            <span>Quality Food</span>
          </div>
          <div className={styles.metaDivider}></div>
          <div className={styles.metaItem}>
            <span className={styles.metaIcon}>🍃</span>
            <span>100% Vegetarian</span>
          </div>
          <div className={styles.metaDivider}></div>
          <div className={styles.metaItem}>
            <span className={styles.metaIcon}>🕐</span>
            <span>Open 7 Days</span>
          </div>
        </div> */}
        
        {/* Slide Indicators */}
        <div className={styles.indicators}>
          {slides.map((_, index) => (
            <button
              key={index}
              className={`${styles.indicator} ${index === currentSlide ? styles.activeIndicator : ''}`}
              onClick={() => setCurrentSlide(index)}
              aria-label={`Go to slide ${index + 1}`}
            />
          ))}
        </div>
      </div>
    </section>
  );
}
