<?php require __DIR__ . '/../../layouts/header.php'; ?>
<?php $item = $row ?? []; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="fw-bold mb-0"><?= e(trans('proceedings_book')) ?> — <?= e(current_lang() === 'ar' ? (string) $conference['title_ar'] : (string) $conference['title_en']) ?></h1>
    <a href="<?= e(base_path('admin')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
</div>

<div class="ec-card   mb-4"><div class="ec-card-body">
<form method="get" action="<?= e(base_path('admin/proceedings-book/edit')) ?>" class="row g-3">
<div class="col-md-6"><label class="form-label"><?= e(trans('conference')) ?></label><select name="conference_id" class="form-select rounded-3"><?php foreach ($conferences as $c): ?><option value="<?= e((string) $c['id']) ?>" <?= ((int) $conference['id'] === (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-2 d-flex align-items-end"><button class="btn ec-btn btn-primary rounded-3 w-100"><?= e(trans('search')) ?></button></div>
</form></div></div>

<div class="ec-card  "><div class="ec-card-body p-4">
<form method="post" action="<?= e(base_path('admin/proceedings-book/edit?conference_id=' . (int) $conference['id'])) ?>">
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
<input type="hidden" name="conference_id" value="<?= e((string) $conference['id']) ?>">

<div class="row g-3">
<div class="col-md-6"><label class="form-label"><?= e(trans('title_en')) ?></label><input type="text" name="title_en" class="form-control rounded-3" value="<?= e((string) ($item['title_en'] ?? '')) ?>" required></div>
<div class="col-md-6"><label class="form-label"><?= e(trans('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">ISBN Print</label><input type="text" name="isbn_print" class="form-control rounded-3" value="<?= e((string) ($item['isbn_print'] ?? '')) ?>"></div>
<div class="col-md-6"><label class="form-label">ISBN Online</label><input type="text" name="isbn_online" class="form-control rounded-3" value="<?= e((string) ($item['isbn_online'] ?? '')) ?>"></div>
<div class="col-md-6"><label class="form-label">Editor EN</label><input type="text" name="editor_en" class="form-control rounded-3" value="<?= e((string) ($item['editor_en'] ?? '')) ?>"></div>
<div class="col-md-6"><label class="form-label">Editor AR</label><input type="text" name="editor_ar" class="form-control rounded-3" value="<?= e((string) ($item['editor_ar'] ?? '')) ?>"></div>
<div class="col-md-6"><label class="form-label">Preface EN</label><textarea name="preface_en" class="form-control rounded-3 richtext" rows="8"><?= e((string) ($item['preface_en'] ?? '')) ?></textarea></div>
<div class="col-md-6"><label class="form-label">Preface AR</label><textarea name="preface_ar" class="form-control rounded-3 richtext" rows="8"><?= e((string) ($item['preface_ar'] ?? '')) ?></textarea></div>
<div class="col-md-12"><label class="form-label">Cover Image</label><input type="text" name="cover_image" class="form-control rounded-3" value="<?= e((string) ($item['cover_image'] ?? '')) ?>"></div>
<div class="col-md-12"><div class="form-check"><input class="form-check-input" type="checkbox" name="is_published" <?= !empty($item['is_published']) ? 'checked' : '' ?>><label class="form-check-label"><?= e(trans('published_count')) ?></label></div></div>
</div>

<div class="mt-4 d-flex gap-2 flex-wrap">
<button type="submit" class="btn ec-btn btn-success rounded-3"><?= e(trans('save')) ?></button>
<a href="<?= e(base_path('conference/proceedings?slug=' . urlencode((string) $conference['slug']))) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('proceedings')) ?></a>
</div>
</form></div></div>
<?php require __DIR__ . '/../../layouts/footer.php'; ?>
