        </div><!-- /.admin-content -->
    </main><!-- /.admin-main -->

</div><!-- /.admin-layout -->

<script>
/* ══════════════════════════════════════════
   SIDEBAR TOGGLE (mobile)
══════════════════════════════════════════ */
var sidebar  = document.getElementById('adminSidebar');
var overlay  = document.getElementById('sidebarOverlay');
var toggleBtn = document.getElementById('sidebarToggle');

function openSidebar() {
    sidebar.classList.add('open');
    overlay.classList.add('active');
    document.body.style.overflow = 'hidden';
}
function closeSidebar() {
    sidebar.classList.remove('open');
    overlay.classList.remove('active');
    document.body.style.overflow = '';
}
if (toggleBtn) {
    toggleBtn.addEventListener('click', function() {
        if (sidebar.classList.contains('open')) {
            closeSidebar();
        } else {
            openSidebar();
        }
    });
}
/* Close on Escape */
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') closeSidebar();
});
/* Close on resize to desktop */
window.addEventListener('resize', function() {
    if (window.innerWidth > 768) closeSidebar();
});

/* ══════════════════════════════════════════
   THEME TOGGLE
══════════════════════════════════════════ */
(function() {
    var html = document.documentElement;
    var btn  = document.getElementById('themeToggleBtn');
    var icon = document.getElementById('themeIcon');

    function applyTheme(theme) {
        html.setAttribute('data-theme', theme);
        if (icon) {
            icon.className = (theme === 'light') ? 'fa fa-sun-o' : 'fa fa-moon-o';
        }
        localStorage.setItem('admin_theme', theme);
    }

    /* Apply on load */
    applyTheme(localStorage.getItem('admin_theme') || 'dark');

    if (btn) {
        btn.addEventListener('click', function() {
            var current = html.getAttribute('data-theme');
            applyTheme(current === 'dark' ? 'light' : 'dark');
        });
    }
})();

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
function showToast(message, type) {
    type = type || 'info';
    var icons = { success: 'fa-check-circle', error: 'fa-times-circle', info: 'fa-info-circle', warning: 'fa-exclamation-triangle' };
    var container = document.getElementById('toast-container');
    if (!container) return;
    var toast = document.createElement('div');
    toast.className = 'toast ' + type;
    toast.innerHTML = '<i class="fa ' + (icons[type] || icons.info) + ' ' + type + '"></i> ' + message;
    container.appendChild(toast);
    setTimeout(function() {
        toast.style.opacity = '0';
        toast.style.transform = 'translateX(40px)';
        toast.style.transition = 'all .3s ease';
        setTimeout(function() { if (toast.parentNode) toast.parentNode.removeChild(toast); }, 320);
    }, 3200);
}

/* ══════════════════════════════════════════
   CONFIRM MODAL
══════════════════════════════════════════ */
function adminConfirm(message, onConfirm) {
    var overlay = document.createElement('div');
    overlay.className = 'modal-overlay';
    overlay.innerHTML =
        '<div class="modal-box">' +
            '<div class="modal-icon"><i class="fa fa-trash"></i></div>' +
            '<h3>Emin misiniz?</h3>' +
            '<p>' + (message || 'Bu işlem geri alınamaz.') + '</p>' +
            '<div class="modal-actions">' +
                '<button class="admin-btn" id="modalCancel"><i class="fa fa-times"></i> İptal</button>' +
                '<button class="admin-btn admin-btn-danger" id="modalConfirm"><i class="fa fa-trash"></i> Sil</button>' +
            '</div>' +
        '</div>';
    document.body.appendChild(overlay);

    document.getElementById('modalCancel').addEventListener('click', function() {
        document.body.removeChild(overlay);
    });
    document.getElementById('modalConfirm').addEventListener('click', function() {
        document.body.removeChild(overlay);
        if (typeof onConfirm === 'function') onConfirm();
    });
    overlay.addEventListener('click', function(e) {
        if (e.target === overlay) document.body.removeChild(overlay);
    });
}

/* ─── ADMIN MOBILE BOTTOM SHEET TOGGLE ─── */
function openAdminBottomSheet() {
    var sheet = document.getElementById('adminMobMenuSheet');
    var backdrop = document.getElementById('adminSheetBackdrop');
    if (sheet && backdrop) {
        sheet.classList.add('show');
        backdrop.classList.add('show');
        document.body.style.overflow = 'hidden';
    }
}
function closeAdminBottomSheet() {
    var sheet = document.getElementById('adminMobMenuSheet');
    var backdrop = document.getElementById('adminSheetBackdrop');
    if (sheet && backdrop) {
        sheet.classList.remove('show');
        backdrop.classList.remove('show');
        document.body.style.overflow = '';
    }
}
</script>

<?php
$curPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$adminMobActive = function($s) use ($curPath) {
    return (strpos($curPath, '/admin/'.$s) !== false) ? 'active' : '';
};
?>

<!-- ─── BOTTOM SHEET FOR ADMIN MOBILE ─── -->
<div class="sheet-backdrop" id="adminSheetBackdrop" onclick="closeAdminBottomSheet()"></div>

<div class="bottom-sheet" id="adminMobMenuSheet">
    <div class="sheet-header">
        <h3>Yönetim Menüsü</h3>
        <button class="close-sheet" onclick="closeAdminBottomSheet()"><i class="fa fa-times"></i></button>
    </div>
    <div class="sheet-body">
        <div class="sheet-menu-grid">
            <a href="<?php echo $baseUrl; ?>/admin/categories" class="sheet-menu-item">
                <i class="fa fa-tags"></i>
                <span>Kategoriler</span>
            </a>
            <a href="<?php echo $baseUrl; ?>/admin/brands" class="sheet-menu-item">
                <i class="fa fa-bookmark"></i>
                <span>Markalar</span>
            </a>
            <a href="<?php echo $baseUrl; ?>/admin/pages" class="sheet-menu-item">
                <i class="fa fa-file-text"></i>
                <span>Sayfalar</span>
            </a>
            <a href="<?php echo $baseUrl; ?>/admin/users" class="sheet-menu-item">
                <i class="fa fa-users"></i>
                <span>Kullanıcılar</span>
            </a>
            <a href="<?php echo $baseUrl; ?>/admin/theme" class="sheet-menu-item">
                <i class="fa fa-paint-brush"></i>
                <span>Tema Ayarları</span>
            </a>
            <a href="<?php echo $baseUrl; ?>/admin/settings" class="sheet-menu-item">
                <i class="fa fa-cogs"></i>
                <span>Sistem Ayarları</span>
            </a>
        </div>
    </div>
</div>

<!-- ─── MOBILE BOTTOM NAV FOR ADMIN ─── -->
<nav class="admin-mobile-nav">
    <a href="<?php echo $baseUrl; ?>/admin/dashboard" class="admin-mob-nav-item <?php echo $adminMobActive('dashboard'); ?>">
        <i class="fa fa-dashboard"></i>
        <span>Panel</span>
    </a>
    <a href="<?php echo $baseUrl; ?>/admin/products" class="admin-mob-nav-item <?php echo $adminMobActive('products'); ?>">
        <i class="fa fa-print"></i>
        <span>Ürünler</span>
    </a>
    
    <!-- Center FAB (Opens Bottom Sheet Menu on Mobile) -->
    <div class="admin-mob-nav-center">
        <button class="admin-nav-fab" onclick="openAdminBottomSheet()" aria-label="Menüyü Aç">
            <i class="fa fa-bars"></i>
        </button>
    </div>

    <a href="<?php echo $baseUrl; ?>/admin/orders" class="admin-mob-nav-item <?php echo $adminMobActive('orders'); ?>">
        <i class="fa fa-shopping-bag"></i>
        <span>Siparişler</span>
    </a>
    <a href="<?php echo $baseUrl; ?>/admin/settings" class="admin-mob-nav-item <?php echo $adminMobActive('settings'); ?>">
        <i class="fa fa-cogs"></i>
        <span>Ayarlar</span>
    </a>
</nav>

</body>
</html>