<?php
echo '<pre>';
var_dump(require 'mail/config.php');
echo '</pre>';
$form_message = '';
$form_error = '';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    require_once 'db/config.php';
    require_once 'mail/MailService.php';

    $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
    $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
    $message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);

    if (empty($name) || empty($email) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $form_error = "Please fill out all fields with valid information.";
    } else {
        try {
            $pdo = db();
            $stmt = $pdo->prepare("INSERT INTO leads (name, email, message) VALUES (?, ?, ?)");
            $stmt->execute([$name, $email, $message]);

            $mailResult = MailService::sendContactMessage($name, $email, $message);

            if ($mailResult['success']) {
                $form_message = "Thank you for your message! We will get back to you shortly.";
            } else {
                $form_error = "Sorry, there was an error sending your message. Please try again later.";
                // Optionally log the detailed error: error_log($mailResult['error']);
            }
        } catch (PDOException $e) {
            $form_error = "Sorry, there was a database error. Please try again later.";
            // Optionally log the detailed error: error_log($e->getMessage());
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nimbus - Streamline Your Success</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    
    <!-- Google Fonts (Inter) -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>

    <!-- Header -->
    <header>
        <nav class="navbar navbar-expand-lg navbar-light fixed-top py-3">
            <div class="container">
                <a class="navbar-brand fw-bold" href="#">Nimbus</a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav ms-auto">
                        <li class="nav-item"><a class="nav-link smooth-scroll" href="#features">Features</a></li>
                        <li class="nav-item"><a class="nav-link smooth-scroll" href="#testimonials">Testimonials</a></li>
                        <li class="nav-item"><a class="nav-link smooth-scroll" href="#pricing">Pricing</a></li>
                        <li class="nav-item"><a class="nav-link smooth-scroll" href="#faq">FAQ</a></li>
                    </ul>
                    <a href="#contact" class="btn btn-primary ms-lg-3 smooth-scroll">Contact Sales</a>
                </div>
            </div>
        </nav>
    </header>

    <main>
        <!-- Hero Section -->
        <section id="hero" class="hero text-center">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-lg-8">
                        <h1 class="display-4">Streamline Your Success.</h1>
                        <p class="lead my-4">Nimbus is the all-in-one platform to automate workflows, manage projects, and scale your business.</p>
                        <a href="#contact" class="btn btn-primary btn-lg smooth-scroll">Get Started Free</a>
                        <a href="#" class="btn btn-outline-secondary btn-lg ms-2">Watch Demo</a>
                    </div>
                </div>
                 <img src="./assets/pasted-20250911-115131-dbff0810.png" class="img-fluid rounded-3 shadow-lg mt-5" alt="Abstract blue and white digital art representing cloud data streams.">
            </div>
        </section>

        <!-- Social Proof -->
        <section id="social-proof" class="py-5">
            <div class="container text-center">
                <h6 class="text-muted mb-4">TRUSTED BY LEADING COMPANIES WORLDWIDE</h6>
                <div class="d-flex flex-wrap justify-content-center align-items-center social-proof-logos">
                    <img src="https://via.placeholder.com/150x50/CCCCCC/FFFFFF?text=CompanyA" alt="Company A Logo" class="mx-4 my-2">
                    <img src="https://via.placeholder.com/150x50/CCCCCC/FFFFFF?text=CompanyB" alt="Company B Logo" class="mx-4 my-2">
                    <img src="https://via.placeholder.com/150x50/CCCCCC/FFFFFF?text=CompanyC" alt="Company C Logo" class="mx-4 my-2">
                    <img src="https://via.placeholder.com/150x50/CCCCCC/FFFFFF?text=CompanyD" alt="Company D Logo" class="mx-4 my-2">
                    <img src="https://via.placeholder.com/150x50/CCCCCC/FFFFFF?text=CompanyE" alt="Company E Logo" class="mx-4 my-2">
                </div>
            </div>
        </section>

        <!-- Product Mock -->
        <section id="product-mock" class="section-py">
            <div class="container text-center">
                 <img src="https://picsum.photos/seed/nimbus-dashboard/1200/800" class="img-fluid rounded-3 shadow-lg" alt="A clean and modern dashboard UI for the Nimbus application.">
            </div>
        </section>

        <!-- Features Section -->
        <section id="features" class="section-py bg-white">
            <div class="container">
                <div class="text-center mb-5">
                    <h2 class="fw-bold">Everything you need, nothing you don't.</h2>
                    <p class="lead text-muted">Focus on what matters with our core features.</p>
                </div>
                <div class="row g-4">
                    <div class="col-md-4">
                        <div class="text-center p-4">
                            <i class="bi bi-bar-chart-line-fill fs-1 text-primary"></i>
                            <h4 class="mt-3">Automated Workflows</h4>
                            <p>Set up triggers and actions to automate repetitive tasks and save countless hours.</p>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="text-center p-4">
                            <i class="bi bi-kanban-fill fs-1 text-primary"></i>
                            <h4 class="mt-3">Project Management</h4>
                            <p>Visualize your progress with kanban boards, task lists, and team assignments.</p>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="text-center p-4">
                            <i class="bi bi-people-fill fs-1 text-primary"></i>
                            <h4 class="mt-3">Team Collaboration</h4>
                            <p>Communicate seamlessly with integrated chat, file sharing, and real-time updates.</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Testimonials Section -->
        <section id="testimonials" class="section-py">
            <div class="container">
                <div class="text-center mb-5">
                    <h2 class="fw-bold">Loved by teams everywhere</h2>
                </div>
                <div class="row g-4">
                    <div class="col-lg-4">
                        <div class="card h-100 testimonial-card rounded-lg shadow-sm">
                            <div class="card-body text-center">
                                <img src="https://picsum.photos/seed/avatar1/96/96" class="rounded-circle mb-3" alt="A portrait of a satisfied Nimbus customer.">
                                <p class="fst-italic">"Nimbus transformed how we manage projects. We're more organized and efficient than ever before."</p>
                                <h6 class="fw-bold mt-4 mb-0">Alex Johnson</h6>
                                <small class="text-muted">CEO, Innovate Inc.</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="card h-100 testimonial-card rounded-lg shadow-sm">
                            <div class="card-body text-center">
                                <img src="https://picsum.photos/seed/avatar2/96/96" class="rounded-circle mb-3" alt="A portrait of a satisfied Nimbus customer.">
                                <p class="fst-italic">"The automation features are a game-changer. We've saved at least 10 hours per week."</p>
                                <h6 class="fw-bold mt-4 mb-0">Samantha Bee</h6>
                                <small class="text-muted">Marketing Director, Creative Co.</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="card h-100 testimonial-card rounded-lg shadow-sm">
                            <div class="card-body text-center">
                                <img src="https://picsum.photos/seed/avatar3/96/96" class="rounded-circle mb-3" alt="A portrait of a satisfied Nimbus customer.">
                                <p class="fst-italic">"The user interface is so intuitive. My team was able to get started with minimal training."</p>
                                <h6 class="fw-bold mt-4 mb-0">David Chen</h6>
                                <small class="text-muted">Head of Operations, Logistics Pro</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Pricing Section -->
        <section id="pricing" class="section-py bg-white">
            <div class="container">
                <div class="text-center mb-5">
                    <h2 class="fw-bold">Find the right plan for you</h2>
                    <div class="form-check form-switch d-inline-block mt-3 fs-5">
                        <label class="form-check-label" for="pricingToggle">Monthly</label>
                        <input class="form-check-input" type="checkbox" id="pricingToggle">
                        <label class="form-check-label" for="pricingToggle">Yearly (Save 20%)</label>
                    </div>
                </div>
                <div class="row g-4 justify-content-center">
                    <!-- Basic Plan -->
                    <div class="col-lg-4">
                        <div class="card h-100 text-center rounded-lg shadow-sm">
                            <div class="card-body p-5">
                                <h5 class="card-title">Basic</h5>
                                <div class="price-monthly">
                                    <span class="display-4 fw-bold">$29</span>
                                    <span class="text-muted">/ month</span>
                                </div>
                                <div class="price-yearly" style="display: none;">
                                    <span class="display-4 fw-bold">$278</span>
                                    <span class="text-muted">/ year</span>
                                </div>
                                <ul class="list-unstyled my-4">
                                    <li>Up to 5 users</li>
                                    <li>Core Features</li>
                                    <li>10GB Storage</li>
                                    <li>Community Support</li>
                                </ul>
                                <a href="#contact" class="btn btn-outline-primary w-100 smooth-scroll">Choose Plan</a>
                            </div>
                        </div>
                    </div>
                    <!-- Pro Plan -->
                    <div class="col-lg-4">
                        <div class="card h-100 text-center rounded-lg shadow border-primary">
                            <div class="card-header bg-primary text-white">Most Popular</div>
                            <div class="card-body p-5">
                                <h5 class="card-title">Pro</h5>
                                <div class="price-monthly">
                                    <span class="display-4 fw-bold">$79</span>
                                    <span class="text-muted">/ month</span>
                                </div>
                                <div class="price-yearly" style="display: none;">
                                    <span class="display-4 fw-bold">$758</span>
                                    <span class="text-muted">/ year</span>
                                </div>
                                <ul class="list-unstyled my-4">
                                    <li>Up to 25 users</li>
                                    <li>Advanced Features</li>
                                    <li>100GB Storage</li>
                                    <li>Priority Support</li>
                                </ul>
                                <a href="#contact" class="btn btn-primary w-100 smooth-scroll">Choose Plan</a>
                            </div>
                        </div>
                    </div>
                    <!-- Enterprise Plan -->
                    <div class="col-lg-4">
                        <div class="card h-100 text-center rounded-lg shadow-sm">
                            <div class="card-body p-5">
                                <h5 class="card-title">Enterprise</h5>
                                <div class="price-monthly">
                                    <span class="display-4 fw-bold">Custom</span>
                                </div>
                                <div class="price-yearly" style="display: none;">
                                    <span class="display-4 fw-bold">Custom</span>
                                </div>
                                <ul class="list-unstyled my-4">
                                    <li>Unlimited users</li>
                                    <li>Dedicated Infrastructure</li>
                                    <li>Unlimited Storage</li>
                                    <li>24/7 Dedicated Support</li>
                                </ul>
                                <a href="#contact" class="btn btn-outline-primary w-100 smooth-scroll">Contact Us</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- FAQ Section -->
        <section id="faq" class="section-py">
            <div class="container">
                <div class="text-center mb-5">
                    <h2 class="fw-bold">Frequently Asked Questions</h2>
                </div>
                <div class="row justify-content-center">
                    <div class="col-lg-8">
                        <div class="accordion" id="faqAccordion">
                            <div class="accordion-item">
                                <h2 class="accordion-header" id="headingOne">
                                    <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne">
                                        Is there a free trial available?
                                    </button>
                                </h2>
                                <div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#faqAccordion">
                                    <div class="accordion-body">
                                        Yes, we offer a 14-day free trial on our Pro plan. No credit card required.
                                    </div>
                                </div>
                            </div>
                            <div class="accordion-item">
                                <h2 class="accordion-header" id="headingTwo">
                                    <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo">
                                        Can I change my plan later?
                                    </button>
                                </h2>
                                <div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                                    <div class="accordion-body">
                                        Absolutely. You can upgrade, downgrade, or cancel your plan at any time from your account settings.
                                    </div>
                                </div>
                            </div>
                            <div class="accordion-item">
                                <h2 class="accordion-header" id="headingThree">
                                    <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree">
                                        What payment methods do you accept?
                                    </button>
                                </h2>
                                <div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                                    <div class="accordion-body">
                                        We accept all major credit cards, including Visa, Mastercard, and American Express. For Enterprise plans, we also support invoicing.
                                    </div>
                                </div>
                            </div>
                             <div class="accordion-item">
                                <h2 class="accordion-header" id="headingFour">
                                    <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseFour">
                                        Is my data secure?
                                    </button>
                                </h2>
                                <div id="collapseFour" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
                                    <div class="accordion-body">
                                        Data security is our top priority. We use industry-standard encryption and security practices to keep your data safe.
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Contact Form Section -->
        <section id="contact" class="section-py bg-white">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-lg-6 text-center">
                        <h2 class="fw-bold">Ready to Grow?</h2>
                        <p class="lead text-muted mb-5">Fill out the form below and a member of our team will get back to you shortly.</p>
                        <div class="alert alert-info">This is for testing purposes only — Flatlogic does not guarantee usage of the mail server. Please set up your own SMTP in <code>.env</code> (MAIL_/SMTP_ vars).</div>
                        
                        <?php if ($form_message): ?>
                            <div class="alert alert-success"><?php echo $form_message; ?></div>
                        <?php endif; ?>
                        <?php if ($form_error): ?>
                            <div class="alert alert-danger"><?php echo $form_error; ?></div>
                        <?php endif; ?>

                        <form id="leadForm" method="POST" action="index.php#contact" novalidate>
                            <div class="mb-3">
                                <input type="text" class="form-control form-control-lg" id="name" name="name" placeholder="Your Name" required>
                                <div class="invalid-feedback">Please enter your name.</div>
                            </div>
                            <div class="mb-3">
                                <input type="email" class="form-control form-control-lg" id="email" name="email" placeholder="Work Email" required>
                                <div class="invalid-feedback">Please enter a valid email address.</div>
                            </div>
                            <div class="mb-3">
                                <textarea class="form-control form-control-lg" id="message" name="message" rows="4" placeholder="Your Message" required></textarea>
                                <div class="invalid-feedback">Please enter a message.</div>
                            </div>
                            <button type="submit" class="btn btn-primary btn-lg w-100">Submit Request</button>
                        </form>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="footer py-4">
        <div class="container">
            <div class="d-flex justify-content-between align-items-center">
                <span class="text-muted">&copy; <?php echo date("Y"); ?> Nimbus, Inc.</span>
                <div>
                    <a href="#" class="text-muted me-3">Privacy Policy</a>
                    <a href="#" class="text-muted">Terms of Service</a>
                </div>
            </div>
        </div>
    </footer>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Custom JS -->
    <script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>