<?php
// Özelleştiricideki bölüm listesi. $page: home, page-ID ya da contact.
$sections = sections_of($page, false);
$sort_url = admin_url('duzen?sayfa=' . urlencode($page));
?>
<?php if ($sections): ?>
    <div data-sortable="<?= e($sort_url) ?>" class="space-y-1.5">
        <?php foreach ($sections as $section): ?>
            <?php [$type_label, $detail] = section_label($section); $info = section_type($section['type']) ?>
            <div data-id="<?= $section['id'] ?>" draggable="true" class="group flex items-center gap-2 rounded-xl border border-zinc-200 bg-white py-2 pr-2 pl-1.5 transition hover:border-zinc-300 <?= $section['status'] ? '' : 'opacity-60' ?>">
                <span class="cursor-grab px-1 text-zinc-300 active:cursor-grabbing"><?= icon('menu', 'size-4', '2') ?></span>
                <button type="button" data-edit-section="<?= $section['id'] ?>" data-section-title="<?= e($type_label) ?>" class="flex min-w-0 flex-1 items-center gap-2.5 text-left">
                    <span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-zinc-100 text-zinc-500 transition group-hover:bg-ink group-hover:text-white"><?= icon($info['icon'] ?? 'document', 'size-4') ?></span>
                    <span class="min-w-0">
                        <span class="block truncate text-[13px] font-semibold"><?= e($type_label) ?></span>
                        <span class="block truncate text-[11px] text-zinc-500"><?= e($detail ?: '—') ?></span>
                    </span>
                </button>
                <label class="relative shrink-0 cursor-pointer" title="Yayında">
                    <input type="checkbox" class="peer sr-only" data-quick="<?= e($sort_url) ?>" data-quick-action="status" data-quick-id="<?= $section['id'] ?>" <?= $section['status'] ? 'checked' : '' ?>>
                    <span class="block h-5 w-9 rounded-full bg-zinc-200 transition after:absolute after:top-0.5 after:left-0.5 after:size-4 after:rounded-full after:bg-white after:shadow after:transition peer-checked:bg-ink peer-checked:after:translate-x-4"></span>
                </label>
                <button type="button" data-section-action="duplicate" data-id="<?= $section['id'] ?>" class="rounded-md p-1 text-zinc-300 transition hover:bg-zinc-100 hover:text-ink" title="Kopyala"><?= icon('slides', 'size-4') ?></button>
                <button type="button" data-section-action="delete" data-id="<?= $section['id'] ?>" class="rounded-md p-1 text-zinc-300 transition hover:bg-rose-50 hover:text-rose-600" title="Sil"><?= icon('trash', 'size-4') ?></button>
            </div>
        <?php endforeach ?>
    </div>
<?php else: ?>
    <p class="rounded-xl border border-dashed border-zinc-200 px-4 py-8 text-center text-sm text-zinc-500">Bu sayfada henüz bölüm yok.</p>
<?php endif ?>
