<?php /* Matches list — open chat for messages (compact, separate) */ require __DIR__.'/../layouts/header.php'; ?>
<div class="section-head">
  <div class="eyebrow">Inbox</div>
  <h1>Messages & matches</h1>
  <p>Tap a match to chat. Unread counts show on the right.</p>
</div>

<div class="spark-bar">
  <div class="spark-ico">💬</div>
  <div>
    <strong>Keep the vibe going</strong>
    <span>Reply within a day — conversations that start fast tend to stick.</span>
  </div>
</div>

<div class="list">
<?php foreach ($matches as $m): ?>
  <a class="match" href="<?= url('chat?user=' . (int)$m['partner_id']) ?>">
    <div class="mini-avatar">
      <?php if (!empty($m['photo'])): ?><img src="<?= url($m['photo']) ?>" alt=""><?php else: ?>V<?php endif; ?>
    </div>
    <div class="match-info">
      <b><?= e($m['partner_name']) ?></b>
      <p><?php if (!empty($m['last_message'])): ?><?= e(mb_substr($m['last_message'], 0, 60)) ?><?php else: ?>Say hello · matched <?= e(date('M j', strtotime($m['created_at']))) ?><?php endif; ?></p>
    </div>
    <?php if (!empty($m['unread'])): ?><span class="count"><?= (int)$m['unread'] ?></span><?php else: ?><span class="muted" style="font-size:11px">›</span><?php endif; ?>
  </a>
<?php endforeach; ?>
</div>

<?php if (!$matches): ?>
  <div class="empty panel">
    <h2>No matches yet</h2>
    <p>When you both like each other, they show up here.</p>
    <a class="btn" href="<?= url('discovery') ?>">Start discovering</a>
  </div>
<?php else: ?>
  <p class="muted" style="text-align:center;margin-top:16px;font-size:12px">Long-press isn’t needed — open a chat for unmatch, block or report.</p>
<?php endif; ?>
<?php require __DIR__.'/../layouts/footer.php'; ?>
