<?php
// Fetch site settings for sidebar
try {
    $stmt = db()->query("SELECT key_name, key_value FROM settings WHERE key_name IN ('site_name', 'site_logo')");
    $sidebar_settings = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
} catch (Exception $e) {
    $sidebar_settings = [];
}
$s_name = $sidebar_settings['site_name'] ?? '豪软后台';
$s_logo = $sidebar_settings['site_logo'] ?? '../assets/pasted-20260208-082111-302e08e2.png';
?>
<div class="py-4 text-center">
    <div class="d-flex align-items-center justify-content-center mb-2 px-3">
        <img src="<?php echo $s_logo; ?>" alt="Logo" style="height: 30px; width: auto; border-radius: 4px; margin-right: 8px;">
        <h5 class="mb-0 text-white fw-bold text-truncate"><?php echo $s_name; ?></h5>
    </div>
</div>
<nav class="mt-3">
    <style>
        .sidebar a { color: rgba(255,255,255,0.7); }
        .sidebar a.active { background: #0d6efd !important; color: white !important; }
        .sidebar a:hover { background: rgba(255, 255, 255, 0.1); color: white; }
        .sidebar hr { border-color: rgba(255,255,255,0.1); }
    </style>
    <a href="index.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'active' : ''; ?>">
        <i class="bi bi-speedometer2 me-2"></i> 仪表盘
    </a>
    <a href="categories.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'categories.php' ? 'active' : ''; ?>">
        <i class="bi bi-grid me-2"></i> 分类管理
    </a>
    <a href="products.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'products.php' ? 'active' : ''; ?>">
        <i class="bi bi-box-seam me-2"></i> 商品管理
    </a>
    <a href="orders.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'orders.php' ? 'active' : ''; ?>">
        <i class="bi bi-cart-check me-2"></i> 订单管理
    </a>
    <a href="settings.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'settings.php' ? 'active' : ''; ?>">
        <i class="bi bi-gear me-2"></i> 系统设置
    </a>
    <hr class="mx-3 opacity-25">
    <a href="../index.php">
        <i class="bi bi-house me-2"></i> 返回首页
    </a>
    <a href="../logout.php">
        <i class="bi bi-box-arrow-right me-2"></i> 退出登录
    </a>
</nav>
