<?php
if (!isset($brandingData)) {
    require_once 'db.php';
    $stmt = $pdo->query("SELECT * FROM branding LIMIT 1");
    $brandingData = $stmt->fetch(PDO::FETCH_ASSOC);
}
?>


<link rel="stylesheet" href="assets/css/themes/<?php echo htmlspecialchars($brandingData['theme_stylesheet'] ?? 'theme-orange.css'); ?>">



<?php
$currentDomain = str_replace(['https://', 'http://', 'www.'], '', $_SERVER['HTTP_HOST']);

if (!isset($brandingData)) {
    require_once 'db.php';
    $stmt = $pdo->query("SELECT * FROM branding LIMIT 1");
    $brandingData = $stmt->fetch(PDO::FETCH_ASSOC);
}

$brandName = $brandingData['brand_name'] ?? 'Your Brand';
$title = $brandingData['title'] ?? '';
$subtitle = $brandingData['subtitle'] ?? '';
$footerNote = $brandingData['footer_note'] ?? '';
?>

<footer class="footer">
    <div>
        &copy; <?= date('Y'); ?> <?= htmlspecialchars($brandName); ?> | <?= htmlspecialchars($currentDomain); ?>. All Rights Reserved.
    </div>

    <?php if (!empty($title) || !empty($subtitle)): ?>
        <div style="font-size: 13px; margin-top: 6px; color: #ccc;">
            <?= htmlspecialchars($title); ?>
            <?php if (!empty($subtitle)): ?>
                <br><small><?= htmlspecialchars($subtitle); ?></small>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <?php if (!empty($footerNote)): ?>
        <div style="font-size: 12px; margin-top: 8px; color: #bbb;">
            <?= strip_tags($footerNote, '<a><br>') ?>
        </div>
    <?php endif; ?>
</footer>
