<?php
/**
 * @var Laminas\View\Renderer\PhpRenderer $this
 * @var \Tour\Entity\Show[]               $shows
 * @var \User\Entity\User|null            $user
 */
$this->headTitle('Shows');
$isAdmin = $user && $user->getIsAdmin();

$moisFr = ['','Jan','Fév','Mar','Avr','Mai','Jun','Jul','Aoû','Sep','Oct','Nov','Déc'];
?>

<?php if ($isAdmin): ?>
<div class="d-flex justify-content-end mb-3">
    <a href="<?= $this->url('shows', ['action' => 'add']) ?>" class="btn btn-app">
        <i class="bi bi-plus-lg me-1"></i>Nouveau show
    </a>
</div>
<?php endif; ?>

<?php if (empty($shows)): ?>
<div class="card-app text-center" style="padding:var(--space-xl)">
    <i class="bi bi-calendar-x" style="font-size:2.5rem;color:var(--color-text-faint);display:block;margin-bottom:var(--space-md)"></i>
    <p class="text-muted mb-0" style="font-size:.875rem">Aucun show pour le moment.</p>
</div>
<?php else: ?>
<div class="d-flex flex-column gap-2">
    <?php foreach ($shows as $show): ?>
    <a href="<?= $this->url('shows', ['action' => 'view', 'id' => $show->getId()]) ?>" class="card-app" style="padding:var(--space-md)">
        <div class="d-flex align-items-center gap-3">
            <div class="show-date-chip flex-shrink-0">
                <span class="show-date-day"><?= $show->getDate() ? $show->getDate()->format('d') : '—' ?></span>
                <span class="show-date-month"><?= $show->getDate() ? $moisFr[(int)$show->getDate()->format('n')] : '' ?></span>
            </div>
            <div class="flex-grow-1 min-w-0">
                <div class="fw-semibold text-truncate"><?= $this->escapeHtml($show->getTitle()) ?></div>
                <div class="text-muted mt-1" style="font-size:.8rem">
                    <i class="bi bi-building me-1"></i><?= $this->escapeHtml($show->getStructure()->getName()) ?>
                    <?php if ($show->getCity()): ?> · <i class="bi bi-geo-alt"></i> <?= $this->escapeHtml($show->getCity()) ?><?php endif; ?>
                    <?php if ($show->getTour()): ?> · <i class="bi bi-music-note-list"></i> <?= $this->escapeHtml($show->getTour()->getName()) ?><?php endif; ?>
                </div>
            </div>
            <i class="bi bi-chevron-right text-muted flex-shrink-0" style="font-size:.875rem"></i>
        </div>
    </a>
    <?php endforeach; ?>
</div>
<?php endif; ?>
