<?php
declare(strict_types=1);

/**
 * @var \App\View\AppView $this
 * @var \App\Model\Entity\Teacher $teacher
 */
?>
<?php $this->assign('title', 'Add teacher · CandleCraft Admin'); ?>

<section class="cc-admin-page" style="max-width: 760px;">
    <a class="cc-msg-back" href="<?= $this->Url->build(['_name' => 'admin_teachers']) ?>">← Back to teachers</a>

    <div class="cc-eyebrow" style="margin-bottom: 12px;">Add teacher</div>
    <h1 style="font-size: 28px; font-weight: 800; margin-bottom: 24px;">New teacher</h1>

    <div class="cc-admin-form-card">
        <?= $this->Form->create($teacher) ?>
            <div class="cc-form-row">
                <div>
                    <label class="cc-label" for="full_name">Full name<span class="cc-required">*</span></label>
                    <?= $this->Form->control('full_name', ['label' => false, 'class' => 'cc-input', 'id' => 'full_name', 'required' => true]) ?>
                </div>
                <div>
                    <label class="cc-label" for="slug">Slug</label>
                    <?= $this->Form->control('slug', ['label' => false, 'class' => 'cc-input', 'id' => 'slug', 'placeholder' => 'auto-generated from name', 'required' => false]) ?>
                    <div class="cc-field-helper">URL-safe — leave blank to auto-generate.</div>
                </div>
            </div>
            <div class="cc-form-row cc-form-row--single">
                <div>
                    <label class="cc-label" for="role">Role / title<span class="cc-required">*</span></label>
                    <?= $this->Form->control('role', ['label' => false, 'class' => 'cc-input', 'id' => 'role', 'placeholder' => 'e.g. Pottery · Lead instructor', 'required' => true]) ?>
                </div>
            </div>
            <div class="cc-form-row cc-form-row--single">
                <div>
                    <label class="cc-label" for="bio">Bio<span class="cc-required">*</span></label>
                    <?= $this->Form->control('bio', ['label' => false, 'class' => 'cc-textarea', 'id' => 'bio', 'type' => 'textarea', 'rows' => 4, 'required' => true]) ?>
                </div>
            </div>
            <div class="cc-form-row">
                <div>
                    <label class="cc-label" for="specialties">Specialties</label>
                    <?= $this->Form->control('specialties', ['label' => false, 'class' => 'cc-input', 'id' => 'specialties', 'placeholder' => 'wheel throwing, glazing, beginners']) ?>
                    <div class="cc-field-helper">Comma-separated.</div>
                </div>
                <div>
                    <label class="cc-label" for="hourly_rate_cents">Rate (cents)</label>
                    <?= $this->Form->control('hourly_rate_cents', ['label' => false, 'class' => 'cc-input', 'id' => 'hourly_rate_cents', 'type' => 'number', 'value' => 6500]) ?>
                    <div class="cc-field-helper">A$ × 100. e.g. 6500 = A$65.</div>
                </div>
            </div>
            <div class="cc-form-row">
                <div>
                    <label class="cc-label" for="photo_path">Photo path</label>
                    <?= $this->Form->control('photo_path', ['label' => false, 'class' => 'cc-input', 'id' => 'photo_path', 'placeholder' => 'studio/teachers/jane.jpg']) ?>
                    <div class="cc-field-helper">Relative to /webroot/img/.</div>
                </div>
                <div>
                    <label class="cc-label" for="sort_order">Sort order</label>
                    <?= $this->Form->control('sort_order', ['label' => false, 'class' => 'cc-input', 'id' => 'sort_order', 'type' => 'number', 'value' => 100]) ?>
                </div>
            </div>
            <label class="cc-consent-box">
                <input type="hidden" name="is_active" value="0">
                <input type="checkbox" name="is_active" value="1" checked>
                <span>
                    <span class="cc-consent-box__label">Active</span>
                    <span class="cc-consent-box__helper">Visible on the public site and bookable.</span>
                </span>
            </label>
            <div style="display: flex; gap: 10px;">
                <button class="cc-btn cc-btn--primary" type="submit">Create teacher</button>
                <a class="cc-btn cc-btn--ghost" href="<?= $this->Url->build(['_name' => 'admin_teachers']) ?>">Cancel</a>
            </div>
        <?= $this->Form->end() ?>
    </div>
</section>
