const { useState, useEffect, useRef } = React;

// Smoke Effect Component
const SmokeEffect = () => {
    const [particles, setParticles] = useState([]);
    
    useEffect(() => {
        console.log('Smoke effect initialized');
        // Create initial particles
        const initialParticles = Array.from({ length: 20 }, (_, i) => ({
            id: i,
            x: Math.random() * window.innerWidth,
            y: window.innerHeight + 50,
            size: Math.random() * 40 + 30,
            opacity: Math.random() * 0.6 + 0.2,
            speed: Math.random() * 3 + 1,
            drift: (Math.random() - 0.5) * 3
        }));
        setParticles(initialParticles);

        // Animation loop
        const animateParticles = () => {
            setParticles(prevParticles => 
                prevParticles.map(particle => {
                    let newY = particle.y - particle.speed;
                    let newX = particle.x + particle.drift;
                    let newOpacity = particle.opacity;

                    // Reset particle when it goes off screen
                    if (newY < -100) {
                        newY = window.innerHeight + 50;
                        newX = Math.random() * window.innerWidth;
                        newOpacity = Math.random() * 0.6 + 0.2;
                    }

                    // Fade out as it rises
                    if (newY < window.innerHeight * 0.6) {
                        newOpacity = newOpacity * 0.992;
                    }

                    return {
                        ...particle,
                        x: newX,
                        y: newY,
                        opacity: Math.max(0, newOpacity)
                    };
                })
            );
        };

        const interval = setInterval(animateParticles, 50);
        return () => clearInterval(interval);
    }, []);

    return (
        <div style={{
            position: 'fixed',
            top: 0,
            left: 0,
            width: '100%',
            height: '100%',
            pointerEvents: 'none',
            zIndex: 10,
            overflow: 'hidden'
        }}>
            {particles.map(particle => (
                <div
                    key={particle.id}
                    style={{
                        position: 'absolute',
                        left: `${particle.x}px`,
                        top: `${particle.y}px`,
                        width: `${particle.size}px`,
                        height: `${particle.size}px`,
                        background: `radial-gradient(circle, rgba(255,255,255,${particle.opacity * 0.8}) 0%, rgba(200,200,200,${particle.opacity * 0.6}) 30%, rgba(150,150,150,${particle.opacity * 0.3}) 60%, transparent 100%)`,
                        borderRadius: '50%',
                        filter: 'blur(12px)',
                        transform: 'scale(1)',
                        transition: 'opacity 0.1s ease-out'
                    }}
                />
            ))}
        </div>
    );
};

// Mock Framer Motion
const motion = new Proxy({}, {
    get: (target, prop) => {
        return ({ children, initial, animate, transition, whileHover, whileInView, viewport, ...props }) => {
            return React.createElement(prop, props, children);
        };
    }
});

const useInView = (ref, options) => true;

// Shared Navigation Component
const Navigation = () => {
    console.log('Navigation component loaded - should show: Menu, Catering, Visit, Jobs, Contact, Order Now');
    const [scrolled, setScrolled] = useState(false);
    const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
    const [isMobile, setIsMobile] = useState(false);

    useEffect(() => {
        const handleScroll = () => setScrolled(window.scrollY > 50);
        const handleResize = () => {
            setIsMobile(window.innerWidth <= 768);
            if (window.innerWidth > 768) setMobileMenuOpen(false);
        };

        handleResize();
        window.addEventListener('scroll', handleScroll);
        window.addEventListener('resize', handleResize);
        return () => {
            window.removeEventListener('scroll', handleScroll);
            window.removeEventListener('resize', handleResize);
        };
    }, []);

    const navLinkStyle = {
        color: 'var(--charcoal)',
        textDecoration: 'none',
        fontSize: '1rem',
        fontWeight: '500',
        transition: 'color 0.2s',
        cursor: 'pointer'
    };

    const buttonStyle = {
        display: 'inline-block',
        padding: '0.875rem 2rem',
        borderRadius: '8px',
        textDecoration: 'none',
        fontWeight: '600',
        fontSize: '1rem',
        transition: 'all 0.3s ease',
        cursor: 'pointer',
        border: 'none',
        letterSpacing: '0.02em'
    };

    return (
        <nav style={{
            position: 'fixed',
            top: 0,
            left: 0,
            right: 0,
            zIndex: 1000,
            padding: isMobile ? '1rem 1.5rem' : '1.5rem 4rem',
            background: scrolled ? 'rgba(245, 241, 232, 0.95)' : 'rgba(26, 26, 26, 0.8)',
            backdropFilter: 'blur(10px)',
            borderBottom: scrolled ? '1px solid rgba(212, 82, 42, 0.1)' : '1px solid rgba(245, 241, 232, 0.1)',
            transition: 'all 0.3s ease'
        }}>
            <div style={{
                maxWidth: '1600px',
                margin: '0 auto',
                display: 'flex',
                justifyContent: 'space-between',
                alignItems: 'center',
                flexDirection: isMobile ? 'column' : 'row'
            }}>
                <div style={{ width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
                    <a href="index.html" style={{
                        fontSize: '1.5rem',
                        fontWeight: '700',
                        color: scrolled ? 'var(--charcoal)' : 'var(--cream)',
                        letterSpacing: '-0.02em',
                        transition: 'color 0.3s ease',
                        textDecoration: 'none'
                    }}>SAUCY'S</a>
                    {isMobile && (
                        <button onClick={() => setMobileMenuOpen(!mobileMenuOpen)} style={{
                            background: 'none',
                            border: 'none',
                            color: scrolled ? 'var(--charcoal)' : 'var(--cream)',
                            fontSize: '1.5rem',
                            cursor: 'pointer',
                            padding: '0.5rem'
                        }}>
                            {mobileMenuOpen ? '✕' : '☰'}
                        </button>
                    )}
                </div>
                <div style={{
                    display: isMobile ? (mobileMenuOpen ? 'flex' : 'none') : 'flex',
                    gap: isMobile ? '1rem' : '3rem',
                    alignItems: 'center',
                    flexDirection: isMobile ? 'column' : 'row',
                    width: isMobile ? '100%' : 'auto',
                    marginTop: isMobile ? '1rem' : '0'
                }}>
                    <a href="menu.html" style={{ ...navLinkStyle, color: scrolled ? 'var(--charcoal)' : 'var(--cream)', width: isMobile ? '100%' : 'auto', textAlign: isMobile ? 'center' : 'left' }}>Menu</a>
                    <a href="catering.html" style={{ ...navLinkStyle, color: scrolled ? 'var(--charcoal)' : 'var(--cream)', width: isMobile ? '100%' : 'auto', textAlign: isMobile ? 'center' : 'left' }}>Catering</a>
                    <a href="location.html" style={{ ...navLinkStyle, color: scrolled ? 'var(--charcoal)' : 'var(--cream)', width: isMobile ? '100%' : 'auto', textAlign: isMobile ? 'center' : 'left' }}>Visit</a>
                    <a href="jobs.html" style={{ ...navLinkStyle, color: scrolled ? 'var(--charcoal)' : 'var(--cream)', width: isMobile ? '100%' : 'auto', textAlign: isMobile ? 'center' : 'left' }}>Jobs</a>
                    <a href="contact-us.html" style={{ ...navLinkStyle, color: scrolled ? 'var(--charcoal)' : 'var(--cream)', width: isMobile ? '100%' : 'auto', textAlign: isMobile ? 'center' : 'left' }}>Contact</a>
                    <a href="order.html" style={{ ...buttonStyle, padding: '0.75rem 2rem', textDecoration: 'none', width: isMobile ? '100%' : 'auto', textAlign: 'center', background: 'var(--terracotta)', color: 'white' }}>Order Now</a>
                </div>
            </div>
        </nav>
    );
};

// Footer Component
const Footer = () => {
    const footerLinkStyle = {
        color: 'rgba(245, 241, 232, 0.7)',
        textDecoration: 'none',
        transition: 'color 0.2s',
        cursor: 'pointer'
    };

    return (
        <footer style={{ background: 'var(--charcoal)', padding: '4rem 4rem 2rem', color: 'var(--cream)' }}>
            <div style={{ maxWidth: '1400px', margin: '0 auto' }}>
                <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: '3rem', marginBottom: '3rem' }}>
                    <div>
                        <h3 style={{ fontSize: '2rem', fontFamily: "'DM Serif Display', serif", marginBottom: '1rem', color: 'var(--terracotta-light)' }}>Saucy's</h3>
                        <p style={{ fontSize: '0.95rem', lineHeight: '1.7', color: 'rgba(245, 241, 232, 0.7)', fontWeight: '300' }}>
                            Denver's favorite destination for authentic Southern BBQ, served with love since day one.
                        </p>
                    </div>
                    <div>
                        <h4 style={{ fontSize: '1.1rem', marginBottom: '1rem', fontWeight: '600', letterSpacing: '0.05em' }}>Quick Links</h4>
                        <div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem', fontSize: '0.95rem', fontWeight: '300' }}>
                            <a href="menu.html" style={footerLinkStyle}>Menu</a>
                            <a href="catering.html" style={footerLinkStyle}>Catering</a>
                            <a href="order.html" style={footerLinkStyle}>Order Online</a>
                            <a href="location.html" style={footerLinkStyle}>Location</a>
                            <a href="jobs.html" style={footerLinkStyle}>Jobs</a>
                            <a href="contact-us.html" style={footerLinkStyle}>Contact</a>
                        </div>
                    </div>
                    <div>
                        <h4 style={{ fontSize: '1.1rem', marginBottom: '1rem', fontWeight: '600', letterSpacing: '0.05em' }}>Connect</h4>
                        <div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem', fontSize: '0.95rem', fontWeight: '300' }}>
                            <a href="https://www.facebook.com/saucysouthern" target="_blank" rel="noopener noreferrer" style={footerLinkStyle}>Facebook</a>
                            <a href="https://www.instagram.com/saucysouthern" target="_blank" rel="noopener noreferrer" style={footerLinkStyle}>Instagram</a>
                            <a href="tel:7204846035" style={footerLinkStyle}>(720) 484-6035</a>
                        </div>
                    </div>
                </div>
                <div style={{ borderTop: '1px solid rgba(245, 241, 232, 0.1)', paddingTop: '2rem', textAlign: 'center', fontSize: '0.9rem', color: 'rgba(245, 241, 232, 0.5)', fontWeight: '300' }}>
                    © {new Date().getFullYear()} Saucy's Southern BBQ & Cuisine. All rights reserved.
                </div>
            </div>
        </footer>
    );
};

// Visit Page
const VisitPage = () => {
    const [isMobile, setIsMobile] = React.useState(false);

    React.useEffect(() => {
        const handleResize = () => setIsMobile(window.innerWidth <= 768);
        handleResize();
        window.addEventListener('resize', handleResize);
        return () => window.removeEventListener('resize', handleResize);
    }, []);

    const buttonStyle = {
        display: 'inline-block',
        padding: '0.875rem 2rem',
        borderRadius: '8px',
        textDecoration: 'none',
        fontWeight: '600',
        fontSize: '1rem',
        transition: 'all 0.3s ease',
        cursor: 'pointer',
        border: 'none',
        letterSpacing: '0.02em'
    };

    return (
        <div>
            <SmokeEffect />
            <Navigation />
            <section style={{
                padding: isMobile ? '6rem 1.5rem 4rem' : '10rem 4rem 8rem',
                background: 'linear-gradient(180deg, var(--charcoal) 0%, #2a1f1a 100%)',
                minHeight: '100vh'
            }}>
                <div style={{ maxWidth: '1400px', margin: '0 auto' }}>
                    <div style={{ textAlign: 'center', marginBottom: '5rem' }}>
                        <div style={{
                            fontSize: '0.9rem',
                            letterSpacing: '0.3em',
                            color: 'var(--terracotta-light)',
                            marginBottom: '1rem',
                            fontWeight: '500',
                            textTransform: 'uppercase'
                        }}>
                            Visit Us
                        </div>
                        <h1 style={{
                            fontSize: isMobile ? '2.5rem' : 'clamp(3rem, 6vw, 5rem)',
                            fontFamily: "'DM Serif Display', serif",
                            marginBottom: '1.5rem',
                            color: 'var(--cream)',
                            lineHeight: '1.1'
                        }}>
                            Come Say <span style={{ fontStyle: 'italic', color: 'var(--terracotta-light)' }}>Hello</span>
                        </h1>
                        <p style={{
                            fontSize: '1.2rem',
                            color: 'rgba(245, 241, 232, 0.8)',
                            maxWidth: '700px',
                            margin: '0 auto',
                            fontWeight: '300',
                            lineHeight: '1.7'
                        }}>
                            We're located in the heart of Denver, serving up authentic Southern BBQ daily. Stop by and taste the tradition!
                        </p>
                    </div>

                    <div style={{
                        display: 'grid',
                        gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr',
                        gap: isMobile ? '3rem' : '5rem',
                        alignItems: 'start'
                    }}>
                        {/* Left Column - Hours & Address */}
                        <div style={{
                            background: 'rgba(245, 241, 232, 0.05)',
                            borderRadius: '20px',
                            padding: isMobile ? '2.5rem' : '3.5rem',
                            border: '1px solid rgba(245, 241, 232, 0.1)',
                            backdropFilter: 'blur(10px)'
                        }}>
                            <div style={{ marginBottom: '3rem' }}>
                                <div style={{
                                    fontSize: '0.9rem',
                                    color: 'var(--terracotta-light)',
                                    marginBottom: '1rem',
                                    fontWeight: '600',
                                    letterSpacing: '0.1em',
                                    textTransform: 'uppercase'
                                }}>
                                    Address
                                </div>
                                <div style={{
                                    color: 'var(--cream)',
                                    fontSize: '1.3rem',
                                    fontWeight: '300',
                                    lineHeight: '1.7'
                                }}>
                                    2100 South University Boulevard<br />
                                    Denver, CO 80210
                                </div>
                            </div>

                            <div style={{ marginBottom: '3rem' }}>
                                <div style={{
                                    fontSize: '0.9rem',
                                    color: 'var(--terracotta-light)',
                                    marginBottom: '1rem',
                                    fontWeight: '600',
                                    letterSpacing: '0.1em',
                                    textTransform: 'uppercase'
                                }}>
                                    Hours
                                </div>
                                <div style={{
                                    color: 'var(--cream)',
                                    fontSize: '1.1rem',
                                    fontWeight: '300',
                                    lineHeight: '2'
                                }}>
                                    <div style={{ display: 'flex', justifyContent: 'space-between', borderBottom: '1px solid rgba(245, 241, 232, 0.1)', paddingBottom: '0.5rem', marginBottom: '0.5rem' }}>
                                        <span>Monday – Thursday</span>
                                        <span>11:00 AM – 9:00 PM</span>
                                    </div>
                                    <div style={{ display: 'flex', justifyContent: 'space-between', borderBottom: '1px solid rgba(245, 241, 232, 0.1)', paddingBottom: '0.5rem', marginBottom: '0.5rem' }}>
                                        <span>Friday – Saturday</span>
                                        <span>11:00 AM – 10:00 PM</span>
                                    </div>
                                    <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                                        <span>Sunday</span>
                                        <span>11:00 AM – 8:00 PM</span>
                                    </div>
                                </div>
                            </div>

                            <div style={{ marginBottom: '3rem' }}>
                                <div style={{
                                    fontSize: '0.9rem',
                                    color: 'var(--terracotta-light)',
                                    marginBottom: '1rem',
                                    fontWeight: '600',
                                    letterSpacing: '0.1em',
                                    textTransform: 'uppercase'
                                }}>
                                    Contact
                                </div>
                                <div style={{
                                    color: 'var(--cream)',
                                    fontSize: '1.3rem',
                                    fontWeight: '300',
                                    lineHeight: '1.7'
                                }}>
                                    <a href="tel:7204846035" style={{
                                        color: 'var(--cream)',
                                        textDecoration: 'none',
                                        borderBottom: '2px solid var(--terracotta)',
                                        paddingBottom: '3px',
                                        transition: 'border-color 0.2s'
                                    }}>
                                        (720) 484-6035
                                    </a>
                                </div>
                            </div>

                            <a href="https://maps.google.com/?q=2100+South+University+Boulevard+Denver+CO+80210" target="_blank" rel="noopener noreferrer" style={{
                                ...buttonStyle,
                                background: 'var(--terracotta)',
                                color: 'white',
                                padding: '1.2rem 3rem',
                                display: 'inline-block',
                                fontSize: '1.1rem'
                            }}>
                                Get Directions →
                            </a>
                        </div>

                        {/* Right Column - Parking & Accessibility */}
                        <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
                            {/* Parking */}
                            <div style={{
                                background: 'rgba(245, 241, 232, 0.05)',
                                borderRadius: '20px',
                                padding: isMobile ? '2rem' : '3rem',
                                border: '1px solid rgba(245, 241, 232, 0.1)',
                                backdropFilter: 'blur(10px)'
                            }}>
                                <div style={{
                                    fontSize: '0.9rem',
                                    color: 'var(--terracotta-light)',
                                    marginBottom: '1rem',
                                    fontWeight: '600',
                                    letterSpacing: '0.1em',
                                    textTransform: 'uppercase'
                                }}>
                                    Parking
                                </div>
                                <h3 style={{
                                    fontSize: '1.5rem',
                                    fontFamily: "'DM Serif Display', serif",
                                    color: 'var(--cream)',
                                    marginBottom: '1.5rem'
                                }}>
                                    Easy Access, Free Parking
                                </h3>
                                <ul style={{
                                    listStyle: 'none',
                                    padding: 0,
                                    margin: 0,
                                    display: 'flex',
                                    flexDirection: 'column',
                                    gap: '1rem'
                                }}>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>✓</span>
                                        Free parking lot behind the restaurant
                                    </li>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>✓</span>
                                        Street parking available along University Boulevard
                                    </li>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>✓</span>
                                        Designated accessible parking spaces near the entrance
                                    </li>
                                </ul>
                            </div>

                            {/* Accessibility */}
                            <div style={{
                                background: 'rgba(212, 82, 42, 0.1)',
                                borderRadius: '20px',
                                padding: isMobile ? '2rem' : '3rem',
                                border: '1px solid rgba(212, 82, 42, 0.2)',
                                backdropFilter: 'blur(10px)'
                            }}>
                                <div style={{
                                    fontSize: '0.9rem',
                                    color: 'var(--terracotta-light)',
                                    marginBottom: '1rem',
                                    fontWeight: '600',
                                    letterSpacing: '0.1em',
                                    textTransform: 'uppercase'
                                }}>
                                    Accessibility
                                </div>
                                <h3 style={{
                                    fontSize: '1.5rem',
                                    fontFamily: "'DM Serif Display', serif",
                                    color: 'var(--cream)',
                                    marginBottom: '1.5rem'
                                }}>
                                    Everyone's Welcome
                                </h3>
                                <ul style={{
                                    listStyle: 'none',
                                    padding: 0,
                                    margin: 0,
                                    display: 'flex',
                                    flexDirection: 'column',
                                    gap: '1rem'
                                }}>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>♿</span>
                                        Wheelchair-accessible entrance and dining area
                                    </li>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>♿</span>
                                        ADA-compliant restrooms
                                    </li>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>♿</span>
                                        Service animals welcome
                                    </li>
                                    <li style={{ display: 'flex', alignItems: 'flex-start', gap: '0.75rem', color: 'rgba(245, 241, 232, 0.8)', fontSize: '1rem', fontWeight: '300', lineHeight: '1.7' }}>
                                        <span style={{ color: 'var(--terracotta-light)', fontSize: '1.2rem', lineHeight: '1.5' }}>♿</span>
                                        Large-print menus available on request
                                    </li>
                                </ul>
                                <p style={{
                                    marginTop: '1.5rem',
                                    fontSize: '0.95rem',
                                    color: 'rgba(245, 241, 232, 0.6)',
                                    fontWeight: '300',
                                    lineHeight: '1.7',
                                    fontStyle: 'italic'
                                }}>
                                    Need special accommodations? Call us at (720) 484-6035 and we'll make sure your visit is comfortable.
                                </p>
                            </div>
                        </div>
                    </div>

                    <div style={{
                        marginTop: '5rem',
                        textAlign: 'center',
                        padding: isMobile ? '2.5rem' : '4rem',
                        background: 'rgba(212, 82, 42, 0.1)',
                        borderRadius: '20px',
                        border: '1px solid rgba(212, 82, 42, 0.2)'
                    }}>
                        <h2 style={{
                            fontSize: isMobile ? '2rem' : '2.5rem',
                            fontFamily: "'DM Serif Display', serif",
                            color: 'var(--cream)',
                            marginBottom: '1.5rem'
                        }}>
                            Planning a Large Group?
                        </h2>
                        <p style={{
                            fontSize: '1.1rem',
                            color: 'rgba(245, 241, 232, 0.8)',
                            fontWeight: '300',
                            marginBottom: '2rem',
                            maxWidth: '600px',
                            margin: '0 auto 2rem'
                        }}>
                            We can accommodate parties of all sizes! Contact us in advance to make arrangements for your group.
                        </p>
                        <a href="contact-us.html" style={{
                            ...buttonStyle,
                            background: 'var(--terracotta)',
                            color: 'white',
                            padding: '1.2rem 3rem',
                            fontSize: '1.1rem'
                        }}>
                            Contact Us
                        </a>
                    </div>
                </div>
            </section>
            <Footer />
        </div>
    );
};

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<VisitPage />);
