<?php
// support.php
require 'config/db.php';


// We include the header and the logic for the support addon
require_once 'includes/header.php';
require_once 'addons/support_system/main.php';

/**
 * SECTION ROUTING
 * Default to 'center' (the help home). 
 * Sanitize the input to prevent directory traversal or script injection.
 */
$section = isset($_GET['section']) ? preg_replace('/[^a-zA-Z0-0_-]/', '', $_GET['section']) : 'center';
?>

<style>
    .support-container { max-width: 1100px; margin: 50px auto; padding: 0 20px; min-height: 70vh; }
    .support-wrapper { 
        background: var(--nav-bg); 
        border: 1px solid var(--border); 
        border-radius: 20px; 
        padding: 50px; 
        box-shadow: 0 10px 40px rgba(0,0,0,0.3);
        position: relative;
    }
    /* Breadcrumb for easier navigation */
    .support-breadcrumb { margin-bottom: 25px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-gray); }
    .support-breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 800; }
    .support-breadcrumb span { margin: 0 10px; opacity: 0.3; }
</style>

<div class="support-container">
    <div class="support-breadcrumb">
        <a href="index.php">The Vault</a> <span>/</span> 
        <a href="support.php">Support Center</a> 
        <?php if($section !== 'center'): ?>
            <span>/</span> <?php echo htmlspecialchars(ucfirst($section)); ?>
        <?php endif; ?>
    </div>

    <div class="support-wrapper">
        <?php 
            /**
             * The render_support_section function should handle 
             * the switch/case logic for different views.
             */
            if (function_exists('render_support_section')) {
                render_support_section($section, $pdo); 
            } else {
                echo "<div style='text-align:center; padding: 50px;'>
                        <i class='fa-solid fa-triangle-exclamation' style='font-size: 40px; color: #ff4d4d;'></i>
                        <h3 style='margin-top:20px;'>Support System Offline</h3>
                        <p style='color: var(--text-gray);'>The support addon was not found in the mainframe.</p>
                      </div>";
            }
        ?>
    </div>
</div>

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