<?php
$hide_back_to_top_pages = ['print_invoice.php', 'print_report.php', 'receipt_preview.php'];
$current_page = basename($_SERVER['PHP_SELF']);

$page_title = str_replace('_', ' ', ucwords(pathinfo($current_page, PATHINFO_FILENAME)));
$user_role = $_SESSION['role_name'] ?? 'User';
$user_name = $_SESSION['full_name'] ?? 'User';
$show_back_to_top = !in_array($current_page, $hide_back_to_top_pages);
?>

<footer class="bank-footer">
    <div class="footer-content">
        <div class="footer-meta">
            <span>&copy; <?= date('Y') ?> LapTrack Digital Systems |
                Powered by <a href="https://laptrack.digital" target="_blank" rel="noopener noreferrer">LapTrack Digital POS</a>.</span>
        </div>
        <?php if ($show_back_to_top): ?>
            <a href="#" class="back-to-top" title="Back to top">&#8679; Top</a>
        <?php endif; ?>
    </div>
</footer>

<style>
.bank-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 4px 16px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #eee;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    line-height: 1.2;
    min-height: 32px;
}

.footer-content {
    max-width: 1850px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.footer-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.footer-meta a {
    color: #ffa500;
    text-decoration: none;
    font-weight: 500;
}

.back-to-top {
    position: absolute;
    right: 32px;
    top: 6px;
    color: #ffa500;
    font-weight: bold;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.3s;
}

.back-to-top:hover {
    color: #fff;
}

@media (max-width: 600px) {
    .bank-footer {
        font-size: 11px;
        padding: 3px 10px;
    }

    .footer-content {
        padding: 0 8px;
    }

    .back-to-top {
        right: 16px;
        top: 4px;
    }
}

@media print {
    .bank-footer {
        display: none !important;
    }
}
</style>

<?php if ($show_back_to_top): ?>
<script>
document.querySelector('.back-to-top').addEventListener('click', function (e) {
    e.preventDefault();
    window.scrollTo({ top: 0, behavior: 'smooth' });
});
</script>
<?php endif; ?>
