<?php $item = $row ?? null; ?>
<div class="row g-3">
    <div class="col-md-4">
        <label class="form-label ec-required"><?= e(trans('conference')) ?></label>
        <select name="conference_id" class="form-select rounded-3" required>
            <option value="0">--</option>
            <?php foreach ($conferences as $c): ?>
                <option value="<?= e((string) $c['id']) ?>" <?= ((int) ($item['conference_id'] ?? ($_GET['conference_id'] ?? 0)) === (int) $c['id']) ? 'selected' : '' ?>>
                    <?= e(current_lang() === 'ar' ? (string) $c['title_ar'] : (string) $c['title_en']) ?>
                </option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="col-md-4">
        <label class="form-label"><?= e(trans('committee_type')) ?></label>
        <select name="committee_type" class="form-select rounded-3">
            <?php foreach (['chair','co_chair','tpc','panel','organizing','scientific','other'] as $t): ?>
                <option value="<?= e($t) ?>" <?= (($item['committee_type'] ?? 'other') === $t) ? 'selected' : '' ?>><?= e($t) ?></option>
            <?php endforeach; ?>
        </select>
    </div>

    <div class="col-md-4">
        <label class="form-label"><?= e(trans('sort_order')) ?></label>
        <input type="number" name="sort_order" class="form-control rounded-3" value="<?= e((string) ($item['sort_order'] ?? 0)) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('full_name_en')) ?></label>
        <input type="text" name="full_name_en" class="form-control rounded-3" value="<?= e((string) ($item['full_name_en'] ?? '')) ?>" required>
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('full_name_ar')) ?></label>
        <input type="text" name="full_name_ar" class="form-control rounded-3" value="<?= e((string) ($item['full_name_ar'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label">Title EN</label>
        <input type="text" name="title_en" class="form-control rounded-3" value="<?= e((string) ($item['title_en'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label">Title AR</label>
        <input type="text" name="title_ar" class="form-control rounded-3" value="<?= e((string) ($item['title_ar'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('affiliation_en')) ?></label>
        <input type="text" name="affiliation_en" class="form-control rounded-3" value="<?= e((string) ($item['affiliation_en'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('affiliation_ar')) ?></label>
        <input type="text" name="affiliation_ar" class="form-control rounded-3" value="<?= e((string) ($item['affiliation_ar'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('email')) ?></label>
        <input type="email" name="email" class="form-control rounded-3" value="<?= e((string) ($item['email'] ?? '')) ?>">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('upload_image')) ?></label>
        <input type="file" name="image_file" class="form-control rounded-3" accept="image/*">
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('bio_en')) ?></label>
        <textarea name="bio_en" class="form-control rounded-3 richtext" rows="6"><?= e((string) ($item['bio_en'] ?? '')) ?></textarea>
    </div>

    <div class="col-md-6">
        <label class="form-label"><?= e(trans('bio_ar')) ?></label>
        <textarea name="bio_ar" class="form-control rounded-3 richtext" rows="6"><?= e((string) ($item['bio_ar'] ?? '')) ?></textarea>
    </div>

    <div class="col-md-12">
        <label class="form-label"><?= e(trans('current_image')) ?></label>
        <input type="hidden" name="image_path_existing" value="<?= e((string) ($item['image_path'] ?? '')) ?>">
        <?php if (!empty($item['image_path'])): ?>
            <div class="mt-2"><img src="<?= e((string) $item['image_path']) ?>" style="max-width:220px;border-radius:14px;" alt=""></div>
        <?php else: ?>
            <div class="text-muted">-</div>
        <?php endif; ?>
    </div>

    <div class="col-md-12">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" name="is_active" <?= !isset($item) || !empty($item['is_active']) ? 'checked' : '' ?>>
            <label class="form-check-label"><?= e(trans('is_active')) ?></label>
        </div>
    </div>
</div>
