<?php
$isEdit = !empty($video);
$pageTitle = $isEdit ? 'Edit Video' : 'Tambah Video';
$action = $isEdit ? APP_URL . '/admin/galeri-video/' . $video['id'] : APP_URL . '/admin/galeri-video';
?>
<?php require BASE_PATH . '/app/Views/admin/layouts/header.php'; ?>

<div class="page-head">
  <h2><?= $isEdit ? 'Edit Video' : 'Tambah Video Baru' ?></h2>
  <a href="<?= APP_URL ?>/admin/galeri-video" class="btn btn-secondary">Kembali</a>
</div>

<div class="card" style="max-width:640px;">
  <form method="POST" action="<?= $action ?>">
    <?= \App\Core\Csrf::field() ?>

    <div class="form-group">
      <label for="judul">Judul Video</label>
      <input type="text" id="judul" name="judul" class="form-control" required
             value="<?= htmlspecialchars($video['judul'] ?? '') ?>">
    </div>

    <div class="form-group">
      <label for="url_video">URL YouTube</label>
      <input type="url" id="url_video" name="url_video" class="form-control" required
             value="<?= htmlspecialchars($video['url_video'] ?? '') ?>" placeholder="https://www.youtube.com/watch?v=...">
      <p class="hint">Tempel link video YouTube biasa — thumbnail akan diambil otomatis.</p>
    </div>

    <div class="form-group">
      <label for="deskripsi">Deskripsi</label>
      <textarea id="deskripsi" name="deskripsi" class="form-control" rows="3"><?= htmlspecialchars($video['deskripsi'] ?? '') ?></textarea>
    </div>

    <button type="submit" class="btn"><?= $isEdit ? 'Simpan Perubahan' : 'Tambah Video' ?></button>
  </form>
</div>

<?php require BASE_PATH . '/app/Views/admin/layouts/footer.php'; ?>
