<?php
// Pastikan $active_page sudah didefinisikan sebelum file ini dipanggil
if(!isset($active_page)) $active_page = 'index';
$app_logo_img = getSetting($pdo, 'app_logo');
$app_title_align = getSetting($pdo, 'app_title_align') ?: 'text-center';
$app_title_size = getSetting($pdo, 'app_title_size') ?: 'h4';
$app_title_font = getSetting($pdo, 'app_title_font') ?: 'fw-bold';
?>
<div class="mb-3 mt-3">
    <div class="mb-3 <?= htmlspecialchars($app_title_align) ?>">
        <!-- Logo -->
        <!-- MARGIN ATAS DAN BAWAH LOGO BISA DIUBAH DI SINI (Contoh: mt-2 untuk margin atas, mb-3 untuk margin bawah) -->
        <div class="mt-2 mb-3">
            <?php if(file_exists('logo/logo.png') || file_exists('../logo/logo.png')): ?>
                <img src="<?= base_url('logo/logo.png?v='.time()) ?>" alt="Logo" class="img-fluid" style="max-height: 80px; object-fit: contain;" fetchpriority="high" decoding="sync">
            <?php else: ?>
                <div class="d-inline-block p-2 rounded-circle bg-primary text-white shadow-sm" style="width: 60px; height: 60px; display: inline-flex; align-items: center; justify-content: center;">
                    <i class="fas fa-paper-plane fa-2x"></i>
                </div>
            <?php endif; ?>
        </div>
        
        <!-- Nama Aplikasi -->
        <?php if($active_page != 'form' && $active_page != 'track'): ?>
        <div class="<?= htmlspecialchars($app_title_size) ?> <?= htmlspecialchars($app_title_font) ?> text-dark mb-1">
            <?= htmlspecialchars($app_title) ?>
        </div>
        <?php endif; ?>
    </div>

    <!-- Tombol Hamburger / Toggle Khusus Mobile -->
    <?php if($active_page != 'form' && $active_page != 'track'): ?>
    <div class="d-md-none text-center mb-3">
        <button class="btn btn-outline-primary rounded-pill px-4 shadow-sm" type="button" data-bs-toggle="collapse" data-bs-target="#mobileNav" aria-expanded="false" aria-controls="mobileNav">
            <i class="fas fa-bars me-2"></i> Menu Navigasi
        </button>
    </div>
    <?php endif; ?>

    <!-- Kumpulan Tombol Navigasi -->
    <?php if($active_page != 'form' && $active_page != 'track'): ?>
    <div class="collapse d-md-block" id="mobileNav">
        <div class="d-flex justify-content-center flex-wrap gap-2 flex-column flex-md-row align-items-center">
            <a href="../index.php" class="btn rounded-pill px-4 fw-bold shadow-sm w-100 w-md-auto <?= ($active_page == 'index') ? 'btn-primary' : 'btn-outline-primary' ?>" style="max-width: 250px;">
                <i class="fas fa-home me-2"></i>Beranda
            </a>
            <a href="index.php" class="btn rounded-pill px-4 fw-bold shadow-sm w-100 w-md-auto <?= ($active_page == 'form') ? 'btn-primary' : 'btn-outline-primary' ?>" style="max-width: 250px;">
                <i class="fas fa-edit me-2"></i>Buat Pengajuan
            </a>
            <a href="track.php" class="btn rounded-pill px-4 fw-bold shadow-sm w-100 w-md-auto <?= ($active_page == 'track') ? 'btn-primary' : 'btn-outline-primary' ?>" style="max-width: 250px;">
                <i class="fas fa-search me-2"></i>Lacak Tiket
            </a>
        </div>
    </div>
    <?php endif; ?>
</div>

<style>
    /* Styling khusus ukuran medium ke atas (Desktop) */
    @media (min-width: 768px) {
        .w-md-auto { width: auto !important; }
    }
    
    /* Footer tidak melayang (tetap di bawah konten) pada Mobile */
    @media (max-width: 767px) {
        footer.fixed-bottom {
            position: static !important;
            margin-top: 40px !important;
            padding-bottom: 20px !important;
        }
    }
</style>
