<?php
$page_title = 'Contact Us';
$page_description = 'Get in touch with the Buy Local Lowveld team.';

require_once __DIR__ . '/includes/csrf.php';

$success = isset($_GET['success']);
$error   = $_GET['error'] ?? '';

require 'includes/header.php';
?>

<section class="page-banner">
    <div class="container">
        <h1>Contact Us</h1>
        <p>Questions about membership, events, or sponsorship? We respond within one business day.</p>
    </div>
</section>

<?php if ($success): ?>
<section class="section">
    <div class="container">
        <div class="alert alert-success" data-autohide>
            <strong>Thanks for getting in touch.</strong>
            Your message has landed with our team and we'll respond within one business day.
        </div>
    </div>
</section>
<?php endif; ?>

<?php if ($error === 'missing'): ?>
<section class="section">
    <div class="container">
        <div class="alert alert-error">
            Please fill in all required fields and try again.
        </div>
    </div>
</section>
<?php endif; ?>

<section class="section">
    <div class="container">
        <div class="grid grid-2">
            <div>
                <h2>Get in touch</h2>
                <p>
                    For general enquiries, partnership opportunities, or help with your membership,
                    use the form &mdash; or reach us on the channels listed here.
                </p>

                <div class="card mt-3">
                    <h3>Email</h3>
                    <p><a href="mailto:<?= htmlspecialchars(SITE_EMAIL) ?>"><?= htmlspecialchars(SITE_EMAIL) ?></a></p>

                    <h3 class="mt-2">Phone</h3>
                    <p><a href="tel:+27135550100">013 555 0100</a></p>

                    <h3 class="mt-2">Office</h3>
                    <p>
                        12 Ferreira Street<br>
                        Nelspruit, Mpumalanga<br>
                        South Africa
                    </p>

                    <h3 class="mt-2">Hours</h3>
                    <p>Mon&ndash;Fri, 08:00&ndash;16:30<br>Closed public holidays</p>
                </div>
            </div>

            <div>
                <h2>Send us a message</h2>
                <form method="post" action="contact-submit.php">
                    <?= csrf_field() ?>
                    <div class="grid grid-2" style="gap:0 1.25rem;">
                        <div>
                            <label for="first_name">First name *</label>
                            <input type="text" id="first_name" name="first_name" required>
                        </div>
                        <div>
                            <label for="last_name">Last name *</label>
                            <input type="text" id="last_name" name="last_name" required>
                        </div>
                    </div>

                    <label for="email">Email *</label>
                    <input type="email" id="email" name="email" required>

                    <label for="phone">Phone</label>
                    <input type="tel" id="phone" name="phone">

                    <label for="topic">What's this about?</label>
                    <select id="topic" name="topic">
                        <option value="General enquiry">General enquiry</option>
                        <option value="Membership">Membership question</option>
                        <option value="Directory listing">Directory listing issue</option>
                        <option value="Events">Events / sponsorship</option>
                        <option value="Media">Media enquiry</option>
                        <option value="Other">Other</option>
                    </select>

                    <label for="message">Message *</label>
                    <textarea id="message" name="message" required placeholder="Tell us a bit about what you need..."></textarea>

                    <label style="font-weight:400;font-size:.9rem;margin-top:1rem;">
                        <input type="checkbox" name="consent">
                        Keep me updated with occasional Buy Local news (optional).
                    </label>

                    <button type="submit" class="btn mt-3">Send message</button>
                </form>
            </div>
        </div>
    </div>
</section>

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