<?php $title = isset($category) ? 'Edit Category' : 'New Category'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><?= isset($category) ? 'Edit Category' : 'New Category' ?></h1>
</div>
<div class="glass-card">
    <form method="POST" action="<?= $baseUrl ?>/post-categories/<?= isset($category) ? $category->id . '/update' : 'store' ?>">
        <div class="row">
            <div class="col-md-6 form-group">
                <label style="color: rgba(255,255,255,0.7);">Name</label>
                <input type="text" name="name" class="form-control glass-input" value="<?= htmlspecialchars($category->name ?? '') ?>" required>
            </div>
            <div class="col-md-3 form-group">
                <label style="color: rgba(255,255,255,0.7);">Sort Order</label>
                <input type="number" name="sort_order" class="form-control glass-input" value="<?= htmlspecialchars($category->sort_order ?? '0') ?>">
            </div>
            <div class="col-md-3 form-group d-flex align-items-end">
                <div class="custom-control custom-checkbox mb-3">
                    <input type="checkbox" class="custom-control-input" id="is_active" name="is_active" value="1" <?= (!isset($category) || $category->is_active) ? 'checked' : '' ?>>
                    <label class="custom-control-label" for="is_active" style="color: rgba(255,255,255,0.7);">Active</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label style="color: rgba(255,255,255,0.7);">Description</label>
            <textarea name="description" class="form-control glass-input" rows="2"><?= htmlspecialchars($category->description ?? '') ?></textarea>
        </div>
        <div class="text-right">
            <a href="<?= $baseUrl ?>/post-categories" class="glass-btn mr-2">Cancel</a>
            <button type="submit" class="glass-btn glass-btn-primary"><?= isset($category) ? 'Update' : 'Create' ?></button>
        </div>
    </form>
</div>
