refactor(archive): redesign segmented archive experience

This commit is contained in:
2026-04-14 15:09:25 +02:00
parent 297f63c7d5
commit ab1d8bc677
6 changed files with 1108 additions and 232 deletions
+5 -3
View File
@@ -5,7 +5,7 @@ declare(strict_types=1);
$brandSubtitle = match ($page) {
'dashboard' => 'Statistiken und Verlauf',
'track' => 'Tag erfassen und bewerten',
'archive' => 'Rückblick auf vergangene Tage',
'archive' => '',
'options' => 'Logik, Erinnerungen, Sicherheit und Accounts',
'login' => 'Geschützter Zugang',
'setup' => 'Erstkonfiguration',
@@ -36,7 +36,7 @@ $brandSubtitle = match ($page) {
<link rel="stylesheet" href="/assets/css/app.css">
<script defer src="/assets/js/app.js"></script>
</head>
<body class="app-body page-<?= e($page) ?><?= $authUser !== null ? ' is-authenticated' : '' ?>" data-authenticated="<?= $authUser !== null ? '1' : '0' ?>"<?= isset($trackMood) ? ' data-track-mood="' . e($trackMood) . '"' : '' ?>>
<body class="app-body page-<?= e($page) ?><?= $authUser !== null ? ' is-authenticated' : '' ?><?= !empty($pageBodyClass) ? ' ' . e((string) $pageBodyClass) : '' ?>" data-authenticated="<?= $authUser !== null ? '1' : '0' ?>"<?= isset($trackMood) ? ' data-track-mood="' . e($trackMood) . '"' : '' ?>>
<div class="aurora aurora-one"></div>
<div class="aurora aurora-two"></div>
<div class="pull-refresh-indicator glass-panel" data-pull-refresh-indicator aria-hidden="true">Zum Aktualisieren ziehen</div>
@@ -89,7 +89,9 @@ $brandSubtitle = match ($page) {
<?php if ($authUser !== null): ?>
<header class="topbar glass-panel">
<div>
<p class="eyebrow"><?= e($brandSubtitle) ?></p>
<?php if ($brandSubtitle !== ''): ?>
<p class="eyebrow"><?= e($brandSubtitle) ?></p>
<?php endif; ?>
<h2><?= e($pageTitle) ?></h2>
</div>
<div class="topbar__meta">
+273 -207
View File
@@ -1,232 +1,298 @@
<section class="page-grid">
<article class="glass-panel archive-list">
<div class="section-head">
<div>
<p class="eyebrow">Archiv</p>
<h3>KI-Rückblicke und gespeicherte Tage</h3>
</div>
<span class="chart-chip"><?= e((string) count($entries)) ?> Einträge</span>
<?php
$baseParams = ['view' => $archiveView];
if ($archiveFilterMonth !== '') {
$baseParams['filter_month'] = $archiveFilterMonth;
}
$archiveUrl = static function (array $params = []) use ($baseParams): string {
$query = array_filter(array_merge($baseParams, $params), static fn (mixed $value): bool => $value !== null && $value !== '');
return $query === [] ? '/archive' : '/archive?' . http_build_query($query);
};
$detailType = $selectedEntry !== null
? 'day'
: ($selectedWeek !== null
? 'week'
: ($selectedMonth !== null ? 'month' : null));
$detailOpen = $detailType !== null;
?>
<section class="archive-page">
<article class="glass-panel archive-shell">
<div class="archive-toolbar archive-toolbar--compact">
<nav class="archive-switcher" aria-label="Archivansicht">
<a class="archive-switcher__item <?= $archiveView === 'days' ? 'active' : '' ?>" href="<?= e('/archive?view=days' . ($archiveFilterMonth !== '' ? '&filter_month=' . rawurlencode($archiveFilterMonth) : '')) ?>">Tage</a>
<a class="archive-switcher__item <?= $archiveView === 'weeks' ? 'active' : '' ?>" href="<?= e('/archive?view=weeks' . ($archiveFilterMonth !== '' ? '&filter_month=' . rawurlencode($archiveFilterMonth) : '')) ?>">Wochen</a>
<a class="archive-switcher__item <?= $archiveView === 'months' ? 'active' : '' ?>" href="<?= e('/archive?view=months' . ($archiveFilterMonth !== '' ? '&filter_month=' . rawurlencode($archiveFilterMonth) : '')) ?>">Monate</a>
</nav>
<form method="get" action="/archive" class="archive-filter">
<input type="hidden" name="view" value="<?= e($archiveView) ?>">
<label>
<span>Zeitraum</span>
<select name="filter_month" onchange="this.form.submit()">
<option value="">Alle Monate</option>
<?php foreach ($archiveMonthOptions as $monthOption): ?>
<option value="<?= e($monthOption) ?>" <?= $archiveFilterMonth === $monthOption ? 'selected' : '' ?>><?= e(month_label($monthOption)) ?></option>
<?php endforeach; ?>
</select>
</label>
</form>
</div>
<section class="archive-summary-section">
<div class="section-head section-head--compact">
<div>
<p class="eyebrow">KI</p>
<h4>Monatszusammenfassungen</h4>
</div>
<?php if (empty($aiAvailable)): ?>
<span class="chart-chip chart-chip--muted">API nicht bereit</span>
<div class="archive-workspace">
<section class="archive-main">
<?php if ($archiveView === 'days'): ?>
<div class="archive-list-header">
<div>
<p class="eyebrow">Tage</p>
<h4>Gespeicherte Tage</h4>
</div>
<span class="chart-chip"><?= e((string) count($entries)) ?> Tage</span>
</div>
<?php if ($entries === []): ?>
<p class="empty-state">Für diesen Zeitraum gibt es noch keine getrackten Tage.</p>
<?php else: ?>
<div class="archive-rows">
<?php foreach ($entries as $entry): ?>
<a class="archive-row archive-row--day <?= $selectedEntry !== null && $selectedEntry['date'] === $entry['date'] ? 'active' : '' ?>" href="<?= e($archiveUrl(['date' => $entry['date'], 'week' => null, 'month_key' => null])) ?>">
<div class="archive-row__main">
<strong><?= e(format_compact_date($entry['date'])) ?></strong>
<span><?= e($entry['evaluation']['label']) ?></span>
</div>
<div class="archive-row__meta">
<span><?= e(format_points((float) $entry['evaluation']['total'])) ?> Punkte</span>
<span>Stimmung <?= e((string) $entry['mood']) ?>/10</span>
</div>
<span class="archive-row__hint">Ansehen</span>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php elseif ($archiveView === 'weeks'): ?>
<div class="archive-list-header">
<div>
<p class="eyebrow">Wochen</p>
<h4>Wöchentliche KI-Rückblicke</h4>
</div>
<span class="chart-chip"><?= e((string) count($weeklyArchive)) ?> Wochen</span>
</div>
<?php if ($weeklyArchive === []): ?>
<p class="empty-state">Für diesen Zeitraum sind noch keine Wochen im Archiv vorhanden.</p>
<?php else: ?>
<div class="archive-rows archive-rows--summary">
<?php foreach ($weeklyArchive as $week): ?>
<a class="archive-row archive-row--summary archive-row--week <?= $selectedWeek !== null && $selectedWeek['summary_key'] === $week['summary_key'] ? 'active' : '' ?>" href="<?= e($archiveUrl(['week' => $week['summary_key'], 'date' => null, 'month_key' => null])) ?>">
<div class="archive-row__main archive-row__main--week">
<div class="archive-row__title-group">
<strong><?= e($week['label']) ?></strong>
<span><?= e(format_compact_date((string) $week['date_from'])) ?> bis <?= e(format_compact_date((string) $week['date_to'])) ?></span>
</div>
<span class="status-badge status-badge--<?= e($week['status_tone']) ?>"><?= e($week['status_label']) ?></span>
</div>
<div class="archive-row__meta archive-row__meta--stack">
<span><?= e((string) $week['note_entries_count']) ?> Texteinträge</span>
<span><?= e((string) $week['tracked_days']) ?> getrackte Tage</span>
<span><?= e($week['trend_label']) ?></span>
</div>
<span class="archive-row__hint"><?= !empty($week['has_summary']) ? 'Öffnen' : 'Details' ?></span>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php else: ?>
<div class="archive-list-header">
<div>
<p class="eyebrow">Monate</p>
<h4>Monatliche KI-Rückblicke</h4>
</div>
<span class="chart-chip"><?= e((string) count($monthlyArchive)) ?> Monate</span>
</div>
<?php if ($monthlyArchive === []): ?>
<p class="empty-state">Für diesen Zeitraum sind noch keine Monatsobjekte im Archiv vorhanden.</p>
<?php else: ?>
<div class="archive-rows archive-rows--summary">
<?php foreach ($monthlyArchive as $month): ?>
<a class="archive-row archive-row--summary archive-row--month <?= $selectedMonth !== null && $selectedMonth['summary_key'] === $month['summary_key'] ? 'active' : '' ?>" href="<?= e($archiveUrl(['month_key' => $month['summary_key'], 'date' => null, 'week' => null])) ?>">
<div class="archive-row__main archive-row__main--month">
<div class="archive-row__title-group">
<strong><?= e($month['label']) ?></strong>
<span><?= e(format_compact_date((string) $month['date_from'])) ?> bis <?= e(format_compact_date((string) $month['date_to'])) ?></span>
</div>
<span class="status-badge status-badge--<?= e($month['status_tone']) ?>"><?= e($month['status_label']) ?></span>
</div>
<div class="archive-row__meta archive-row__meta--stack">
<span><?= e($month['weekly_progress_label']) ?></span>
<span><?= e((string) $month['tracked_days']) ?> getrackte Tage</span>
</div>
<span class="archive-row__hint"><?= !empty($month['has_summary']) ? 'Öffnen' : 'Details' ?></span>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</section>
<?php if ($monthlyArchive === []): ?>
<p class="empty-state">Sobald genügend Wochenzusammenfassungen vorliegen, erscheinen hier die Monatsrückblicke.</p>
<?php else: ?>
<div class="archive-summary-grid">
<?php foreach ($monthlyArchive as $month): ?>
<article class="archive-summary-card">
<div class="archive-summary-card__head">
<div>
<span class="summary-badge">KI</span>
<strong><?= e($month['label']) ?></strong>
</div>
<?php if (!empty($month['has_summary'])): ?>
<span class="chart-chip">vorhanden</span>
<?php else: ?>
<span class="chart-chip chart-chip--muted">offen</span>
<?php endif; ?>
</div>
<p class="helper-text"><?= e($month['date_from']) ?> bis <?= e($month['date_to']) ?></p>
<p class="helper-text"><?= e((string) $month['weekly_summary_count']) ?> KI-Wochenzusammenfassungen im Monat verfügbar</p>
<?php if (!empty($month['summary'])): ?>
<p class="helper-text">Erstellt am <?= e(format_display_datetime((string) $month['summary']['created_at'])) ?></p>
<aside class="archive-detail <?= $detailOpen ? 'is-open' : '' ?>" id="archive-detail-panel" data-detail-open="<?= $detailOpen ? '1' : '0' ?>">
<div class="glass-panel archive-detail__panel">
<div class="archive-detail__top">
<div>
<p class="eyebrow">Details</p>
<?php if ($detailType === 'day'): ?>
<h3><?= e(format_compact_date($selectedEntry['date'])) ?></h3>
<?php elseif ($detailType === 'week'): ?>
<h3><?= e($selectedWeek['label']) ?></h3>
<?php elseif ($detailType === 'month'): ?>
<h3><?= e($selectedMonth['label']) ?></h3>
<?php else: ?>
<p class="helper-text">Mindestens 2 KI-Wochenzusammenfassungen nötig.</p>
<h3>Archivansicht</h3>
<?php endif; ?>
</div>
<div class="archive-item__actions archive-item__actions--stack">
<?php if (!empty($month['summary'])): ?>
<a class="ghost-link archive-action" href="/archive?summary_kind=monthly&amp;summary_key=<?= e(rawurlencode((string) $month['summary_key'])) ?>">Öffnen</a>
<?php endif; ?>
<?php if ($detailOpen): ?>
<a class="ghost-link archive-detail__close" href="<?= e($archiveUrl(['date' => null, 'week' => null, 'month_key' => null])) ?>">Schließen</a>
<?php endif; ?>
</div>
<form method="post" action="/archive">
<?= csrf_field() ?>
<input type="hidden" name="form_name" value="generate_monthly_summary">
<input type="hidden" name="month_key" value="<?= e((string) $month['summary_key']) ?>">
<button class="ghost-button ghost-button--small" type="submit" <?= !$month['can_generate'] || empty($aiAvailable) ? 'disabled' : '' ?>>
<?= !empty($month['has_summary']) ? 'Neu generieren' : 'KI-Monatszusammenfassung erzeugen' ?>
</button>
</form>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<?php if ($detailType === 'day'): ?>
<p class="hero-label"><?= e($selectedEntry['evaluation']['label']) ?> · <?= e(format_points((float) $selectedEntry['evaluation']['total'])) ?> Punkte</p>
<a class="primary-button button-link" href="/track?date=<?= e(rawurlencode($selectedEntry['date'])) ?>">Diesen Tag bearbeiten</a>
<section class="archive-summary-section">
<div class="section-head section-head--compact">
<div>
<p class="eyebrow">KI</p>
<h4>Wochenzusammenfassungen</h4>
</div>
</div>
<?php if ($weeklyArchive === []): ?>
<p class="empty-state">Noch keine Wochen verfügbar. Sobald Einträge vorliegen, kannst du hier Wochenrückblicke erzeugen.</p>
<?php else: ?>
<div class="archive-summary-grid">
<?php foreach ($weeklyArchive as $week): ?>
<article class="archive-summary-card">
<div class="archive-summary-card__head">
<div>
<span class="summary-badge">KI</span>
<strong><?= e($week['label']) ?></strong>
</div>
<?php if (!empty($week['has_summary'])): ?>
<span class="chart-chip">vorhanden</span>
<?php else: ?>
<span class="chart-chip chart-chip--muted">offen</span>
<?php endif; ?>
</div>
<p class="helper-text"><?= e($week['date_from']) ?> bis <?= e($week['date_to']) ?></p>
<p class="helper-text"><?= e((string) $week['note_entries_count']) ?> Texteinträge · <?= e((string) $week['tracked_days']) ?> getrackte Tage</p>
<?php if (!empty($week['summary'])): ?>
<p class="helper-text">Erstellt am <?= e(format_display_datetime((string) $week['summary']['created_at'])) ?></p>
<?php else: ?>
<p class="helper-text">Mindestens 3 Texteinträge nötig.</p>
<dl class="detail-grid detail-grid--archive-day">
<div><dt>Stimmung</dt><dd><?= e((string) $selectedEntry['mood']) ?>/10</dd></div>
<div><dt>Energie</dt><dd><?= e((string) $selectedEntry['energy']) ?>/10</dd></div>
<div><dt>Stress</dt><dd><?= e((string) $selectedEntry['stress']) ?>/10</dd></div>
<?php if (!empty($settings['tracking']['pain_enabled'])): ?>
<div><dt>Schmerzen</dt><dd><?= e((string) $selectedEntry['pain']) ?>/10</dd></div>
<?php endif; ?>
<div><dt>Schlaf</dt><dd><?= e((string) $selectedEntry['sleep_hours']) ?> h</dd></div>
<div><dt>Schlafgefühl</dt><dd><?= e((string) $selectedEntry['sleep_feeling']) ?>/5</dd></div>
<div><dt>Sport</dt><dd><?= e((string) $selectedEntry['sport_minutes']) ?> min</dd></div>
<div><dt>Spaziergang</dt><dd><?= e(format_walk_value($selectedEntry)) ?></dd></div>
<div><dt>Alkohol</dt><dd><?= !empty($selectedEntry['alcohol']) ? 'ja' : 'nein' ?></dd></div>
</dl>
<div class="archive-item__actions archive-item__actions--stack">
<?php if (!empty($week['summary'])): ?>
<a class="ghost-link archive-action" href="/archive?summary_kind=weekly&amp;summary_key=<?= e(rawurlencode((string) $week['summary_key'])) ?>">Öffnen</a>
<?php endif; ?>
<div class="note-box">
<h4>Notiz</h4>
<p><?= nl2br(e($selectedEntry['note'] !== '' ? $selectedEntry['note'] : 'Keine Notiz hinterlegt.')) ?></p>
</div>
<?php elseif ($detailType === 'week'): ?>
<p class="hero-label"><?= e(format_compact_date((string) $selectedWeek['date_from'])) ?> bis <?= e(format_compact_date((string) $selectedWeek['date_to'])) ?></p>
<div class="archive-detail__status-row">
<span class="status-badge status-badge--<?= e($selectedWeek['status_tone']) ?>"><?= e($selectedWeek['status_label']) ?></span>
<span class="chart-chip"><?= e($selectedWeek['trend_label']) ?></span>
</div>
<dl class="detail-grid detail-grid--archive">
<div><dt>Texteinträge</dt><dd><?= e((string) $selectedWeek['note_entries_count']) ?></dd></div>
<div><dt>Getrackte Tage</dt><dd><?= e((string) $selectedWeek['tracked_days']) ?></dd></div>
<?php if (!empty($selectedWeek['summary'])): ?>
<div><dt>Erstellt am</dt><dd><?= e(format_compact_datetime((string) $selectedWeek['summary']['created_at'])) ?></dd></div>
<?php endif; ?>
</dl>
<div class="note-box archive-detail__status-note">
<h4>KI-Status</h4>
<p><?= e($selectedWeek['status_hint']) ?></p>
</div>
<?php if (!empty($selectedWeek['summary'])): ?>
<div class="archive-detail__actions">
<a class="ghost-link archive-action" href="<?= e($archiveUrl(['week' => $selectedWeek['summary_key'], 'date' => null, 'month_key' => null])) ?>">Öffnen</a>
<form method="post" action="/archive">
<?= csrf_field() ?>
<input type="hidden" name="form_name" value="generate_weekly_summary">
<input type="hidden" name="week_key" value="<?= e((string) $week['summary_key']) ?>">
<button class="ghost-button ghost-button--small" type="submit" <?= !$week['can_generate'] || empty($aiAvailable) ? 'disabled' : '' ?>>
<?= !empty($week['has_summary']) ? 'Neu generieren' : 'KI-Wochenzusammenfassung erzeugen' ?>
</button>
<input type="hidden" name="view" value="weeks">
<input type="hidden" name="filter_month" value="<?= e($archiveFilterMonth) ?>">
<input type="hidden" name="week_key" value="<?= e((string) $selectedWeek['summary_key']) ?>">
<button class="ghost-button" type="submit" <?= empty($aiAvailable) ? 'disabled' : '' ?>>Neu generieren</button>
</form>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<section class="archive-summary-section">
<div class="section-head section-head--compact">
<div>
<p class="eyebrow">Tage</p>
<h4>Alle gespeicherten Tage</h4>
</div>
</div>
<?php if ($entries === []): ?>
<p class="empty-state">Noch keine Einträge vorhanden. Auf der Tracking-Seite kannst du den ersten Tag anlegen.</p>
<?php else: ?>
<div class="archive-items">
<?php foreach ($entries as $entry): ?>
<article class="archive-item <?= $selectedEntry !== null && $selectedEntry['date'] === $entry['date'] ? 'active' : '' ?>">
<div>
<strong><?= e(format_display_date($entry['date'], false)) ?></strong>
<span><?= e($entry['evaluation']['label']) ?></span>
<?php if ((int) $entry['sport_minutes'] > 0 && !empty($entry['sport_type_meta'])): ?>
<span class="sport-pill-group">
<?php foreach ($entry['sport_type_meta'] as $sportType): ?>
<span class="sport-pill">
<img src="<?= e(sport_icon_path($sportType['icon'])) ?>" alt="">
<span><?= e($sportType['label']) ?><?= !empty($sportType['location']) ? ' · ' . e(sport_location_label((string) $sportType['location'])) : '' ?></span>
</span>
<?php endforeach; ?>
</span>
<?php endif; ?>
<div class="note-box note-box--summary">
<h4>KI-Wochenzusammenfassung</h4>
<p><?= e((string) ($selectedWeek['summary']['text'] ?? '')) ?></p>
</div>
<div class="archive-item__meta">
<span><?= e(format_points((float) $entry['evaluation']['total'])) ?></span>
<span>Stimmung <?= e((string) $entry['mood']) ?>/10</span>
</div>
<div class="archive-item__actions">
<a class="ghost-link archive-action" href="/archive?date=<?= e(rawurlencode($entry['date'])) ?>">Ansehen</a>
<a class="ghost-link archive-action" href="/track?date=<?= e(rawurlencode($entry['date'])) ?>">Bearbeiten</a>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
</article>
<?php else: ?>
<form method="post" action="/archive" class="archive-detail__single-action">
<?= csrf_field() ?>
<input type="hidden" name="form_name" value="generate_weekly_summary">
<input type="hidden" name="view" value="weeks">
<input type="hidden" name="filter_month" value="<?= e($archiveFilterMonth) ?>">
<input type="hidden" name="week_key" value="<?= e((string) $selectedWeek['summary_key']) ?>">
<button class="primary-button" type="submit" <?= !$selectedWeek['can_generate'] || empty($aiAvailable) ? 'disabled' : '' ?>>KI-Wochenzusammenfassung erzeugen</button>
</form>
<?php endif; ?>
<?php elseif ($detailType === 'month'): ?>
<p class="hero-label"><?= e(format_compact_date((string) $selectedMonth['date_from'])) ?> bis <?= e(format_compact_date((string) $selectedMonth['date_to'])) ?></p>
<aside class="stack-column">
<?php if ($selectedSummary !== null): ?>
<article class="glass-panel detail-card">
<p class="eyebrow">KI-Zusammenfassung</p>
<h3><?= e($selectedSummary['title']) ?></h3>
<p class="hero-label"><?= e($selectedSummary['date_from']) ?> bis <?= e($selectedSummary['date_to']) ?></p>
<p class="helper-text">Erstellt am <?= e(format_display_datetime((string) $selectedSummary['created_at'])) ?></p>
<div class="archive-detail__status-row">
<span class="status-badge status-badge--<?= e($selectedMonth['status_tone']) ?>"><?= e($selectedMonth['status_label']) ?></span>
<span class="chart-chip"><?= e($selectedMonth['weekly_progress_label']) ?></span>
</div>
<div class="note-box note-box--summary">
<h4>Text</h4>
<p><?= e($selectedSummary['text']) ?></p>
</div>
</article>
<?php elseif ($selectedEntry !== null): ?>
<article class="glass-panel detail-card">
<p class="eyebrow">Ausgewählt</p>
<h3><?= e(format_display_date($selectedEntry['date'])) ?></h3>
<p class="hero-label"><?= e($selectedEntry['evaluation']['label']) ?> · <?= e(format_points((float) $selectedEntry['evaluation']['total'])) ?> Punkte</p>
<a class="primary-button button-link" href="/track?date=<?= e(rawurlencode($selectedEntry['date'])) ?>">Diesen Tag bearbeiten</a>
<dl class="detail-grid">
<div><dt>Stimmung</dt><dd><?= e((string) $selectedEntry['mood']) ?>/10</dd></div>
<div><dt>Energie</dt><dd><?= e((string) $selectedEntry['energy']) ?>/10</dd></div>
<div><dt>Stress</dt><dd><?= e((string) $selectedEntry['stress']) ?>/10</dd></div>
<?php if (!empty($settings['tracking']['pain_enabled'])): ?>
<div><dt>Schmerzen</dt><dd><?= e((string) $selectedEntry['pain']) ?>/10</dd></div>
<?php endif; ?>
<div><dt>Schlaf</dt><dd><?= e((string) $selectedEntry['sleep_hours']) ?> h</dd></div>
<div><dt>Schlafgefühl</dt><dd><?= e((string) $selectedEntry['sleep_feeling']) ?>/5</dd></div>
<div><dt>Sport</dt><dd><?= e((string) $selectedEntry['sport_minutes']) ?> min</dd></div>
<div>
<dt>Sportarten</dt>
<dd>
<?php if ((int) $selectedEntry['sport_minutes'] > 0 && !empty($selectedEntry['sport_type_meta'])): ?>
<span class="sport-pill-group sport-pill-group--inline">
<?php foreach ($selectedEntry['sport_type_meta'] as $sportType): ?>
<span class="sport-pill sport-pill--inline">
<img src="<?= e(sport_icon_path($sportType['icon'])) ?>" alt="">
<span><?= e($sportType['label']) ?><?= !empty($sportType['location']) ? ' · ' . e(sport_location_label((string) $sportType['location'])) : '' ?></span>
</span>
<?php endforeach; ?>
</span>
<?php else: ?>
keine
<dl class="detail-grid detail-grid--archive">
<div><dt>KI-Wochen vorhanden</dt><dd><?= e((string) $selectedMonth['weekly_summary_count']) ?> / <?= e((string) ((int) $selectedMonth['weekly_total_count'])) ?></dd></div>
<?php if (!empty($selectedMonth['summary'])): ?>
<div><dt>Erstellt am</dt><dd><?= e(format_compact_datetime((string) $selectedMonth['summary']['created_at'])) ?></dd></div>
<?php endif; ?>
</dd>
</div>
<div><dt>Sportbonus</dt><dd><?= e(format_points((float) ($selectedEntry['evaluation']['components']['sport_bonus'] ?? 0))) ?></dd></div>
<div><dt>Spaziergang</dt><dd><?= e(format_walk_value($selectedEntry)) ?></dd></div>
<div><dt>Alkohol</dt><dd><?= !empty($selectedEntry['alcohol']) ? 'ja' : 'nein' ?></dd></div>
</dl>
</dl>
<div class="note-box">
<h4>Notiz</h4>
<p><?= nl2br(e($selectedEntry['note'] !== '' ? $selectedEntry['note'] : 'Keine Notiz hinterlegt.')) ?></p>
<div class="note-box archive-detail__status-note">
<h4>Monatsstatus</h4>
<p><?= e($selectedMonth['status_hint']) ?></p>
</div>
<div class="note-box archive-detail__week-status">
<h4>Wochen in diesem Monat</h4>
<div class="archive-mini-list">
<?php foreach ($selectedMonth['weeks'] as $week): ?>
<div class="archive-mini-list__row">
<span><?= e($week['label']) ?></span>
<span class="status-badge status-badge--<?= !empty($week['has_summary']) ? 'ready' : 'blocked' ?>"><?= !empty($week['has_summary']) ? 'vorhanden' : 'fehlt' ?></span>
</div>
<?php endforeach; ?>
</div>
</div>
<?php if (!empty($selectedMonth['summary'])): ?>
<div class="archive-detail__actions">
<a class="ghost-link archive-action" href="<?= e($archiveUrl(['month_key' => $selectedMonth['summary_key'], 'date' => null, 'week' => null])) ?>">Öffnen</a>
<form method="post" action="/archive">
<?= csrf_field() ?>
<input type="hidden" name="form_name" value="generate_monthly_summary">
<input type="hidden" name="view" value="months">
<input type="hidden" name="filter_month" value="<?= e($archiveFilterMonth) ?>">
<input type="hidden" name="month_key" value="<?= e((string) $selectedMonth['summary_key']) ?>">
<button class="ghost-button" type="submit" <?= empty($aiAvailable) ? 'disabled' : '' ?>>Neu generieren</button>
</form>
</div>
<div class="note-box note-box--summary">
<h4>KI-Monatszusammenfassung</h4>
<p><?= e((string) ($selectedMonth['summary']['text'] ?? '')) ?></p>
</div>
<?php else: ?>
<form method="post" action="/archive" class="archive-detail__single-action">
<?= csrf_field() ?>
<input type="hidden" name="form_name" value="generate_monthly_summary">
<input type="hidden" name="view" value="months">
<input type="hidden" name="filter_month" value="<?= e($archiveFilterMonth) ?>">
<input type="hidden" name="month_key" value="<?= e((string) $selectedMonth['summary_key']) ?>">
<button class="primary-button" type="submit" <?= !$selectedMonth['can_generate'] || empty($aiAvailable) ? 'disabled' : '' ?>>KI-Monatszusammenfassung erzeugen</button>
</form>
<?php endif; ?>
<?php else: ?>
<p class="helper-text">Wähle links einen Tag, eine Woche oder einen Monat aus.</p>
<?php endif; ?>
</div>
</article>
<?php else: ?>
<article class="glass-panel detail-card">
<p class="eyebrow">Details</p>
<h3>Archivansicht</h3>
<p>Wähle links einen Tag oder eine KI-Zusammenfassung aus. Wochenrückblicke benötigen mindestens 3 Texteinträge, Monatsrückblicke mindestens 2 vorhandene KI-Wochenzusammenfassungen.</p>
</article>
<?php endif; ?>
</aside>
</aside>
</div>
</article>
</section>