<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 Warga</small>
        </div>
    </div>

    <!-- Info Cards untuk Warga -->
    <div class="row g-3 mb-4">
        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100" style="border-left: 4px solid #dc3545 !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Tagihan Bulan Ini</small>
                            <h3 class="mb-0 <?php echo $tagihan_bulan_ini > 0 ? 'text-danger' : 'text-success'; ?>">
                                <?php echo $tagihan_bulan_ini; ?>
                            </h3>
                            <small class="<?php echo $tagihan_bulan_ini > 0 ? 'text-danger' : 'text-success'; ?>">
                                <?php echo $tagihan_bulan_ini > 0 ? 'Belum dibayar' : 'Sudah lunas'; ?>
                            </small>
                        </div>
                        <div class="bg-danger bg-opacity-10 rounded p-3">
                            <i class="bi bi-exclamation-circle-fill fs-2 text-danger"></i>
                        </div>
                    </div>
                    <?php if($tagihan_bulan_ini > 0): ?>
                    <a href="<?php echo base_url('iuran'); ?>" class="btn btn-sm btn-danger w-100 mt-3">
                        <i class="bi bi-credit-card me-2"></i>Bayar Sekarang
                    </a>
                    <?php endif; ?>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100" style="border-left: 4px solid #ffc107 !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Total Tunggakan</small>
                            <h3 class="mb-0 text-warning">
                                Rp <?php echo number_format($total_tunggakan, 0, ',', '.'); ?>
                            </h3>
                            <small class="text-muted">Harus segera dibayar</small>
                        </div>
                        <div class="bg-warning bg-opacity-10 rounded p-3">
                            <i class="bi bi-cash-stack fs-2 text-warning"></i>
                        </div>
                    </div>
                    <?php if($total_tunggakan > 0): ?>
                    <a href="<?php echo base_url('iuran'); ?>" class="btn btn-sm btn-warning w-100 mt-3">
                        <i class="bi bi-eye me-2"></i>Lihat Detail
                    </a>
                    <?php endif; ?>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100" style="border-left: 4px solid #0dcaf0 !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <small class="text-muted">Surat Dalam Proses</small>
                            <h3 class="mb-0 text-info"><?php echo $surat_proses; ?></h3>
                            <small class="text-muted">Menunggu diproses</small>
                        </div>
                        <div class="bg-info bg-opacity-10 rounded p-3">
                            <i class="bi bi-file-text-fill fs-2 text-info"></i>
                        </div>
                    </div>
                    <a href="<?php echo base_url('surat'); ?>" class="btn btn-sm btn-info w-100 mt-3">
                        <i class="bi bi-plus-circle me-2"></i>Ajukan Surat
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- Saldo Kas (Read Only) -->
    <div class="row g-3">
        <div class="col-12">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h6 class="mb-0">
                        <i class="bi bi-bank me-2"></i>Informasi Kas RT
                        <span class="badge bg-info ms-2">View Only</span>
                    </h6>
                </div>
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-md-6">
                            <div class="d-flex align-items-center">
                                <div class="bg-success bg-opacity-10 rounded p-3 me-3">
                                    <i class="bi bi-cash-coin fs-1 text-success"></i>
                                </div>
                                <div>
                                    <small class="text-muted">Saldo Kas RT Saat Ini</small>
                                    <h2 class="mb-0 text-success">
                                        Rp <?php echo number_format($saldo_kas, 0, ',', '.'); ?>
                                    </h2>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 text-end">
                            <a href="<?php echo base_url('kas'); ?>" class="btn btn-outline-primary">
                                <i class="bi bi-eye me-2"></i>Lihat Laporan Lengkap
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Access -->
    <div class="row g-3 mt-3">
        <div class="col-12">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h6 class="mb-0">
                        <i class="bi bi-grid-3x3-gap me-2"></i>Menu Cepat
                    </h6>
                </div>
                <div class="card-body">
                    <div class="row g-3">
                        <div class="col-md-3">
                            <a href="<?php echo base_url('iuran'); ?>" class="text-decoration-none">
                                <div class="card h-100 border-0 shadow-sm hover-card">
                                    <div class="card-body text-center">
                                        <i class="bi bi-cash-stack fs-1 text-primary mb-2"></i>
                                        <h6>Iuran Saya</h6>
                                        <small class="text-muted">Lihat & Bayar Iuran</small>
                                    </div>
                                </div>
                            </a>
                        </div>

                        <div class="col-md-3">
                            <a href="<?php echo base_url('tabungan'); ?>" class="text-decoration-none">
                                <div class="card h-100 border-0 shadow-sm hover-card">
                                    <div class="card-body text-center">
                                        <i class="bi bi-wallet2 fs-1 text-success mb-2"></i>
                                        <h6>Tabungan Saya</h6>
                                        <small class="text-muted">Cek Saldo Tabungan</small>
                                    </div>
                                </div>
                            </a>
                        </div>

                        <div class="col-md-3">
                            <a href="<?php echo base_url('pinjaman'); ?>" class="text-decoration-none">
                                <div class="card h-100 border-0 shadow-sm hover-card">
                                    <div class="card-body text-center">
                                        <i class="bi bi-cash-coin fs-1 text-warning mb-2"></i>
                                        <h6>Pinjaman Saya</h6>
                                        <small class="text-muted">Ajukan Pinjaman</small>
                                    </div>
                                </div>
                            </a>
                        </div>

                        <div class="col-md-3">
                            <a href="<?php echo base_url('pengumuman'); ?>" class="text-decoration-none">
                                <div class="card h-100 border-0 shadow-sm hover-card">
                                    <div class="card-body text-center">
                                        <i class="bi bi-megaphone-fill fs-1 text-info mb-2"></i>
                                        <h6>Pengumuman</h6>
                                        <small class="text-muted">Lihat Pengumuman</small>
                                    </div>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
.hover-card {
    transition: all 0.3s ease;
}
.hover-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15) !important;
}
</style>