<?php
// public/partials/layout_end.php
?>
    </main>

    <!-- FOOTER -->
    <?php 
        tpl('footer'); 
    ?>

</div>
<?php
// CSS im Footer (falls benötigt)
foreach ($GLOBALS['page_styles'] as $style) {
    if ($style['pos'] !== 'footer') {
        continue;
    }

    $href = $style['href'];
    if (!empty($style['version'])) {
        $href .= (str_contains($href, '?') ? '&' : '?') . 'v=' . urlencode($style['version']);
    }

    echo '<link rel="stylesheet" href="' . htmlspecialchars($href) . '">' . PHP_EOL;
}

// Scripts im Footer
foreach ($GLOBALS['page_footer_scripts'] as $script) {
    $src = $script['src'];
    if (!empty($script['version'])) {
        $src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']);
    }

    $attr = '';
    if ($script['async']) {
        $attr .= ' async';
    } elseif ($script['defer']) {
        $attr .= ' defer';
    }
    if ($script['type']) {
        $attr .= ' type="' . htmlspecialchars($script['type']) . '"';
    }

    echo '<script src="' . htmlspecialchars($src) . '"' . $attr . '></script>' . PHP_EOL;
}
?>

<!-- Globale JS-Dateien -->
<script src="/assets/js/lang.js"></script>
<!-- Logout-Modal -->
<div id="logoutModalBackdrop"
     class="hidden fixed inset-0 z-50 bg-black/60 backdrop-blur-sm">
    <div class="min-h-full flex items-center justify-center p-4">
        <div class="w-full max-w-sm rounded-2xl border border-brand-border bg-brand-surface shadow-soft p-6 space-y-4">
            <h2 class="font-heading text-lg font-semibold text-brand-text" data-i18n="logout_modal_title">
                Wirklich ausloggen?
            </h2>
            <p class="text-sm text-brand-muted" data-i18n="logout_modal_text">
                Wenn du dich abmeldest, werden deine Sitzung und alle nicht gespeicherten Aktionen beendet. Du kannst dich jederzeit wieder einloggen.
            </p>

            <div class="flex justify-end gap-3 pt-2">
                <button type="button"
                        id="logoutCancel"
                        class="inline-flex items-center justify-center rounded-full border border-brand-border px-4 py-1.5 text-xs font-semibold uppercase tracking-[0.18em] text-brand-muted hover:border-brand-primary hover:text-brand-primary transition-colors"
                        data-i18n="logout_modal_cancel">
                    Abbrechen
                </button>
                <button type="button"
                        id="logoutConfirm"
                        class="inline-flex items-center justify-center rounded-full bg-red-500/90 px-4 py-1.5 text-xs font-semibold uppercase tracking-[0.18em] text-white shadow-soft hover:bg-red-400 transition-colors"
                        data-i18n="logout_modal_confirm">
                    Ja, ausloggen
                </button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<?php tpl('matomo', 'structure'); ?>
