<?php
include "../db.php";
$id = intval($_GET['id']);
$stmt = $pdo->prepare("SELECT * FROM categories WHERE id=?");
$stmt->execute([$id]);
$c = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$c) die("Category Not Found!");
?>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">

<style>
.card { background:#222; color:#fff; padding:20px; border-radius:10px; }
img { width:160px; border-radius:8px; border:2px solid #444; margin-top:10px; }
h3 { color:#00e6ff; }
</style>

<div class="card">
    <h3>Category Details</h3>
    <hr>

    <p><b>ID:</b> <?= $c['id'] ?></p>
    <p><b>Name:</b> <?= htmlspecialchars($c['category_name']) ?></p>

    <p><b>Image:</b><br>
        <img src="../lbfood/uploads/categories/<?= $c['image_path'] ?>">
    </p>

    <p><b>Created At:</b> <?= $c['created_at'] ?></p>

    <hr>

    <button class="btn btn-secondary"
        onclick="window.parent.loadPage('view_categories.php')">
        ← Back
    </button>

    <button class="btn btn-warning"
        onclick="window.parent.loadPage('edit_category.php?id=<?= $c['id'] ?>')">
        ✏ Edit
    </button>
</div>
