<?php
/**
 * ITSWEBER CMS – Page Builder Admin Form: Course Schedule (Pulse Theme)
 *
 * @var array $data    Decoded JSON content
 * @var array $section DB row
 */
$sectionId = (int) $section['id'];
$items = $data['items'] ?? [];
?>

<div style="background:linear-gradient(135deg,#0a0a0a 0%,#1a1a1a 100%);border-radius:8px;padding:0.625rem 1rem;margin-bottom:1.25rem;display:flex;align-items:center;gap:0.5rem;">
    <span style="color:#39ff14;font-size:0.75rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;">★ Pulse Theme – Kursplan</span>
</div>

<?php admin_field('text', 'title', __('admin.section.title'), $data['title'] ?? '', [
    'placeholder' => 'z.B. Unsere Kurse',
]) ?>

<?php admin_field('text', 'subtitle', __('admin.section.subtitle'), $data['subtitle'] ?? '', [
    'placeholder' => 'Optionale Beschreibung',
    'hint' => __('admin.section.optional'),
]) ?>

<h5 style="margin:1.5rem 0 1rem;font-size:.85rem;text-transform:uppercase;letter-spacing:.06em;color:#39ff14;">
    Kurse (bis zu 6)
</h5>

<?php for ($i = 0; $i < 6; $i++):
    $item = $items[$i] ?? ['title' => '', 'description' => '', 'category' => '', 'duration' => '', 'level' => '', 'next_session' => '', 'image' => ''];
    $num = $i + 1;
?>
<details style="margin-bottom:0.75rem;border:1px solid var(--color-border, #e2e8f0);border-radius:6px;padding:0;">
    <summary style="padding:0.75rem 1rem;cursor:pointer;font-weight:600;font-size:0.875rem;color:var(--gray-700, #374151);">
        Kurs <?= $num ?><?= !empty($item['title']) ? ': ' . e($item['title'] ?? '') : '' ?>
    </summary>
    <div style="padding:0.5rem 1rem 1rem;display:grid;grid-template-columns:1fr 1fr;gap:0.5rem 1rem;">
        <div class="form-group" style="margin:0;">
            <label class="form-label">Titel</label>
            <input type="text" name="course_title[]" class="form-control" value="<?= e($item['title'] ?? '') ?>" placeholder="z.B. HIIT Bootcamp">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Kategorie (Badge)</label>
            <input type="text" name="course_category[]" class="form-control" value="<?= e($item['category'] ?? '') ?>" placeholder="z.B. Intensiv">
        </div>
        <div class="form-group" style="margin:0;grid-column:span 2;">
            <label class="form-label">Beschreibung</label>
            <textarea name="course_description[]" class="form-control" rows="2" placeholder="Kurzbeschreibung..."><?= e($item['description'] ?? '') ?></textarea>
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Dauer</label>
            <input type="text" name="course_duration[]" class="form-control" value="<?= e($item['duration'] ?? '') ?>" placeholder="z.B. 45 Min">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Level</label>
            <input type="text" name="course_level[]" class="form-control" value="<?= e($item['level'] ?? '') ?>" placeholder="z.B. Alle Level">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Naechste Session</label>
            <input type="text" name="course_next_session[]" class="form-control" value="<?= e($item['next_session'] ?? '') ?>" placeholder="z.B. Mo 07:00">
        </div>
        <div class="form-group" style="margin:0;grid-column:span 2;">
            <?php admin_media_picker('course_image[]', $item['image'] ?? '', 'Bild', 'image', '/uploads/...') ?>
        </div>
    </div>
</details>
<?php endfor; ?>

<?php admin_section_separator() ?>

<?php admin_field_grid_open(2) ?>
    <?php admin_color_scheme_field($data['color_scheme'] ?? '') ?>
    <?php render_section_text_color_field($data) ?>
<?php admin_field_grid_close() ?>
