<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-12">
            <h4 class="mb-0">Selamat Datang, <?php echo $this->session->userdata('nama'); ?>!</h4>
            <small class="text-muted">Dashboard Administrator</small>
        </div>
    </div>

    <!-- Statistik Cards -->
    <div class="row g-3 mb-4">
        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Total Warga</small>
                            <h3 class="mb-0"><?php echo number_format($total_warga); ?></h3>
                        </div>
                        <div class="bg-primary bg-opacity-10 rounded p-3">
                            <i class="bi bi-people-fill fs-2 text-primary"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Iuran Bulan Ini</small>
                            <h3 class="mb-0">Rp <?php echo number_format($total_iuran_bulan_ini, 0, ',', '.'); ?></h3>
                        </div>
                        <div class="bg-success bg-opacity-10 rounded p-3">
                            <i class="bi bi-cash-stack fs-2 text-success"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Tunggakan</small>
                            <h3 class="mb-0 text-danger">Rp <?php echo number_format($total_tunggakan, 0, ',', '.'); ?></h3>
                        </div>
                        <div class="bg-danger bg-opacity-10 rounded p-3">
                            <i class="bi bi-exclamation-triangle-fill fs-2 text-danger"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-3">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Saldo Kas</small>
                            <h3 class="mb-0 text-info">Rp <?php echo number_format($saldo_kas, 0, ',', '.'); ?></h3>
                        </div>
                        <div class="bg-info bg-opacity-10 rounded p-3">
                            <i class="bi bi-bank fs-2 text-info"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Info -->
    <div class="row g-3">
        <div class="col-md-6">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h6 class="mb-0">
                        <i class="bi bi-file-text me-2"></i>Permohonan Surat Pending
                    </h6>
                </div>
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-grow-1">
                            <p class="mb-0">Total surat yang menunggu diproses</p>
                        </div>
                        <div class="text-end">
                            <h2 class="mb-0 text-warning"><?php echo $surat_pending; ?></h2>
                            <a href="<?php echo base_url('surat'); ?>" class="btn btn-sm btn-warning mt-2">
                                Lihat Detail
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h6 class="mb-0">
                        <i class="bi bi-clock-history me-2"></i>Pembayaran Iuran Terbaru
                    </h6>
                </div>
                <div class="card-body">
                    <?php if(!empty($pembayaran_terbaru)): ?>
                        <div class="list-group list-group-flush">
                            <?php foreach($pembayaran_terbaru as $p): ?>
                            <div class="list-group-item px-0">
                                <div class="d-flex justify-content-between">
                                    <div>
                                        <strong><?php echo $p->nama_lengkap; ?></strong>
                                        <br>
                                        <small class="text-muted"><?php echo $p->nama_iuran; ?></small>
                                    </div>
                                    <div class="text-end">
                                        <strong class="text-success">Rp <?php echo number_format($p->nominal, 0, ',', '.'); ?></strong>
                                        <br>
                                        <small class="text-muted"><?php echo date('d/m/Y', strtotime($p->tanggal_bayar)); ?></small>
                                    </div>
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    <?php else: ?>
                        <p class="text-muted text-center mb-0">Belum ada pembayaran hari ini</p>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>