<?php $title = config('app.name'); ?>

<div style="max-width:960px;margin:0 auto;padding:40px 16px;">
  <div style="text-align:center;margin-bottom:40px;">
    <h1 style="font-size:28px;font-weight:700;color:#fff;margin-bottom:6px;"><?= h(config('app.name')) ?></h1>
    <p style="font-size:14px;color:#6b7280;">Seleciona o teu evento para ver e comprar as fotografias</p>
  </div>

  <?php if(empty($events)): ?>
  <div style="text-align:center;padding:80px 0;color:#4b5563;">
    <div style="font-size:48px;margin-bottom:12px;">📷</div>
    <p>Ainda não existem eventos disponíveis.</p>
  </div>

  <?php else: ?>
  <div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px;">
    <?php foreach($events as $ev): ?>
    <a href="<?= base_url('evento/'.h($ev['slug'])) ?>"
       style="display:block;background:#111827;border-radius:16px;overflow:hidden;
              border:1px solid rgba(255,255,255,.07);transition:border-color .2s;"
       onmouseover="this.style.borderColor='rgba(99,102,241,.45)'"
       onmouseout="this.style.borderColor='rgba(255,255,255,.07)'">

      <!-- Capa -->
      <div style="aspect-ratio:16/9;background:#1f2937;overflow:hidden;">
        <?php if($ev['cover_photo']): ?>
        <img src="<?= base_url('imgs/'.$ev['cover_photo']) ?>"
             alt="<?= h($ev['name']) ?>"
             style="width:100%;height:100%;object-fit:cover;transition:transform .35s;"
             onmouseover="this.style.transform='scale(1.05)'"
             onmouseout="this.style.transform='scale(1)'"
             loading="lazy">
        <?php else: ?>
        <div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#374151;font-size:36px;">📷</div>
        <?php endif; ?>
      </div>

      <!-- Info -->
      <div style="padding:14px 16px;">
        <div style="font-weight:600;font-size:15px;color:#f9fafb;margin-bottom:6px;"><?= h($ev['name']) ?></div>
        <div style="display:flex;align-items:center;gap:12px;font-size:12px;color:#6b7280;">
          <?php if($ev['date_event']): ?>
          <span>📅 <?= date('d/m/Y',strtotime($ev['date_event'])) ?></span>
          <?php endif; ?>
          <span>📷 <?= $ev['photo_count'] ?> fotografias</span>
        </div>
      </div>
    </a>
    <?php endforeach; ?>
  </div>
  <?php endif; ?>
</div>
