<?php
require_once __DIR__ . '/_site_content.php';
$activePage = 'contact';

$contactSuccess = false;
$contactError = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['email'])) {
    $fullName = htmlspecialchars(trim($_POST['full_name'] ?? ''));
    $organisation = htmlspecialchars(trim($_POST['organisation'] ?? ''));
    $email = filter_var(trim($_POST['email'] ?? ''), FILTER_SANITIZE_EMAIL);
    $phone = htmlspecialchars(trim($_POST['phone'] ?? ''));
    $area = htmlspecialchars(trim($_POST['area'] ?? ($_POST['service'] ?? ($_POST['programme'] ?? ($_POST['partnership_type'] ?? 'General')))));
    $message = htmlspecialchars(trim($_POST['message'] ?? ''));

    $subject = 'SmartThink GT Website Enquiry — ' . $area;
    $body = "New enquiry from the website:\n\n";
    $body .= "Name: {$fullName}\n";
    $body .= "Organisation: {$organisation}\n";
    $body .= "Email: {$email}\n";
    $body .= "Phone: {$phone}\n";
    $body .= "Interest/Area: {$area}\n";
    if ($message) $body .= "Message:\n{$message}\n";

    $extraFields = ['ai_interest', 'data_maturity', 'goal', 'landscape', 'situation', 'format', 'enquiry_type', 'partnership_type', 'service', 'programme', 'current_situation'];
    foreach ($extraFields as $field) {
        if (!empty($_POST[$field])) {
            $label = ucwords(str_replace('_', ' ', $field));
            $body .= "{$label}: " . htmlspecialchars(trim($_POST[$field])) . "\n";
        }
    }

    $body .= "\nSubmitted at: " . date('Y-m-d H:i:s') . "\n";

    $headers = "From: {$email}\r\nReply-To: {$email}\r\nX-Mailer: PHP/" . phpversion();
    if (mail('study@smartthinkllc.com', $subject, $body, $headers)) {
        $contactSuccess = true;
    } else {
        $contactError = 'There was a problem sending your enquiry. Please try again or email us directly at study@smartthinkllc.com.';
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact — SmartThink Global Technology</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/smartthink-global.css">
    <style>
        .contact-hero { min-height: 45vh; padding: 8rem 0 4rem; background: linear-gradient(135deg, rgba(7,25,47,0.9) 0%, rgba(7,25,47,0.65) 100%), url('../assets/images/slider/cyberinsurance.webp') center/cover; color: #fff; }
        .contact-hero h1 { color: #fff; max-width: 720px; margin-bottom: 24px; }
        .contact-hero p { color: rgba(255,255,255,0.85); font-size: 21px; max-width: 600px; margin-bottom: 0; }
        .inquiry-card { cursor: pointer; border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 1.5rem; background: #fff; transition: all .2s; text-align: center; }
        .inquiry-card:hover { border-color: var(--blue-accent); box-shadow: var(--shadow-md); }
        .inquiry-card.selected { border: 3px solid var(--blue-accent); background: #f0f9ff; }
        .inquiry-card i { font-size: 2rem; color: var(--blue-accent); margin-bottom: .75rem; }
        .inquiry-card h4 { font-size: 1rem; margin-bottom: .5rem; }
        .inquiry-card p { font-size: .85rem; color: var(--slate); margin: 0; }
        .routed-form { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 2rem; }
    </style>
</head>
<body>
<?php include __DIR__ . '/includes/header.php'; ?>

    <section class="contact-hero">
        <div class="container">
            <h1>Let's Start Your Transformation</h1>
            <p>Tell us what you are working on. Our team will respond within one business day.</p>
        </div>
    </section>

    <section class="st-section">
        <div class="container">
            <div class="row g-5">
                <div class="col-lg-8">
                    <h2 class="mb-4">What can we help you with?</h2>
                    <?php if ($contactSuccess): ?>
                        <div class="alert alert-success mb-4">Thank you. Your message is with our team. A member of SmartThink Global Technology will contact you within one business day.</div>
                    <?php elseif ($contactError): ?>
                        <div class="alert alert-danger mb-4"><?php echo $contactError; ?></div>
                    <?php endif; ?>
                    <div class="row g-3 mb-5">
                        <div class="col-md-4 col-6">
                            <div class="inquiry-card selected" data-form="form-ai">
                                <i class="fas fa-robot"></i>
                                <h4>AI &amp; Digital Solutions</h4>
                                <p>Explore AI, digital transformation, or enterprise technology</p>
                            </div>
                        </div>
                        <div class="col-md-4 col-6">
                            <div class="inquiry-card" data-form="form-cyber">
                                <i class="fas fa-shield-alt"></i>
                                <h4>Cybersecurity &amp; Risk</h4>
                                <p>Cybersecurity advisory, risk assessment, or compliance</p>
                            </div>
                        </div>
                        <div class="col-md-4 col-6">
                            <div class="inquiry-card" data-form="form-academy">
                                <i class="fas fa-user-graduate"></i>
                                <h4>Academy &amp; Training</h4>
                                <p>Enrol or explore corporate training solutions</p>
                            </div>
                        </div>
                        <div class="col-md-6 col-6">
                            <div class="inquiry-card" data-form="form-partner">
                                <i class="fas fa-handshake"></i>
                                <h4>Partnership &amp; Alliances</h4>
                                <p>Partner with SmartThink Global Technology</p>
                            </div>
                        </div>
                        <div class="col-md-6 col-12">
                            <div class="inquiry-card" data-form="form-media">
                                <i class="fas fa-microphone"></i>
                                <h4>Media &amp; Press</h4>
                                <p>Journalist or analyst media enquiry</p>
                            </div>
                        </div>
                    </div>

                    <!-- Form A: AI & Digital Solutions -->
                    <div id="form-ai" class="routed-form">
                        <h3 class="mb-4">AI &amp; Digital Solutions</h3>
                        <form action="contact.php" method="post">
                            <div class="row g-3">
                                <div class="col-md-6"><label class="form-label">Full Name *</label><input type="text" class="form-control" name="full_name" required></div>
                                <div class="col-md-6"><label class="form-label">Organisation *</label><input type="text" class="form-control" name="organisation" required></div>
                                <div class="col-md-6"><label class="form-label">Work Email *</label><input type="email" class="form-control" name="email" required></div>
                                <div class="col-md-6"><label class="form-label">Phone</label><input type="tel" class="form-control" name="phone"></div>
                                <div class="col-12">
                                    <label class="form-label">Which area interests you?</label>
                                    <select class="form-select" name="area">
                                        <option>AI Solutions</option>
                                        <option>Digital Transformation</option>
                                        <option>Enterprise Solutions</option>
                                        <option>Innovation Lab</option>
                                        <option>Not sure</option>
                                    </select>
                                </div>
                                <div class="col-12"><label class="form-label">Brief description</label><textarea class="form-control" rows="3" name="message"></textarea></div>
                                <div class="col-12"><button type="submit" class="st-btn st-btn-primary">Schedule My Consultation</button></div>
                            </div>
                        </form>
                    </div>

                    <!-- Form B: Cybersecurity & Risk -->
                    <div id="form-cyber" class="routed-form d-none">
                        <h3 class="mb-4">Cybersecurity &amp; Risk</h3>
                        <form action="contact.php" method="post">
                            <div class="row g-3">
                                <div class="col-md-6"><label class="form-label">Full Name *</label><input type="text" class="form-control" name="full_name" required></div>
                                <div class="col-md-6"><label class="form-label">Organisation *</label><input type="text" class="form-control" name="organisation" required></div>
                                <div class="col-md-6"><label class="form-label">Work Email *</label><input type="email" class="form-control" name="email" required></div>
                                <div class="col-md-6"><label class="form-label">Phone</label><input type="tel" class="form-control" name="phone"></div>
                                <div class="col-md-6">
                                    <label class="form-label">Which service?</label>
                                    <select class="form-select" name="service">
                                        <option>Virtual CISO</option>
                                        <option>ISO 27001 Implementation</option>
                                        <option>SOC 2 Readiness</option>
                                        <option>NIST CSF Implementation</option>
                                        <option>Risk Assessment</option>
                                        <option>Compliance Programme</option>
                                        <option>Security Awareness</option>
                                        <option>Cybersecurity Strategy</option>
                                    </select>
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Current situation</label>
                                    <select class="form-select" name="situation">
                                        <option>Immediate incident</option>
                                        <option>Upcoming audit</option>
                                        <option>Building programme</option>
                                        <option>General assessment</option>
                                    </select>
                                </div>
                                <div class="col-12"><button type="submit" class="st-btn st-btn-primary">Schedule My Consultation</button></div>
                            </div>
                        </form>
                    </div>

                    <!-- Form C: Academy & Training -->
                    <div id="form-academy" class="routed-form d-none">
                        <h3 class="mb-4">Academy &amp; Training</h3>
                        <form action="contact.php" method="post">
                            <div class="row g-3">
                                <div class="col-md-6"><label class="form-label">Full Name *</label><input type="text" class="form-control" name="full_name" required></div>
                                <div class="col-md-6"><label class="form-label">Work Email *</label><input type="email" class="form-control" name="email" required></div>
                                <div class="col-md-6"><label class="form-label">Phone</label><input type="tel" class="form-control" name="phone"></div>
                                <div class="col-md-6">
                                    <label class="form-label">Individual or organisation?</label>
                                    <select class="form-select" name="enquiry_type">
                                        <option>Individual</option>
                                        <option>Organisation</option>
                                    </select>
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Programme interest</label>
                                    <select class="form-select" name="programme">
                                        <option>Artificial Intelligence</option>
                                        <option>Cybersecurity</option>
                                        <option>Digital Transformation</option>
                                        <option>GRC</option>
                                        <option>Cloud Security</option>
                                        <option>Data Analytics</option>
                                        <option>Technology Leadership</option>
                                        <option>Not sure</option>
                                    </select>
                                </div>
                                <div class="col-md-6">
                                    <label class="form-label">Preferred format</label>
                                    <select class="form-select" name="format">
                                        <option>Online</option>
                                        <option>In-person</option>
                                        <option>Hybrid</option>
                                    </select>
                                </div>
                                <div class="col-12"><button type="submit" class="st-btn st-btn-teal">Apply to Academy / Request Training Info</button></div>
                            </div>
                        </form>
                    </div>

                    <!-- Form D: Partnership -->
                    <div id="form-partner" class="routed-form d-none">
                        <h3 class="mb-4">Partnership &amp; Alliances</h3>
                        <form action="contact.php" method="post">
                            <div class="row g-3">
                                <div class="col-md-6"><label class="form-label">Full Name *</label><input type="text" class="form-control" name="full_name" required></div>
                                <div class="col-md-6"><label class="form-label">Organisation *</label><input type="text" class="form-control" name="organisation" required></div>
                                <div class="col-md-6"><label class="form-label">Work Email *</label><input type="email" class="form-control" name="email" required></div>
                                <div class="col-md-6">
                                    <label class="form-label">Partnership type</label>
                                    <select class="form-select" name="partnership_type">
                                        <option>Technology</option>
                                        <option>Channel</option>
                                        <option>Institutional</option>
                                        <option>Other</option>
                                    </select>
                                </div>
                                <div class="col-12"><label class="form-label">Brief message</label><textarea class="form-control" rows="3" name="message"></textarea></div>
                                <div class="col-12"><button type="submit" class="st-btn st-btn-primary">Submit Partnership Enquiry</button></div>
                            </div>
                        </form>
                    </div>

                    <!-- Form E: Media -->
                    <div id="form-media" class="routed-form d-none">
                        <h3 class="mb-4">Media &amp; Press</h3>
                        <form action="contact.php" method="post">
                            <div class="row g-3">
                                <div class="col-md-6"><label class="form-label">Full Name *</label><input type="text" class="form-control" name="full_name" required></div>
                                <div class="col-md-6"><label class="form-label">Publication/Organisation *</label><input type="text" class="form-control" name="organisation" required></div>
                                <div class="col-md-6"><label class="form-label">Work Email *</label><input type="email" class="form-control" name="email" required></div>
                                <div class="col-12"><label class="form-label">Nature of enquiry</label><textarea class="form-control" rows="3" name="message"></textarea></div>
                                <div class="col-12"><button type="submit" class="st-btn st-btn-primary">Submit Media Enquiry</button></div>
                            </div>
                        </form>
                    </div>
                </div>

                <!-- Side Panel -->
                <div class="col-lg-4">
                    <div class="p-4 rounded-3 mb-4" style="background: var(--bg-cloud); border: 1px solid var(--border-light);">
                        <h4 class="mb-3">Direct Contact</h4>
                        <p><a href="mailto:study@smartthinkllc.com"><i class="fas fa-envelope me-2"></i>study@smartthinkllc.com</a></p>
                        <p><a href="tel:+12027907745"><i class="fas fa-phone me-2"></i>(+1) 202-790-7745</a></p>
                    </div>
                    <div class="p-4 rounded-3 mb-4" style="background: var(--bg-cloud); border: 1px solid var(--border-light);">
                        <h4 class="mb-3">Office Locations</h4>
                        <p><i class="fas fa-map-marker-alt me-2"></i>Berwyn Heights, MD</p>
                        <p><i class="fas fa-map-marker-alt me-2"></i>United Kingdom</p>
                        <p><i class="fas fa-map-marker-alt me-2"></i>Ghana</p>
                    </div>
                    <div class="p-4 rounded-3" style="background: var(--navy-primary); color: #fff;">
                        <h4 class="mb-3" style="color: #fff;">By the Numbers</h4>
                        <div class="d-flex justify-content-between text-center">
                            <div><div class="h4 fw-bold">25+</div><small style="opacity:.8;">Years</small></div>
                            <div><div class="h4 fw-bold">500+</div><small style="opacity:.8;">Trained</small></div>
                            <div><div class="h4 fw-bold">EG</div><small style="opacity:.8;">Trusted</small></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

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