<?php
/**
 * @var Laminas\View\Renderer\PhpRenderer $this
 * @var \User\Entity\User                 $user
 * @var \Tour\Entity\Show[]               $todayShows
 * @var \Tour\Entity\Show[]               $upcomingShows
 * @var \DateTimeInterface                $today
 */
$this->headTitle('J-Day');

$joursFr = ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'];
$moisFr  = ['','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'];
$todayLabel = $joursFr[(int)$today->format('w')] . ' ' . $today->format('j') . ' ' . $moisFr[(int)$today->format('n')] . ' ' . $today->format('Y');
?>

<!-- Date du jour -->
<div class="jday-date-bar">
    <i class="bi bi-calendar-check-fill"></i> <?= $todayLabel ?>
</div>

<!-- ── Widget : Aujourd'hui ──────────────────────────────────────────────── -->
<div data-jday-widget="today">

<?php if (!empty($todayShows)): ?>
<div class="jday-section-label jday-today-label mb-3">
    <i class="bi bi-dot"></i> Aujourd'hui
</div>

<?php foreach ($todayShows as $show): ?>
<div class="card-app jday-today-card mb-3">
    <div class="d-flex align-items-start gap-3">
        <div class="show-date-chip" style="min-width:52px">
            <span class="show-date-day"><?= $show->getDate()->format('H') ?>h</span>
            <span class="show-date-month"><?= $show->getDate()->format('i') ?></span>
        </div>
        <div class="flex-grow-1 min-w-0">
            <div class="fw-bold" style="font-size:1.1rem;line-height:1.2"><?= $this->escapeHtml($show->getTitle()) ?></div>
            <?php if ($show->getVenue() || $show->getCity()): ?>
            <div class="text-muted mt-1" style="font-size:.875rem">
                <i class="bi bi-geo-alt-fill me-1" style="color:var(--color-accent)"></i>
                <?php if ($show->getVenue()): ?><?= $this->escapeHtml($show->getVenue()) ?><?php endif; ?>
                <?php if ($show->getCity()): ?><?= $show->getVenue() ? ' — ' : '' ?><?= $this->escapeHtml($show->getCity()) ?><?php endif; ?>
            </div>
            <?php endif; ?>
            <?php if ($show->getTour()): ?>
            <div class="mt-2">
                <span class="badge" style="background:var(--color-accent-dim);color:var(--color-accent);font-size:.75rem">
                    <i class="bi bi-music-note-list me-1"></i><?= $this->escapeHtml($show->getTour()->getName()) ?>
                </span>
            </div>
            <?php endif; ?>
            <?php if ($show->getNotes()): ?>
            <div class="mt-2 text-muted" style="font-size:.8rem;font-style:italic"><?= $this->escapeHtml($show->getNotes()) ?></div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php endforeach; ?>

<?php else: ?>
<div class="card-app mb-4 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 aujourd'hui</p>
</div>
<?php endif; ?>

</div><!-- /data-jday-widget="today" -->

<!-- ── Widget : Cette semaine ────────────────────────────────────────────── -->
<div data-jday-widget="week">

<?php if (!empty($upcomingShows)): ?>
<div class="jday-section-label mb-2">
    <i class="bi bi-chevron-right"></i> Cette semaine
</div>
<div class="d-flex flex-column gap-2">
<?php foreach ($upcomingShows as $show): ?>
    <div class="card-app" style="padding:var(--space-md)">
        <div class="d-flex align-items-center gap-3">
            <div class="show-date-chip">
                <span class="show-date-day"><?= $show->getDate()->format('d') ?></span>
                <span class="show-date-month"><?= mb_strtoupper($show->getDate()->format('M')) ?></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" style="font-size:.8rem">
                    <?php if ($show->getCity()): ?><i class="bi bi-geo-alt"></i> <?= $this->escapeHtml($show->getCity()) ?><?php endif; ?>
                    <?php if ($show->getVenue()): ?> · <?= $this->escapeHtml($show->getVenue()) ?><?php endif; ?>
                    <?php if ($show->getDate()): ?> · <?= $show->getDate()->format('H:i') ?><?php endif; ?>
                </div>
            </div>
            <?php if ($show->getTour()): ?>
            <span class="badge flex-shrink-0" style="background:var(--color-accent-dim);color:var(--color-accent);font-size:.7rem">
                <?= $this->escapeHtml($show->getTour()->getName()) ?>
            </span>
            <?php endif; ?>
        </div>
    </div>
<?php endforeach; ?>
</div>

<?php else: ?>
<div class="jday-section-label mb-2">
    <i class="bi bi-chevron-right"></i> Cette semaine
</div>
<div class="card-app text-center" style="padding:var(--space-xl)">
    <i class="bi bi-hourglass-split" style="font-size:2rem;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 dans les 7 prochains jours</p>
</div>
<?php endif; ?>

</div><!-- /data-jday-widget="week" -->
