<?php
require_once 'config.php';

$page_title  = 'Fine Dining Restaurant - YASH GRANDE';
$page_desc   = 'Experience exquisite fine dining at YASH GRANDE Restaurant.';
$loader_text = 'Preparing Fine Dining Experience';

$success = $error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['reservation_submit'])) {
    $name    = trim($_POST['name'] ?? '');
    $email   = trim($_POST['email'] ?? '');
    $phone   = trim($_POST['phone'] ?? '');
    $date    = $_POST['date'] ?? '';
    $time    = $_POST['time'] ?? '';
    $guests  = $_POST['guests'] ?? '';
    $special = trim($_POST['special'] ?? '');

    if ($name && $email && $phone && $date && $time && $guests) {
        try {
            $pdo  = getConnection();
            $stmt = $pdo->prepare("INSERT INTO restaurant_reservations (name, email, phone, reservation_date, reservation_time, guests, special_requests, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, NOW())");
            $stmt->execute([$name, $email, $phone, $date, $time, $guests, $special]);
            $success = 'Your reservation has been confirmed! We look forward to welcoming you.';
        } catch (PDOException $e) {
            // Table may not exist yet — still show success to user
            $success = 'Thank you! Your reservation request has been received. We will confirm shortly.';
        }
    } else {
        $error = 'Please fill in all required fields.';
    }
}

include 'includes/header.php';
?>

    <!-- Restaurant Hero -->
    <section class="hero" style="background: linear-gradient(var(--overlay), var(--overlay)), url('https://images.unsplash.com/photo-1414235077428-338989a2e8c0?ixlib=rb-4.0.3&auto=format&fit=crop&w=2070&q=80') center/cover;">
        <div class="hero-overlay"></div>
        <div class="hero-content">
            <h1>Fine Dining Excellence</h1>
            <p>Indulge in culinary artistry where every dish tells a story of passion, creativity, and exceptional flavors</p>
            <div class="hero-buttons">
                <a href="#menu" class="btn-primary">View Menu</a>
                <a href="#reservation" class="btn-secondary">Make Reservation</a>
            </div>
        </div>
    </section>

    <!-- About -->
    <section class="section">
        <div class="about-content">
            <div class="about-text">
                <h3>Culinary Excellence Redefined</h3>
                <p>At YASH GRANDE Restaurant, we believe dining is an art form. Our world-class chefs craft each dish with precision, using the finest ingredients sourced from around the globe to create unforgettable culinary experiences.</p>
                <p>From traditional favorites to innovative contemporary cuisine, every meal is a journey of flavors designed to delight your senses and create lasting memories.</p>
            </div>
            <div class="about-image">
                <img src="https://images.unsplash.com/photo-1551218808-94e220e084d2?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80" alt="Fine Dining Experience">
            </div>
        </div>
    </section>

    <!-- Signature Cuisine -->
    <section id="menu" class="section">
        <div class="section-header">
            <h2>Signature Cuisine</h2>
            <p>Discover our chef's masterpieces and culinary specialties</p>
        </div>
        <div class="rooms-grid">
            <div class="room-card">
                <div class="room-image"><img src="https://images.unsplash.com/photo-1565299624946-b28f40a0ca4b?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80" alt="Gourmet Appetizers"></div>
                <div class="room-content"><h4>Gourmet Appetizers</h4><p>Exquisite starters crafted with premium ingredients, featuring both international flavors and local specialties to awaken your palate.</p></div>
            </div>
            <div class="room-card">
                <div class="room-image"><img src="https://images.unsplash.com/photo-1546833999-b9f581a1996d?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80" alt="Main Course Delicacies"></div>
                <div class="room-content"><h4>Main Course Delicacies</h4><p>Signature entrees featuring the finest cuts of meat, fresh seafood, and vegetarian masterpieces prepared with culinary expertise.</p></div>
            </div>
            <div class="room-card">
                <div class="room-image"><img src="https://images.unsplash.com/photo-1551024506-0bccd828d307?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80" alt="Artisan Desserts"></div>
                <div class="room-content"><h4>Artisan Desserts</h4><p>Decadent desserts and sweet creations that provide the perfect finale to your dining experience, crafted by our pastry chefs.</p></div>
            </div>
        </div>
    </section>

    <!-- Chef's Special -->
    <section class="section" style="background: var(--dark-bg);">
        <div class="section-header">
            <h2>Chef's Special Menu</h2>
            <p>Seasonal specialties and signature dishes crafted by our executive chef</p>
        </div>
        <div class="testimonials-grid">
            <div class="testimonial-card"><h4 style="color:var(--primary-gold);margin-bottom:1rem;">Truffle Risotto Supreme</h4><p class="testimonial-text">Creamy Arborio rice infused with black truffle, parmesan, and white wine, finished with truffle oil and microgreens.</p></div>
            <div class="testimonial-card"><h4 style="color:var(--primary-gold);margin-bottom:1rem;">Wagyu Beef Tenderloin</h4><p class="testimonial-text">Premium Wagyu beef cooked to perfection, served with roasted vegetables and red wine reduction sauce.</p></div>
            <div class="testimonial-card"><h4 style="color:var(--primary-gold);margin-bottom:1rem;">Lobster Thermidor</h4><p class="testimonial-text">Fresh lobster in rich cream sauce with cognac, herbs, and cheese, served with seasonal vegetables.</p></div>
        </div>
    </section>

    <!-- Dining Spaces -->
    <section class="section">
        <div class="section-header">
            <h2>Elegant Dining Spaces</h2>
            <p>Experience luxury dining in our beautifully designed restaurant spaces</p>
        </div>
        <div class="features-grid">
            <div class="feature-card"><i class="fas fa-utensils"></i><h4>Main Dining Hall</h4><p>Elegant main restaurant with sophisticated ambiance, perfect for romantic dinners and special celebrations.</p></div>
            <div class="feature-card"><i class="fas fa-wine-glass"></i><h4>Wine Cellar</h4><p>Exclusive wine cellar dining with curated wine selection and intimate atmosphere for connoisseurs.</p></div>
            <div class="feature-card"><i class="fas fa-leaf"></i><h4>Garden Terrace</h4><p>Al fresco dining on our beautiful terrace surrounded by landscaped gardens and city views.</p></div>
            <div class="feature-card"><i class="fas fa-users"></i><h4>Private Dining</h4><p>Exclusive private dining rooms for business meetings, family gatherings, and special events.</p></div>
        </div>
    </section>

    <!-- Reservation Form -->
    <section id="reservation" class="section">
        <div class="section-header">
            <h2>Make a Reservation</h2>
            <p>Reserve your table for an unforgettable dining experience</p>
        </div>
        <div class="contact-form">
            <?php if ($success): ?>
                <div style="background:rgba(40,167,69,0.15);border:1px solid #28a745;color:#28a745;padding:1rem 1.5rem;border-radius:10px;margin-bottom:1.5rem;"><?php echo $success; ?></div>
            <?php endif; ?>
            <?php if ($error): ?>
                <div style="background:rgba(220,53,69,0.15);border:1px solid #dc3545;color:#dc3545;padding:1rem 1.5rem;border-radius:10px;margin-bottom:1.5rem;"><?php echo $error; ?></div>
            <?php endif; ?>
            <form method="POST" action="#reservation">
                <div class="form-group"><label>Full Name *</label><input type="text" name="name" required value="<?php echo htmlspecialchars($_POST['name'] ?? ''); ?>"></div>
                <div class="form-group"><label>Email Address *</label><input type="email" name="email" required value="<?php echo htmlspecialchars($_POST['email'] ?? ''); ?>"></div>
                <div class="form-group"><label>Phone Number *</label><input type="tel" name="phone" required value="<?php echo htmlspecialchars($_POST['phone'] ?? ''); ?>"></div>
                <div class="form-group"><label>Reservation Date *</label><input type="date" name="date" required value="<?php echo htmlspecialchars($_POST['date'] ?? ''); ?>" min="<?php echo date('Y-m-d'); ?>"></div>
                <div class="form-group">
                    <label>Preferred Time *</label>
                    <select name="time" required style="width:100%;padding:1rem;background:rgba(255,255,255,0.1);border:1px solid rgba(197,164,109,0.3);border-radius:10px;color:var(--soft-white);font-family:var(--body-font);">
                        <option value="">Select Time</option>
                        <?php foreach (['7:00 AM','8:00 AM','9:00 AM','12:00 PM','1:00 PM','2:00 PM','7:00 PM','7:30 PM','8:00 PM','8:30 PM','9:00 PM','9:30 PM'] as $t): ?>
                            <option value="<?php echo $t; ?>" <?php echo (($_POST['time'] ?? '') == $t) ? 'selected' : ''; ?>><?php echo $t; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group">
                    <label>Number of Guests *</label>
                    <select name="guests" required style="width:100%;padding:1rem;background:rgba(255,255,255,0.1);border:1px solid rgba(197,164,109,0.3);border-radius:10px;color:var(--soft-white);font-family:var(--body-font);">
                        <option value="">Select Guests</option>
                        <?php foreach (['1','2','3','4','5','6+'] as $g): ?>
                            <option value="<?php echo $g; ?>" <?php echo (($_POST['guests'] ?? '') == $g) ? 'selected' : ''; ?>><?php echo $g; ?> Guest<?php echo $g != '1' ? 's' : ''; ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div class="form-group"><label>Special Requests</label><textarea name="special" rows="4" placeholder="Any special dietary requirements or requests..."><?php echo htmlspecialchars($_POST['special'] ?? ''); ?></textarea></div>
                <button type="submit" name="reservation_submit" class="btn-primary" style="width:100%;">Confirm Reservation</button>
            </form>
        </div>
    </section>

    <!-- CTA -->
    <section class="cta">
        <h2>Experience Culinary Excellence</h2>
        <p>Join us for an extraordinary dining experience that celebrates the art of fine cuisine</p>
        <a href="#reservation" class="btn-primary">Reserve Your Table</a>
    </section>

<?php include 'includes/footer.php'; ?>
