<div id="tab-overview" class="tab-content">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h4 class="fw-bold mb-1">Dashboard Administrator</h4>
            <p class="text-muted mb-0">Ringkasan sistem dan statistik platform</p>
        </div>
        <div class="d-flex gap-2">
            <div class="dropdown">
                <button class="btn btn-outline-primary d-flex align-items-center gap-2" type="button" data-bs-toggle="dropdown">
                    <i data-lucide="calendar" width="16"></i>
                    Bulan Ini
                    <i data-lucide="chevron-down" width="16"></i>
                </button>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="#">Hari Ini</a></li>
                    <li><a class="dropdown-item" href="#">Minggu Ini</a></li>
                    <li><a class="dropdown-item" href="#">Bulan Ini</a></li>
                    <li><a class="dropdown-item" href="#">Tahun Ini</a></li>
                </ul>
            </div>
            <button class="btn btn-primary d-flex align-items-center gap-2" onclick="location.reload()">
                <i data-lucide="refresh-cw" width="16"></i>
                Refresh
            </button>
        </div>
    </div>

    <!-- Stats Cards -->
    <div class="row g-3 mb-4">
        <div class="col-md-3">
            <div class="stat-card total-users p-4">
                <div class="d-flex align-items-center gap-3">
                    <div class="stat-icon bg-primary bg-opacity-10 text-primary">
                        <i data-lucide="users" width="20"></i>
                    </div>
                    <div class="flex-grow-1">
                        <h4 class="fw-bold mb-0"><?php echo number_format($admin_stats['total_users']); ?></h4>
                        <small class="text-muted">Total Pengguna</small>
                        <!-- <span class="growth-badge bg-primary bg-opacity-10 text-primary ms-2">
                            <?php // echo $admin_stats['growth_users']; ?>
                        </span> -->
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card total-members p-4">
                <div class="d-flex align-items-center gap-3">
                    <div class="stat-icon bg-success bg-opacity-10 text-success">
                        <i data-lucide="user-check" width="20"></i>
                    </div>
                    <div class="flex-grow-1">
                        <h4 class="fw-bold mb-0"><?php echo number_format($admin_stats['total_members']); ?></h4>
                        <small class="text-muted">Total Anggota</small>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card total-seminars p-4">
                <div class="d-flex align-items-center gap-3">
                    <div class="stat-icon bg-warning bg-opacity-10 text-warning">
                        <i data-lucide="calendar" width="20"></i>
                    </div>
                    <div class="flex-grow-1">
                        <h4 class="fw-bold mb-0"><?php echo number_format($admin_stats['total_seminars']); ?></h4>
                        <small class="text-muted">Total Seminar</small>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card total-income p-4">
                <div class="d-flex align-items-center gap-3">
                    <div class="stat-icon bg-info bg-opacity-10 text-info">
                        <i data-lucide="dollar-sign" width="24"></i>
                    </div>
                    <div class="flex-grow-1">
                        <div class="income-display mb-0">Rp <?php echo number_format($admin_stats['total_income'], 0, ',', '.'); ?></div>
                        <small class="text-muted">Total Pendapatan</small>
                        <!-- <span class="growth-badge bg-info bg-opacity-10 text-info ms-2">
                            <?php // echo $admin_stats['growth_income']; ?>
                        </span>
                        -->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Additional Stats -->
    <div class="row g-3 mb-4">
        <div class="col-md-3">
            <div class="stat-card p-4">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h4 class="fw-bold mb-0"><?php echo number_format($admin_stats['total_seminar_participants']); ?></h4>
                        <small class="text-muted">Total Peserta</small>
                    </div>
                    <div class="stat-icon bg-secondary bg-opacity-10 text-secondary">
                        <i data-lucide="users" width="20"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card p-4">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h4 class="fw-bold mb-0"><?php echo $admin_stats['active_seminars']; ?></h4>
                        <small class="text-muted">Seminar Aktif</small>
                    </div>
                    <div class="stat-icon bg-success bg-opacity-10 text-success">
                        <i data-lucide="activity" width="20"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card p-4">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h4 class="fw-bold mb-0"><?php echo $admin_stats['expired']; ?></h4>
                        <small class="text-muted">Anggota Expired</small>
                    </div>
                    <div class="stat-icon bg-warning bg-opacity-10 text-warning">
                        <i data-lucide="clock" width="20"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card p-4">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h4 class="fw-bold mb-0 income-today">Rp <?php echo number_format($admin_stats['revenue_month'], 0, ',', '.'); ?></h4>
                        <small class="text-muted">Pendapatan Bulan Ini</small>
                    </div>
                    <div class="stat-icon bg-info bg-opacity-10 text-info">
                        <i data-lucide="trending-up" width="20"></i>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Charts and Tables -->
    <div class="row g-4">
        <div class="col-lg-8">
            <div class="card p-4">
                <h5 class="fw-bold mb-4">Statistik Pengguna</h5>
                <div class="chart-container">
                    <canvas id="userGrowthChart"></canvas>
                </div>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="card p-4 h-100">
                <h5 class="fw-bold mb-4">Pengguna Baru</h5>
                <div class="d-flex flex-column gap-3">
                    <?php foreach($new_users as $user): ?>
                    <div class="d-flex align-items-center gap-3">
                        <div class="stat-icon bg-primary bg-opacity-10 text-primary">
                            <i data-lucide="user" width="18"></i>
                        </div>
                        <div class="flex-grow-1">
                            <h6 class="fw-bold mb-0 small"><?php echo htmlspecialchars($user['name']); ?></h6>
                            <small class="text-muted"><?php echo htmlspecialchars($user['email']); ?></small>
                        </div>
                        <div class="text-end">
                            <small class="text-muted d-block"><?php echo $user['joined']; ?></small>
                            <span class="badge <?php echo $user['type'] == 'Anggota' ? 'bg-success' : 'bg-secondary'; ?>">
                                <?php echo $user['type']; ?>
                            </span>
                        </div>
                    </div>
                    <?php endforeach; ?>
                    <a href="?menu=users" class="btn btn-outline-primary btn-sm">Lihat Semua Pengguna</a>
                </div>
            </div>
        </div>
    </div>

    <!-- Active Seminars Table -->
    <div class="card mt-4">
        <div class="p-4">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h5 class="fw-bold mb-0">Seminar Aktif</h5>
                <a href="?menu=seminars" class="text-primary text-decoration-none small">Lihat Semua</a>
            </div>
            <div class="table-responsive">
                <table class="table table-admin">
                    <thead>
                        <tr>
                            <th>Nama Seminar</th>
                            <th>Tanggal</th>
                            <th>Peserta</th>
                            <th>Pendapatan</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach($active_seminars as $seminar): ?>
                        <tr>
                            <td><?php echo htmlspecialchars($seminar['title']); ?></td>
                            <td><?php echo date('d M Y', strtotime($seminar['date'])); ?></td>
                            <td><?php echo number_format($seminar['participants']); ?></td>
                            <td class="fw-bold text-success">Rp <?php echo number_format($seminar['income'], 0, ',', '.'); ?></td>
                            <td>
                                <a href="?menu=seminars" class="btn btn-sm btn-outline-primary">Kelola</a>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>