<?= $this->extend('layouts/admin') ?>

<?= $this->section('content') ?>

<div style="min-height: 100vh;">
        <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px;">
            <div>
                <h2 style="margin-bottom: 5px;">Welcome Back!</h2>
                <p style="color: var(--text-muted);">Here is what is happening with your projects today.</p>
            </div>
            <div style="display: flex; gap: 15px;">
                <a href="<?= base_url('admin/project_add') ?>" class="btn btn-primary"><i class="bi bi-plus-lg"></i> New Project</a>
            </div>
        </div>

        <div class="stats-grid" style="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px;">
            <div class="admin-card" style="padding: 25px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 150px;">
                <h4 style="color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Total Projects</h4>
                <div style="font-size: 2.8rem; font-weight: 800; color: var(--primary); line-height: 1;"><?= $project_count ?></div>
            </div>
            <div class="admin-card" style="padding: 25px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 150px;">
                <h4 style="color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Active Services</h4>
                <div style="font-size: 2.8rem; font-weight: 800; color: #3498db; line-height: 1;"><?= $service_count ?></div>
            </div>
            <div class="admin-card" style="padding: 25px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 150px;">
                <h4 style="color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Pending Enquiries</h4>
                <div style="font-size: 2.8rem; font-weight: 800; color: #2ecc71; line-height: 1;">0</div>
            </div>
            <div class="admin-card" style="padding: 25px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 150px; cursor: pointer;" onclick="location.href='<?= base_url('admin/attendance') ?>'">
                <h4 style="color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Pending Attendance</h4>
                <div style="font-size: 2.8rem; font-weight: 800; color: #f1c40f; line-height: 1;"><?= $attendance_count ?></div>
            </div>

        </div>

        <div class="admin-card">
            <table class="admin-table">
                <thead>
                    <tr>
                        <th>Project Name</th>
                        <th>Status</th>
                        <th>Budget</th>
                        <th>Start Date</th>
                        <th style="text-align: right;">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($projects as $project): ?>
                        <tr>
                            <td style="font-weight: 600;"><?= $project['title'] ?></td>
                            <td>
                                <span class="status-badge status-<?= strtolower(str_replace(' ', '-', $project['status'])) ?>">
                                    <?= $project['status'] ?>
                                </span>
                            </td>
                            <td>₹<?= number_format($project['budget'], 2) ?></td>

                            <td style="color: var(--text-muted); font-size: 0.9rem;"><?= date('M d, Y', strtotime($project['start_date'])) ?></td>
                            <td style="text-align: right;">
                                <div style="display: flex; gap: 8px; justify-content: flex-end;">
                                    <a href="#" class="btn-action edit" title="Edit"><i class="bi bi-pencil-square"></i></a>
                                    <a href="#" class="btn-action delete" title="Delete"><i class="bi bi-trash-fill"></i></a>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
