<?php require_once __DIR__ . '/../layout/header.php'; ?>

<div class="container">
    <?php if (empty($class)): ?>
        <p class="notice">Class not found.</p>
    <?php else: ?>
        <h2>Edit Image — <?= htmlspecialchars($class['name']) ?></h2>

        <div class="current-image" style="margin:12px 0">
              <img src="<?= htmlspecialchars($class['image'] ?? \Tshen\asset('uploads/classes/default-class.jpg')) ?>"
                 alt="Current image" style="max-width:360px;border:1px solid #ddd;padding:6px;">
        </div>

        <form method="post" action="<?= \Tshen\url('/classes/update-image') ?>" enctype="multipart/form-data">
            <input type="hidden" name="id" value="<?= (int)($class['id'] ?? 0) ?>">
            <label for="image">Choose new image (jpg, png, gif)</label><br>
            <input type="file" id="image" name="image" accept="image/*" required><br><br>
            <button type="submit">Upload Image</button>
            <a href="<?= \Tshen\url('/classes') ?>" style="margin-left:12px">Cancel</a>
        </form>
    <?php endif; ?>
</div>

<?php require_once __DIR__ . '/../layout/footer.php'; ?>
