{{--
    Modal konfirmasi aksi berbahaya (hapus, dll).
    Cara pakai:
    1. Include di layout atau halaman yang butuh: @include('partials.confirm-modal')
    2. Panggil dari tombol: onclick="confirmAction('/url/hapus', 'Yakin hapus item ini?')"
--}}
<div id="confirmModal" class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 hidden" style="backdrop-filter:blur(4px)">
    <div class="bg-white rounded-2xl shadow-2xl w-full max-w-sm p-6 text-center">
        <div class="text-5xl mb-4">⚠️</div>
        <h3 class="text-lg font-bold text-slate-800 mb-2">Konfirmasi Aksi</h3>
        <p class="text-slate-500 text-sm mb-6" id="confirmMessage">Apakah Anda yakin?</p>
        <div class="flex gap-3">
            <button onclick="closeConfirm()"
                class="flex-1 py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 font-semibold rounded-xl transition text-sm">
                Batal
            </button>
            <form id="confirmForm" method="POST" class="flex-1">
                @csrf
                @method('DELETE')
                <button type="submit"
                    class="w-full py-2.5 bg-red-500 hover:bg-red-600 text-white font-bold rounded-xl transition text-sm">
                    Ya, Hapus
                </button>
            </form>
        </div>
    </div>
</div>

<script>
function confirmAction(url, message = 'Apakah Anda yakin?') {
    document.getElementById('confirmMessage').textContent = message;
    document.getElementById('confirmForm').action = url;
    document.getElementById('confirmModal').classList.remove('hidden');
}
function closeConfirm() {
    document.getElementById('confirmModal').classList.add('hidden');
}
// Tutup jika klik di luar modal
document.getElementById('confirmModal').addEventListener('click', function(e) {
    if (e.target === this) closeConfirm();
});
</script>
