<?= $this->extend('layouts/dashboard') ?>

<?= $this->section('content') ?>
    <div class="space-y-6">
        <section class="page-header">
            <div>
                <p class="page-kicker">Academy Groups</p>
                <h2 class="section-title text-2xl"><?= esc($pageTitle) ?></h2>
                <p class="section-copy mt-2 max-w-3xl"><?= esc($pageDescription) ?></p>
            </div>
        </section>

        <form method="post" action="<?= esc($submitUrl) ?>" class="surface-card p-6">
            <div class="grid gap-5 md:grid-cols-2 xl:grid-cols-3">
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Nume grupa</label>
                    <input type="text" name="name" class="form-input" value="<?= esc((string) $values['name']) ?>">
                    <?php if (! empty($errors['name'])) : ?><p class="field-error"><?= esc($errors['name']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Cod</label>
                    <input type="text" name="code" class="form-input" value="<?= esc((string) $values['code']) ?>">
                    <?php if (! empty($errors['code'])) : ?><p class="field-error"><?= esc($errors['code']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Nivel</label>
                    <select name="academy_level_id" class="form-select">
                        <option value="">Selecteaza nivelul</option>
                        <?php foreach ($levelOptions as $option) : ?>
                            <option value="<?= esc((string) $option['id']) ?>" <?= (string) $values['academy_level_id'] === (string) $option['id'] ? 'selected' : '' ?>><?= esc($option['name']) ?></option>
                        <?php endforeach; ?>
                    </select>
                    <?php if (! empty($errors['academy_level_id'])) : ?><p class="field-error"><?= esc($errors['academy_level_id']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Trainer principal</label>
                    <select name="primary_coach_id" class="form-select">
                        <option value="">Selecteaza trainerul</option>
                        <?php foreach ($coachOptions as $option) : ?>
                            <option value="<?= esc((string) $option['id']) ?>" <?= (string) $values['primary_coach_id'] === (string) $option['id'] ? 'selected' : '' ?>><?= esc($option['full_name']) ?></option>
                        <?php endforeach; ?>
                    </select>
                    <?php if (! empty($errors['primary_coach_id'])) : ?><p class="field-error"><?= esc($errors['primary_coach_id']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Program</label>
                    <input type="text" name="schedule_summary" class="form-input" value="<?= esc((string) $values['schedule_summary']) ?>" placeholder="Mon & Wed, 17:00">
                    <?php if (! empty($errors['schedule_summary'])) : ?><p class="field-error"><?= esc($errors['schedule_summary']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Capacitate</label>
                    <input type="number" name="capacity" class="form-input" value="<?= esc((string) $values['capacity']) ?>" min="1" max="40">
                    <?php if (! empty($errors['capacity'])) : ?><p class="field-error"><?= esc($errors['capacity']) ?></p><?php endif; ?>
                </div>
                <div>
                    <label class="mb-2 block text-sm font-medium text-slate-700">Status</label>
                    <select name="status" class="form-select">
                        <option value="active" <?= (string) $values['status'] === 'active' ? 'selected' : '' ?>>Activ</option>
                        <option value="inactive" <?= (string) $values['status'] === 'inactive' ? 'selected' : '' ?>>Inactiv</option>
                    </select>
                    <?php if (! empty($errors['status'])) : ?><p class="field-error"><?= esc($errors['status']) ?></p><?php endif; ?>
                </div>
            </div>
            <div class="mt-6 flex flex-wrap gap-3">
                <button type="submit" class="btn-primary">Salveaza</button>
                <a href="<?= esc($cancelUrl) ?>" class="btn-secondary">Renunta</a>
            </div>
        </form>
    </div>
<?= $this->endSection() ?>
