<div class="stats-grid">
  <div class="stat-card">
    <div class="stat-icon stat-icon-gold">
      <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 22h16a2 2 0 002-2V4a2 2 0 00-2-2H8a2 2 0 00-2 2v16"/></svg>
    </div>
    <div class="stat-body">
      <span class="stat-value"><?= $stats['news'] ?></span>
      <span class="stat-label">Actualités publiées</span>
    </div>
    <a href="/admin/news" class="stat-action">Gérer →</a>
  </div>

  <div class="stat-card">
    <div class="stat-icon stat-icon-blue">
      <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/></svg>
    </div>
    <div class="stat-body">
      <span class="stat-value"><?= $stats['contacts'] ?></span>
      <span class="stat-label">Messages non lus</span>
    </div>
    <a href="/admin/contacts" class="stat-action">Voir →</a>
  </div>

  <div class="stat-card">
    <div class="stat-icon stat-icon-green">
      <svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"/></svg>
    </div>
    <div class="stat-body">
      <span class="stat-value"><?= $stats['subs'] ?></span>
      <span class="stat-label">Filiales actives</span>
    </div>
  </div>
</div>

<div class="admin-section">
  <h2 class="admin-section-title">Actions rapides</h2>
  <div class="quick-actions">
    <a href="/admin/news/new" class="quick-btn quick-btn-primary">
      <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
      Nouvelle actualité
    </a>
    <a href="/admin/settings" class="quick-btn">
      <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.07 4.93a10 10 0 010 14.14M4.93 19.07a10 10 0 010-14.14"/></svg>
      Paramètres du site
    </a>
    <a href="/" target="_blank" class="quick-btn">
      <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 014 10 15.3 15.3 0 01-4 10 15.3 15.3 0 01-4-10 15.3 15.3 0 014-10z"/></svg>
      Voir le site public
    </a>
  </div>
</div>

<?php if (!empty($recentContacts)): ?>
<div class="admin-section">
  <h2 class="admin-section-title">Derniers messages</h2>
  <div class="admin-table-wrap">
    <table class="admin-table">
      <thead>
        <tr>
          <th>Nom</th><th>Email</th><th>Sujet</th><th>Date</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($recentContacts as $c): ?>
        <tr>
          <td><?= htmlspecialchars($c['full_name']) ?></td>
          <td><a href="mailto:<?= htmlspecialchars($c['email']) ?>"><?= htmlspecialchars($c['email']) ?></a></td>
          <td><?= htmlspecialchars(mb_substr($c['subject'], 0, 50)) ?></td>
          <td><?= date('d/m/Y H:i', strtotime($c['created_at'])) ?></td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
  </div>
</div>
<?php endif; ?>
