<?php include __DIR__ . '/../header.php'; ?>

<div class="container-fluid py-4">

    <div class="mb-4">
        <h3 class="mb-1">
            <i class="bi bi-pencil-square me-2"></i>
            <?= __('categories.edit.title', 'Edit Category') ?>
        </h3>
        <small class="text-muted">
            <?= __('categories.edit.breadcrumb', 'Catalog → Categories → Edit') ?>
        </small>
    </div>

    <div class="card border-0 shadow-sm">
        <div class="card-body">

            <form method="post"
                  action="/admin/categories/update/<?= (int)$item['id'] ?>"
                  enctype="multipart/form-data">

                <?= \Core\System\Csrf::field(); ?>

                <div class="mb-3">
                    <label class="form-label">
                        <?= __('categories.form.name', 'Name') ?>
                    </label>
                    <input type="text" name="name" class="form-control"
                           value="<?= htmlspecialchars($item['name']) ?>" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">
                        <?= __('categories.form.slug', 'Slug') ?>
                    </label>
                    <input type="text" name="slug" class="form-control"
                           value="<?= htmlspecialchars($item['slug']) ?>">
                </div>

                <div class="mb-3">
                    <label class="form-label">
                        <?= __('categories.form.image', 'Image') ?>
                    </label><br>

                    <?php if (!empty($item['image'])): ?>
                        <img src="<?= htmlspecialchars($item['image']) ?>"
                             class="rounded mb-2"
                             style="width:120px;height:120px;object-fit:cover;">
                    <?php endif; ?>

                    <input type="file" name="image" class="form-control">
                </div>

                <div class="mb-3">
                    <label class="form-label">
                        <?= __('categories.form.status', 'Status') ?>
                    </label>
                    <select name="status" class="form-select">
                        <option value="active" <?= $item['status'] === 'active' ? 'selected' : '' ?>>
                            <?= __('common.active', 'Active') ?>
                        </option>
                        <option value="inactive" <?= $item['status'] === 'inactive' ? 'selected' : '' ?>>
                            <?= __('common.inactive', 'Inactive') ?>
                        </option>
                    </select>
                </div>

                <div class="d-flex gap-2">
                    <button class="btn btn-primary">
                        <?= __('common.update', 'Update') ?>
                    </button>
                    <a href="/admin/categories" class="btn btn-light">
                        <?= __('common.cancel', 'Cancel') ?>
                    </a>
                </div>

            </form>

        </div>
    </div>

</div>

<?php include __DIR__ . '/../footer.php'; ?>
