<?php use function App\Core\e; $section = 'artist-basvurulari'; ?>
<div class="panel zpanel zpanel-app">
    <?php require BASE_PATH . '/app/Views/zpanel/_sidebar.php'; ?>
    <section class="panel-body zpanel-main" data-zpanel-page>
        <div class="zpanel-head"><div><p class="eyebrow">ZPanel</p><h1>Artist Basvurulari</h1><p class="muted">Zalorox Artist Connect onay ve ret islemleri.</p></div></div>
        <form class="zpanel-filters" method="get">
            <input name="q" value="<?= e($_GET['q'] ?? '') ?>" placeholder="Sanatci, slug veya kullanici ara">
            <select name="status"><option value="">Tum durumlar</option><?php foreach (['pending','approved','rejected'] as $status): ?><option value="<?= e($status) ?>" <?= ($_GET['status'] ?? '') === $status ? 'selected' : '' ?>><?= e($status) ?></option><?php endforeach; ?></select>
            <button class="pill primary">Filtrele</button>
        </form>
        <section class="zpanel-card"><div class="table-scroll"><table class="zpanel-table">
            <thead><tr><th>Sanatci</th><th>Kullanici</th><th>Status</th><th>Hak Onayi</th><th>Not</th><th>Aksiyon</th></tr></thead><tbody>
            <?php foreach (($artists ?? []) as $artist): ?>
                <tr>
                    <td><strong><?= e($artist['artist_name'] ?? '-') ?></strong><span class="muted block">@<?= e($artist['slug'] ?? '') ?></span></td>
                    <td><?= e($artist['username'] ?? '-') ?><span class="muted block"><?= e($artist['email'] ?? '') ?></span></td>
                    <td><span class="status-pill status-<?= e($artist['status'] ?? '') ?>"><?= e($artist['status'] ?? '-') ?></span></td>
                    <td><?= !empty($artist['rights_confirmed_at']) ? e($artist['rights_confirmed_at']) : 'Yok' ?></td>
                    <td><?= e($artist['rejection_reason'] ?? '') ?></td>
                    <td class="action-row">
                        <form data-zpanel-form action="/api/zpanel/artists/approve" method="post" data-confirm="Artist onaylansin mi?"><input type="hidden" name="_csrf" value="<?= e($csrfToken ?? '') ?>"><input type="hidden" name="id" value="<?= e($artist['id'] ?? '') ?>"><button type="submit">Onayla</button></form>
                        <form data-zpanel-form action="/api/zpanel/artists/reject" method="post" data-confirm="Artist reddedilsin mi?"><input type="hidden" name="_csrf" value="<?= e($csrfToken ?? '') ?>"><input type="hidden" name="id" value="<?= e($artist['id'] ?? '') ?>"><input name="reason" placeholder="Red notu"><button type="submit">Reddet</button></form>
                    </td>
                </tr>
            <?php endforeach; ?>
            <?php if (empty($artists)): ?><tr><td colspan="6">Artist basvurusu bulunamadi.</td></tr><?php endif; ?>
            </tbody></table></div></section>
    </section>
</div>
