<?php
/**
 * ITSWEBER CMS – Page Builder Admin Form: Property Cards (Estate 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,#062a2a 0%,#0d4f4f 100%);border-radius:8px;padding:0.625rem 1rem;margin-bottom:1.25rem;display:flex;align-items:center;gap:0.5rem;">
    <span style="color:#c9a84c;font-size:0.75rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;">★ Estate Theme – Property Cards</span>
</div>

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

<?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:#0d4f4f;">
    Immobilien (bis zu 6)
</h5>

<?php for ($i = 0; $i < 6; $i++):
    $item = $items[$i] ?? ['title' => '', 'price' => '', 'image' => '', 'url' => '', 'badge' => '', 'features' => ''];
    $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);">
        Objekt <?= $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="property_title[]" class="form-control" value="<?= e($item['title']) ?>" placeholder="z.B. Moderne Altbauwohnung">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Preis</label>
            <input type="text" name="property_price[]" class="form-control" value="<?= e($item['price']) ?>" placeholder="z.B. 485.000 €">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Link-URL</label>
            <input type="text" name="property_url[]" class="form-control" value="<?= e($item['url']) ?>" placeholder="/immobilien/altbau-koeln">
        </div>
        <div class="form-group" style="margin:0;">
            <label class="form-label">Badge <small style="color:#aaa;">(optional)</small></label>
            <input type="text" name="property_badge[]" class="form-control" value="<?= e($item['badge']) ?>" placeholder="z.B. Neu, Top-Lage">
        </div>
        <div class="form-group" style="margin:0;grid-column:1/-1;">
            <label class="form-label">Bild-Pfad <small style="color:#aaa;">(relativ zu /uploads/)</small></label>
            <input type="text" name="property_image[]" class="form-control" value="<?= e($item['image']) ?>" placeholder="media/immobilie-1.jpg">
        </div>
        <div class="form-group" style="margin:0;grid-column:1/-1;">
            <label class="form-label">Ausstattung <small style="color:#aaa;">(kommasepariert)</small></label>
            <input type="text" name="property_features[]" class="form-control" value="<?= e($item['features']) ?>" placeholder="3 Zimmer, 85 m², Balkon, EBK">
        </div>
    </div>
</details>
<?php endfor; ?>

<?php admin_field_grid_open(2) ?>
    <?php admin_field('text', 'cta_text', 'CTA Button Text', $data['cta_text'] ?? '', [
        'placeholder' => 'Alle Objekte', 'wrap_style' => 'margin:0;',
    ]) ?>
    <?php admin_field('text', 'cta_url', 'CTA Button URL', $data['cta_url'] ?? '', [
        'placeholder' => '/immobilien', 'wrap_style' => 'margin:0;',
    ]) ?>
<?php admin_field_grid_close() ?>

<?php admin_section_separator() ?>
<?php admin_field_grid_open(2) ?>
    <?php admin_field('select', 'color_scheme', __('admin.section.color_scheme'), $data['color_scheme'] ?? '', [
        'options' => ['' => __('admin.section.scheme_default'), 'alt' => __('admin.section.scheme_alt'), 'primary' => __('admin.section.scheme_primary'), 'dark' => __('admin.section.scheme_dark')],
        'wrap_style' => 'margin:0;',
    ]) ?>
    <?php admin_field('select', 'section_text_color', __('admin.section.section_text_color'), $data['section_text_color'] ?? '', [
        'options' => ['' => __('admin.section.scheme_default'), 'black' => __('admin.section.color_black'), 'white' => __('admin.section.color_white'), 'theme' => __('admin.section.color_theme')],
        'wrap_style' => 'margin:0;',
    ]) ?>
<?php admin_field_grid_close() ?>
