<?php
require_once __DIR__ . '/db.php';

// Count items in cart
$cart_count = 0;
if (isset($_SESSION['cart']) && is_array($_SESSION['cart'])) {
    foreach ($_SESSION['cart'] as $qty) {
        $cart_count += $qty;
    }
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($page_title) ? $page_title . " - Toko Kue Edelys" : "Toko Kue Edelys - Kelezatan Premium di Setiap Gigitan"; ?></title>
    <meta name="description" content="Toko Kue Edelys menyajikan berbagai pilihan kue premium, cake ulang tahun, mille crepes, dan pastry yang dibuat dari bahan-bahan berkualitas terbaik. Pesan langsung secara online.">
    <!-- Favicon -->
    <link rel="icon" type="image/png" href="assets/images/favicon.png" error-src="https://cdn-icons-png.flaticon.com/512/992/992717.png">
    <!-- CSS -->
    <link rel="stylesheet" href="assets/css/style.css">
    <!-- FontAwesome for Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <header>
        <div class="nav-container">
            <a href="index.php" class="logo">
                <span class="brand-name">Edelys<span>Cake</span></span>
            </a>
            <nav>
                <ul class="nav-links">
                    <li><a href="index.php" class="<?php echo basename($_SERVER['PHP_SELF']) == 'index.php' || basename($_SERVER['PHP_SELF']) == 'product.php' ? 'active' : ''; ?>">Katalog Kue</a></li>
                    <li>
                        <a href="cart.php" class="cart-icon <?php echo basename($_SERVER['PHP_SELF']) == 'cart.php' ? 'active' : ''; ?>">
                            <i class="fa-solid fa-basket-shopping"></i>
                            <span>Keranjang</span>
                            <?php if ($cart_count > 0): ?>
                                <span class="cart-badge"><?php echo $cart_count; ?></span>
                            <?php endif; ?>
                        </a>
                    </li>
                    <li><a href="admin/login.php" class="btn btn-secondary" style="padding: 0.4rem 1.2rem; font-size: 0.85rem; margin-left: 0.5rem;"><i class="fa-solid fa-user-gear"></i> Portal Admin</a></li>
                </ul>
            </nav>
        </div>
    </header>
