<?php
/**
 * ITSWEBER CMS – Page Builder Admin Form: Events Preview
 * Loaded via AJAX into section cards.
 *
 * @author  Benny Weber
 * @copyright ITSWEBER, www.itsweber.de
 *
 * @var array $data    Decoded JSON content
 * @var array $section DB row (id, section_type, instance_label, ...)
 */
?>

<?php admin_field('text', 'title', __('admin.section.heading'), $data['title'] ?? '', [
    'placeholder' => __('admin.section.events_ph_title'),
]) ?>

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

<?php admin_field('number', 'count', __('admin.section.preview_count'), (int)($data['count'] ?? 3), [
    'hint'  => __('admin.section.preview_hint_count'),
    'attrs' => 'min="1" max="12" style="width:100px;"',
]) ?>

<?php admin_field('text', 'cta_text', __('admin.section.cta_text'), $data['cta_text'] ?? '', [
    'placeholder' => __('admin.section.events_ph_cta'),
    'hint'        => __('admin.section.leave_blank_to_hide'),
]) ?>

<?php admin_field('text', 'cta_url', __('admin.section.cta_url'), $data['cta_url'] ?? '', [
    'placeholder' => '/events',
]) ?>

<?php admin_field('checkbox', 'show_image', __('admin.section.events_show_images'), !empty($data['show_image']), [
    'checkbox_label' => __('admin.section.events_show_images'),
]) ?>

<p class="form-hint">
    <?= __('admin.section.events_hint_manage') ?> <a href="<?= admin_url('events') ?>" target="_blank">Events &rarr;</a>
</p>

<?php admin_section_separator() ?>

<?php admin_field_grid_open(2) ?>
    <?php admin_color_scheme_field($data['color_scheme'] ?? '', true) ?>
    <?php render_section_text_color_field($data) ?>
    <?php admin_field('select', 'text_align', __('admin.section.text_align'), $data['text_align'] ?? '', [
        'options'    => ['' => __('admin.section.align_default'), 'left' => __('admin.section.align_left')],
        'wrap_style' => 'margin:0;',
    ]) ?>
<?php admin_field_grid_close() ?>
