<main class="container-fluid py-4"><div class="row g-4"><div class="col-lg-3"><?php require APP_PATH.'/Views/admin/_sidebar.php'; ?></div><div class="col-lg-9">
    <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3 mb-4"><div><h1 class="h3 fw-bold text-cfc-dark mb-1">Painel Administrativo</h1><p class="text-muted mb-0">Código da administração para mensagens: <strong><?= e($currentUser['internal_code']??'---------') ?></strong></p></div><a class="btn btn-primary rounded-pill <?= !empty($unreadAudioMessages)?'audio-notification-pulse':'' ?>" href="<?= e(url('admin/messages')) ?>"><i class="bi bi-chat-dots"></i> Mensagens <?php if(!empty($unreadMessages)): ?><span class="badge text-bg-danger ms-1"><?= (int)$unreadMessages ?></span><?php endif; ?><?php if(!empty($unreadAudioMessages)): ?><span class="badge text-bg-info ms-1"><i class="bi bi-mic-fill"></i> <?= (int)$unreadAudioMessages ?></span><?php endif; ?></a></div>
    <div class="row g-3 mb-4">
        <div class="col-sm-6 col-xl-3"><a class="admin-stat-link" href="<?= e(url('admin/students')) ?>" aria-label="Abrir área de alunos"><div class="card border-0 shadow-soft rounded-4 h-100"><div class="card-body p-4"><span class="text-muted">Alunos</span><h2 class="display-6 fw-bold text-primary mb-0"><?= (int)$studentsCount ?></h2><small class="text-muted">Toque para abrir os cadastros</small></div></div></a></div>
        <div class="col-sm-6 col-xl-3"><a class="admin-stat-link" href="<?= e(url('admin/appointments')) ?>" aria-label="Abrir aulas agendadas"><div class="card border-0 shadow-soft rounded-4 h-100"><div class="card-body p-4"><span class="text-muted">Aulas agendadas</span><h2 class="display-6 fw-bold text-primary mb-0"><?= (int)$appointmentsCount ?></h2><small class="text-muted">Contadas por unidade de 50 min</small></div></div></a></div>
        <div class="col-sm-6 col-xl-3"><a class="admin-stat-link" href="<?= e(url('admin/appointments')) ?>" aria-label="Abrir histórico de aulas concluídas"><div class="card border-0 shadow-soft rounded-4 h-100"><div class="card-body p-4"><span class="text-muted">Aulas concluídas</span><h2 class="display-6 fw-bold text-success mb-0"><?= (int)($completedLessonsCount??0) ?></h2><small class="text-muted">1 ou 2 aulas confirmadas</small></div></div></a></div>
        <div class="col-sm-6 col-xl-3"><a class="admin-stat-link" href="<?= e(url('admin/theory-groups')) ?>" aria-label="Abrir grupos teóricos"><div class="card border-0 shadow-soft rounded-4 h-100"><div class="card-body p-4"><span class="text-muted">Grupos teóricos</span><h2 class="display-6 fw-bold text-dark mb-0"><?= (int)($theoryGroupsCount??0) ?></h2><small class="text-muted">Toque para gerenciar as turmas</small></div></div></a></div>
        <div class="col-sm-6 col-xl-3"><a class="admin-stat-link" href="<?= e(url('admin/payment-center')) ?>" aria-label="Abrir cobranças pendentes"><div class="card border-0 shadow-soft rounded-4 h-100"><div class="card-body p-4"><span class="text-muted">Cobranças pendentes</span><h2 class="display-6 fw-bold text-warning mb-0"><?= (int)($pendingChargesCount??0) ?></h2><small class="text-muted">Toque para abrir bancos e cobranças</small></div></div></a></div>
    </div>
    <div class="card border-0 shadow-soft rounded-4 mb-4"><div class="card-body p-4"><div class="row align-items-center g-4"><div class="col-md-8"><h2 class="h5 fw-bold mb-1"><i class="bi bi-qr-code"></i> QR Code de cadastro do aluno</h2><p class="text-muted mb-2">Deixe o candidato apontar a câmera do celular para abrir diretamente o cadastro.</p><span class="badge text-bg-light border text-dark"><?= e(url('register')) ?></span></div><div class="col-md-4 text-center"><img src="https://api.qrserver.com/v1/create-qr-code/?size=220x220&data=<?= urlencode(url('register')) ?>" alt="QR Code cadastro" width="220" height="220" class="img-fluid rounded-3 border"><small class="d-block text-muted mt-2">Cadastro do aluno</small></div></div></div></div>
    <?php if(!empty($unreadMessages)): ?><div class="alert alert-danger rounded-4 shadow-soft border-0 d-flex justify-content-between align-items-center"><span><i class="bi bi-bell-fill"></i> Existem <strong><?= (int)$unreadMessages ?></strong> mensagens novas.</span><a class="btn btn-sm btn-light rounded-pill" href="<?= e(url('admin/messages')) ?>">Abrir mensagens</a></div><?php endif; ?>
    <div class="card border-0 shadow-soft rounded-4"><div class="card-body p-4"><h2 class="h5 fw-bold mb-3">Próximos horários</h2><div class="table-responsive"><table class="table align-middle mb-0"><thead><tr><th>Data</th><th>Horário</th><th>Profissional</th><th>Status</th></tr></thead><tbody><?php foreach($upcomingSlots as $slot): ?><tr><td><?= e(date('d/m/Y',strtotime($slot['start_at']))) ?></td><td><?= e(date('H:i',strtotime($slot['start_at']))) ?></td><td><?= e($slot['professional_name']) ?></td><td><span class="badge <?= $slot['slot_status']==='livre'?'text-bg-success':'text-bg-secondary' ?>"><?= e($slot['slot_status']) ?></span></td></tr><?php endforeach; ?></tbody></table></div></div></div>
</div></div></main>
