<style>
.reset-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.reset-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 24px 28px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px rgba(30, 41, 59, 0.25);
}

.reset-header h4 {
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.reset-header p {
    margin: 8px 0 0 0;
    opacity: 0.85;
    font-size: 0.95rem;
}

/* Alert Box */
.alert-security {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.alert-security i {
    color: #d97706;
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-security strong {
    color: #92400e;
    display: block;
    margin-bottom: 4px;
}

.alert-security ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
    color: #78350f;
    font-size: 0.9rem;
}

/* Cards Grid */
.reset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Individual Reset Cards */
.reset-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.reset-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.reset-card-header {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.reset-card-header i {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* Color variants */
.card-danger .reset-card-header { background: #fef2f2; }
.card-danger .reset-card-header i { background: #fee2e2; color: #dc2626; }
.card-danger .btn-reset { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.card-warning .reset-card-header { background: #fff7ed; }
.card-warning .reset-card-header i { background: #ffedd5; color: #ea580c; }
.card-warning .btn-reset { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }

.card-info .reset-card-header { background: #eff6ff; }
.card-info .reset-card-header i { background: #dbeafe; color: #2563eb; }
.card-info .btn-reset { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }

.card-success .reset-card-header { background: #f0fdf4; }
.card-success .reset-card-header i { background: #dcfce7; color: #16a34a; }
.card-success .btn-reset { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }

.card-purple .reset-card-header { background: #faf5ff; }
.card-purple .reset-card-header i { background: #f3e8ff; color: #9333ea; }
.card-purple .btn-reset { background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%); }

.card-dark .reset-card-header { background: #f8fafc; }
.card-dark .reset-card-header i { background: #e2e8f0; color: #475569; }
.card-dark .btn-reset { background: linear-gradient(135deg, #64748b 0%, #475569 100%); }

.reset-card-header h5 {
    margin: 0;
    font-weight: 600;
    color: #1e293b;
    font-size: 1.1rem;
}

.reset-card-header small {
    display: block;
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 2px;
}

.reset-card-body {
    padding: 20px;
}

.stat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.9rem;
}

.stat-list .stat-label {
    color: #64748b;
}

.stat-list .stat-value {
    font-weight: 600;
    color: #334155;
}

.btn-reset {
    width: 100%;
    border: none;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-reset:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0.95;
}

/* Total Reset Card - Special */
.reset-total-card {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 50%, #b91c1c 100%);
    color: white;
    border-radius: 16px;
    padding: 28px;
    margin-top: 24px;
    box-shadow: 0 20px 25px -5px rgba(127, 29, 29, 0.25), 0 10px 10px -5px rgba(127, 29, 29, 0.1);
}

.reset-total-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.reset-total-header i {
    font-size: 3rem;
    opacity: 0.9;
}

.reset-total-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.reset-total-header p {
    margin: 4px 0 0 0;
    opacity: 0.85;
    font-size: 0.95rem;
}

.reset-total-body {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.reset-total-body .form-label {
    color: #fecaca;
    font-weight: 500;
    margin-bottom: 8px;
}

.reset-total-body .form-control {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
}

.reset-total-body .form-control::placeholder {
    color: rgba(255,255,255,0.5);
}

.reset-total-body .form-control:focus {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    color: white;
    box-shadow: 0 0 0 0.2rem rgba(255,255,255,0.15);
}

.btn-reset-total {
    background: white;
    color: #991b1b;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    width: 100%;
    margin-top: 16px;
    transition: all 0.2s;
}

.btn-reset-total:hover {
    background: #fee2e2;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* Modal Styles */
.modal-reset .modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
}

.modal-reset .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
}

.modal-reset .modal-header.danger {
    background: #fef2f2;
    color: #991b1b;
}

.modal-reset .modal-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-reset .modal-body {
    padding: 24px;
}

.modal-reset .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    gap: 10px;
}

.password-input-group {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #64748b;
    z-index: 10;
}

/* Protected Badge */
.protected-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dcfce7;
    color: #166534;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 8px;
}

/* Empty State */
.empty-data {
    text-align: center;
    color: #94a3b8;
    padding: 12px;
    font-style: italic;
    font-size: 0.9rem;
}
</style>

<div>

    <!-- Header -->
    <div class="reset-header">
        <h4><i class="bi bi-exclamation-triangle-fill"></i> Reset Data Sistem</h4>
        <p>Halaman ini digunakan untuk menghapus data secara massal. Gunakan dengan sangat hati-hati. Data yang dihapus <strong>TIDAK DAPAT DIKEMBALIKAN</strong>.</p>
    </div>

    <!-- Security Alert -->
    <div class="alert-security">
        <i class="bi bi-shield-lock-fill"></i>
        <div>
            <strong>Keamanan Data Admin</strong>
            <span>Sistem akan secara otomatis melindungi:</span>
            <ul>
                <li>Akun dengan role <strong>Admin, Ketua RT, Sekretaris, Bendahara</strong></li>
                <li>User dengan <strong>ID = 1</strong> (Default Administrator)</li>
                <li>Data Master: Jenis Iuran, Jenis Pinjaman, Jenis Surat, Master Kas</li>
                <li>Pengaturan RT dan Konfigurasi Sistem</li>
            </ul>
        </div>
    </div>

    <!-- Reset Cards Grid -->
    <div class="reset-grid">

        <!-- Card 1: Warga & User -->
        <div class="reset-card card-danger">
            <div class="reset-card-header">
                <i class="bi bi-people-fill"></i>
                <div>
                    <h5>Data Warga & User</h5>
                    <small>Hapus semua data warga, KK, dan user non-admin</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-person"></i> Warga</span>
                        <span class="stat-value"><?php echo number_format($statistik['warga']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-people"></i> KK</span>
                        <span class="stat-value"><?php echo number_format($statistik['kk']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-person-x"></i> User Non-Admin</span>
                        <span class="stat-value"><?php echo number_format($statistik['user_non_admin']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-shield-check"></i> Admin Safe</span>
                        <span class="stat-value" style="color: #16a34a;">✓ Protected</span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-shield-fill-check"></i> Admin & Petugas Dilindungi</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="warga_user" data-title="Reset Data Warga & User" 
                        data-desc="Semua data warga, kartu keluarga, dan user non-admin akan dihapus permanen.">
                    <i class="bi bi-trash3-fill"></i> Reset Warga & User
                </button>
            </div>
        </div>

        <!-- Card 2: Keuangan -->
        <div class="reset-card card-warning">
            <div class="reset-card-header">
                <i class="bi bi-cash-stack"></i>
                <div>
                    <h5>Data Keuangan</h5>
                    <small>Tabungan, Pinjaman, Transaksi Kas, dan Angsuran</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-piggy-bank"></i> Tabungan</span>
                        <span class="stat-value"><?php echo number_format($statistik['tabungan']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-credit-card"></i> Pinjaman</span>
                        <span class="stat-value"><?php echo number_format($statistik['pinjaman']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-file-text"></i> Pengajuan</span>
                        <span class="stat-value"><?php echo number_format($statistik['pengajuan_pinjaman']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-bank"></i> Transaksi Kas</span>
                        <span class="stat-value"><?php echo number_format($statistik['transaksi_kas']); ?></span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-info-circle"></i> Master Kas direset ke Saldo Awal</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="keuangan" data-title="Reset Data Keuangan" 
                        data-desc="Semua data tabungan, pinjaman, angsuran, dan transaksi kas akan dihapus. Saldo Master Kas akan direset ke nilai awal.">
                    <i class="bi bi-trash3-fill"></i> Reset Keuangan
                </button>
            </div>
        </div>

        <!-- Card 3: Iuran -->
        <div class="reset-card card-info">
            <div class="reset-card-header">
                <i class="bi bi-receipt"></i>
                <div>
                    <h5>Data Iuran & Pembayaran</h5>
                    <small>Pembayaran iuran, pengajuan bayar, dan riwayat</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-check-circle"></i> Pembayaran</span>
                        <span class="stat-value"><?php echo number_format($statistik['pembayaran_iuran']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-clock-history"></i> Pending</span>
                        <span class="stat-value">Auto</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-cash-coin"></i> Riwayat</span>
                        <span class="stat-value">All</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-shield"></i> Master</span>
                        <span class="stat-value" style="color: #16a34a;">Safe</span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-shield-fill-check"></i> Jenis Iuran Tetap Ada</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="iuran" data-title="Reset Data Iuran" 
                        data-desc="Semua pembayaran iuran, pengajuan bayar angsuran, dan riwayat pembayaran akan dihapus. Data master jenis iuran tidak terhapus.">
                    <i class="bi bi-trash3-fill"></i> Reset Iuran
                </button>
            </div>
        </div>

        <!-- Card 4: Inventaris -->
        <div class="reset-card card-success">
            <div class="reset-card-header">
                <i class="bi bi-box-seam"></i>
                <div>
                    <h5>Data Inventaris</h5>
                    <small>Barang inventaris, gallery foto, dan rencana pembelian</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-box"></i> Inventaris</span>
                        <span class="stat-value"><?php echo number_format($statistik['inventaris']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-images"></i> Gallery</span>
                        <span class="stat-value">Auto</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-cart-plus"></i> Rencana Beli</span>
                        <span class="stat-value">All</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-folder"></i> File</span>
                        <span class="stat-value">Manual*</span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-exclamation-circle"></i> File foto di folder uploads tidak terhapus otomatis</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="inventaris" data-title="Reset Data Inventaris" 
                        data-desc="Semua data inventaris, gallery foto, dan rencana pembelian akan dihapus dari database. File foto di server harus dihapus manual.">
                    <i class="bi bi-trash3-fill"></i> Reset Inventaris
                </button>
            </div>
        </div>

        <!-- Card 5: Arisan -->
        <div class="reset-card card-purple">
            <div class="reset-card-header">
                <i class="bi bi-gift-fill"></i>
                <div>
                    <h5>Data Arisan</h5>
                    <small>Arisan, peserta, pertemuan, iuran, dan pemenang</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-calendar-event"></i> Arisan</span>
                        <span class="stat-value"><?php echo number_format($statistik['arisan']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-people-fill"></i> Peserta</span>
                        <span class="stat-value">All</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-award"></i> Pemenang</span>
                        <span class="stat-value">All</span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-cash"></i> Iuran</span>
                        <span class="stat-value">All</span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-info-circle"></i> Semua data arisan terkait akan dihapus</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="arisan" data-title="Reset Data Arisan" 
                        data-desc="Semua data arisan, peserta, pertemuan, iuran arisan, dan riwayat pemenang akan dihapus permanen.">
                    <i class="bi bi-trash3-fill"></i> Reset Arisan
                </button>
            </div>
        </div>

        <!-- Card 6: Administrasi -->
        <div class="reset-card card-dark">
            <div class="reset-card-header">
                <i class="bi bi-file-earmark-text-fill"></i>
                <div>
                    <h5>Data Administrasi</h5>
                    <small>Permohonan surat, pengumuman, dan pengaduan</small>
                </div>
            </div>
            <div class="reset-card-body">
                <ul class="stat-list">
                    <li>
                        <span class="stat-label"><i class="bi bi-envelope"></i> Surat</span>
                        <span class="stat-value"><?php echo number_format($statistik['permohonan_surat']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-megaphone"></i> Pengumuman</span>
                        <span class="stat-value"><?php echo number_format($statistik['pengumuman']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-chat-left-text"></i> Pengaduan</span>
                        <span class="stat-value"><?php echo number_format($statistik['pengaduan']); ?></span>
                    </li>
                    <li>
                        <span class="stat-label"><i class="bi bi-shield"></i> Master</span>
                        <span class="stat-value" style="color: #16a34a;">Safe</span>
                    </li>
                </ul>
                <span class="protected-badge"><i class="bi bi-shield-fill-check"></i> Jenis Surat Tetap Ada</span>
                <button type="button" class="btn-reset mt-3" data-bs-toggle="modal" data-bs-target="#modalReset" 
                        data-type="administrasi" data-title="Reset Data Administrasi" 
                        data-desc="Semua permohonan surat, pengumuman, dan pengaduan akan dihapus. Data master jenis surat tidak terhapus.">
                    <i class="bi bi-trash3-fill"></i> Reset Administrasi
                </button>
            </div>
        </div>

    </div>

    <!-- Log Aktivitas (Smaller) -->
    <div class="reset-card card-dark" style="max-width: 400px;">
        <div class="reset-card-header">
            <i class="bi bi-clock-history"></i>
            <div>
                <h5>Log Aktivitas</h5>
                <small>Hapus riwayat log sistem</small>
            </div>
        </div>
        <div class="reset-card-body">
            <ul class="stat-list" style="grid-template-columns: 1fr;">
                <li>
                    <span class="stat-label"><i class="bi bi-list-ul"></i> Total Log</span>
                    <span class="stat-value"><?php echo number_format($statistik['log_aktivitas']); ?></span>
                </li>
            </ul>
            <button type="button" class="btn-reset" data-bs-toggle="modal" data-bs-target="#modalReset" 
                    data-type="log" data-title="Reset Log Aktivitas" 
                    data-desc="Semua log aktivitas sistem akan dihapus. Tindakan ini tidak mempengaruhi data lain.">
                <i class="bi bi-trash3-fill"></i> Reset Log
            </button>
        </div>
    </div>

    <!-- TOTAL RESET SECTION -->
    <div class="reset-total-card">
        <div class="reset-total-header">
            <i class="bi bi-exclamation-octagon-fill"></i>
            <div>
                <h3>🚨 RESET TOTAL SISTEM 🚨</h3>
                <p>Hapus SEMUA data kecuali akun admin dan master data. Ini adalah tombol nuklir!</p>
            </div>
        </div>
        
        <div class="reset-total-body">
            <form action="<?php echo base_url('reset/reset_total'); ?>" method="POST" id="formResetTotal">
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Konfirmasi Password Admin</label>
                        <div class="password-input-group">
                            <input type="password" name="password_confirm" class="form-control" placeholder="Masukkan password Anda" required>
                            <i class="bi bi-eye-slash password-toggle" onclick="togglePassword(this)"></i>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Ketik "RESET TOTAL DATA"</label>
                        <input type="text" name="konfirmasi_total" class="form-control" placeholder="RESET TOTAL DATA" required 
                               pattern="RESET TOTAL DATA" title="Ketik persis: RESET TOTAL DATA">
                    </div>
                </div>
                <button type="submit" class="btn-reset-total" onclick="return confirm('ANDA YAKIN? INI TIDAK BISA DIBATALKAN!')">
                    <i class="bi bi-radioactive"></i> EKSEKUSI RESET TOTAL
                </button>
            </form>
        </div>
    </div>

</div>

<!-- Modal Konfirmasi Reset -->
<div class="modal fade modal-reset" id="modalReset" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header danger">
                <h5 class="modal-title">
                    <i class="bi bi-exclamation-triangle-fill"></i>
                    <span id="modalTitle">Konfirmasi Reset</span>
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <form method="POST" action="" id="formReset">
                <div class="modal-body">
                    <div class="alert alert-warning d-flex align-items-center gap-2">
                        <i class="bi bi-exclamation-circle-fill fs-4"></i>
                        <div>
                            <strong>Perhatian!</strong> Tindakan ini <strong>PERMANEN</strong> dan tidak dapat dibatalkan.
                        </div>
                    </div>
                    
                    <p class="text-muted" id="modalDesc">Deskripsi reset akan muncul di sini...</p>
                    
                    <div class="mb-3">
                        <label class="form-label fw-bold">Masukkan Password Admin untuk Konfirmasi</label>
                        <div class="password-input-group">
                            <input type="password" name="password_confirm" class="form-control form-control-lg" 
                                   placeholder="Password Anda" required style="padding-right: 40px;">
                            <i class="bi bi-eye-slash password-toggle" onclick="togglePassword(this)"></i>
                        </div>
                        <div class="form-text text-danger">
                            <i class="bi bi-shield-lock"></i> Password diperlukan untuk keamanan
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-light" data-bs-dismiss="modal">
                        <i class="bi bi-x-circle"></i> Batal
                    </button>
                    <button type="submit" class="btn btn-danger">
                        <i class="bi bi-trash3-fill"></i> Ya, Reset Data
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
// Toggle password visibility
function togglePassword(icon) {
    const input = icon.previousElementSibling;
    if (input.type === 'password') {
        input.type = 'text';
        icon.classList.remove('bi-eye-slash');
        icon.classList.add('bi-eye');
    } else {
        input.type = 'password';
        icon.classList.remove('bi-eye');
        icon.classList.add('bi-eye-slash');
    }
}

// Modal configuration
document.addEventListener('DOMContentLoaded', function() {
    const modalReset = document.getElementById('modalReset');
    const formReset = document.getElementById('formReset');
    
    modalReset.addEventListener('show.bs.modal', function(event) {
        const button = event.relatedTarget;
        const type = button.getAttribute('data-type');
        const title = button.getAttribute('data-title');
        const desc = button.getAttribute('data-desc');
        
        // Set content
        document.getElementById('modalTitle').textContent = title;
        document.getElementById('modalDesc').textContent = desc;
        
        // Set form action
        const baseUrl = '<?php echo base_url(); ?>';
        const actions = {
            'warga_user': 'reset/reset_warga_user',
            'keuangan': 'reset/reset_keuangan',
            'iuran': 'reset/reset_iuran',
            'inventaris': 'reset/reset_inventaris',
            'arisan': 'reset/reset_arisan',
            'administrasi': 'reset/reset_administrasi',
            'log': 'reset/reset_log'
        };
        
        formReset.action = baseUrl + actions[type];
    });
    
    // Reset form when modal closes
    modalReset.addEventListener('hidden.bs.modal', function() {
        formReset.reset();
    });
});
</script>