<!-- 作りかけのプロトタイプ -->
<!DOCTYPE html>
<html lang="ja"><head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>WB-Workout - ワークアウトダッシュボード</title>
<link href="https://fonts.googleapis.com" rel="preconnect"/>
<link crossorigin="" href="https://fonts.gstatic.com/" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&amp;display=swap" rel="stylesheet"/>
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <style type="text/tailwindcss"></style>
<style type="text/tailwindcss">
        :root {
            --primary-color: #2a8fed;
            --primary-hover-color: #1e73db;
            --text-color: #111827;
            --text-muted-color: #6b7280;
            --background-color: #f9fafb;
            --card-background-color: #ffffff;
            --border-color: #e5e7eb;
        }
        body {
            font-family: 'Lexend', sans-serif;
            background-color: var(--background-color);
            color: var(--text-color);
        }
        .primary-button {
            @apply bg-[var(--primary-color)] text-white font-semibold py-2 px-4 rounded-md shadow-sm hover:bg-[var(--primary-hover-color)] transition-colors duration-300;
        }
        .nav-link.active {
          @apply text-[var(--primary-color)] font-semibold border-b-2 border-[var(--primary-color)];
        }.mobile-menu {
            @apply hidden md:hidden absolute top-full left-0 w-full bg-[var(--card-background-color)] shadow-md;
        }
        .mobile-menu.active {
            @apply block;
        }
    </style>
</head>
<body>
<div class="relative flex size-full min-h-screen flex-col group/design-root">
<div class="layout-container flex h-full grow flex-col">
<header class="flex items-center justify-between whitespace-nowrap border-b border-solid border-[var(--border-color)] bg-[var(--card-background-color)] px-4 sm:px-6 py-4 shadow-sm relative">
<div class="flex items-center gap-4">
<a class="flex items-center gap-2 text-xl md:text-2xl font-bold text-[var(--primary-color)]" href="#">
<!-- ロゴ画像をここに追加 -->
<span class="inline">WB-Workout</span>
</a>
<nav class="hidden md:flex items-center gap-6 ml-8">
<a class="nav-link text-sm font-medium text-[var(--text-muted-color)] hover:text-[var(--primary-color)] transition-colors duration-200" href="#">ホーム</a>
<a class="nav-link active text-sm font-medium transition-colors duration-200 pb-1" href="#">ダッシュボード</a>
<a class="nav-link text-sm font-medium text-[var(--text-muted-color)] hover:text-[var(--primary-color)] transition-colors duration-200" href="#">コミュニティ</a>
<a class="nav-link text-sm font-medium text-[var(--text-muted-color)] hover:text-[var(--primary-color)] transition-colors duration-200" href="#">設定</a>
</nav>
</div>
<div class="flex items-center gap-2 sm:gap-4">
<div class="relative hidden sm:block">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="h-5 w-5 text-[var(--text-muted-color)]" fill="currentColor" viewBox="0 0 256 256" xmlns="http://www.w3.org/2000/svg"><path d="M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"></path></svg>
</div>
<input class="form-input w-full max-w-xs rounded-md border-[var(--border-color)] bg-transparent pl-10 text-sm focus:border-[var(--primary-color)] focus:ring-[var(--primary-color)]" placeholder="検索..." type="search"/>
</div>
<button class="primary-button hidden sm:block">新しいワークアウト</button>
<div class="bg-center bg-no-repeat aspect-square bg-cover rounded-full size-10" style='background-image: url("{{ user.profile_image_url }}");'></div>
<!--↑ユーザプロフ画像 -->
<button class="md:hidden p-2" id="mobile-menu-button">
<svg class="h-6 w-6" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24">
<path d="M4 6h16M4 12h16m-7 6h7"></path>
</svg>
</button>
</div>
<nav class="mobile-menu" id="mobile-menu">
<a class="block px-4 py-2 text-sm text-[var(--text-muted-color)] hover:bg-gray-100" href="#">ホーム</a>
<a class="block px-4 py-2 text-sm text-[var(--primary-color)] font-semibold bg-gray-100" href="#">ダッシュボード</a>
<a class="block px-4 py-2 text-sm text-[var(--text-muted-color)] hover:bg-gray-100" href="#">コミュニティ</a>
<a class="block px-4 py-2 text-sm text-[var(--text-muted-color)] hover:bg-gray-100" href="#">設定</a>
<div class="border-t border-[var(--border-color)] px-4 py-3">
<button class="primary-button w-full">新しいワークアウト</button>
</div>
</nav>
</header>
<main class="px-4 sm:px-6 lg:px-8 py-8 flex flex-1 justify-center">
<div class="layout-content-container flex flex-col max-w-7xl w-full gap-6 md:gap-8">
<div class="flex flex-col md:flex-row md:justify-between md:items-center gap-4">
<div>
<h1 class="text-2xl sm:text-3xl font-bold tracking-tight">ワークアウトダッシュボード</h1>
<p class="text-[var(--text-muted-color)] mt-1 text-sm sm:text-base">あなたの進捗をグラフと表で確認しましょう。</p>
</div>
<!-- 開発中
<div class="flex items-center gap-2">
<button class="text-sm font-medium px-3 py-1.5 rounded-md bg-[var(--primary-color)] text-white">日別</button>
<button class="text-sm font-medium px-3 py-1.5 rounded-md bg-gray-200 text-[var(--text-muted-color)] hover:bg-gray-300">週別</button>
<button class="text-sm font-medium px-3 py-1.5 rounded-md bg-gray-200 text-[var(--text-muted-color)] hover:bg-gray-300">月別</button>
</div>
-->
</div>
<section class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 flex flex-col gap-6">
<div class="rounded-md border border-[var(--border-color)] p-4 sm:p-6 bg-[var(--card-background-color)] shadow-sm">
<h2 class="font-semibold text-lg mb-4">総リフト重量の推移</h2>
<div class="flex items-center gap-2 text-sm mb-4">
<p class="text-[var(--text-muted-color)]">過去7日間</p>
<!-- 過去7日間とあるが、筋トレしていない日は表示を省く -->
<span class="flex items-center text-green-600 font-semibold">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path clip-rule="evenodd" d="M10 17a.75.75 0 01-.75-.75V5.612L6.22 8.78a.75.75 0 01-1.06-1.06l4.25-4.25a.75.75 0 011.06 0l4.25 4.25a.75.75 0 11-1.06 1.06L10.75 5.612V16.25A.75.75 0 0110 17z" fill-rule="evenodd"></path></svg>
5%
</span>
</div>
<div class="h-52 sm:h-64 relative">
    <canvas id="totalLiftChart"></canvas>
</div>
</div>
</div>
<div class="flex flex-col gap-6">
<div class="rounded-md border border-[var(--border-color)] p-4 sm:p-6 bg-[var(--card-background-color)] shadow-sm">
<h2 class="font-semibold text-lg mb-4">ジム訪問回数</h2>
<div class="flex items-end gap-8">
<div>
<p class="text-4xl font-bold text-[var(--primary-color)]">{{ stats.gym_visits.monthly_count }}回</p>
<p class="text-[var(--text-muted-color)] text-sm mt-1">今月</p>
</div>
<div>
<p class="text-4xl font-bold text-[var(--primary-color)]">{{ stats.gym_visits.yearly_count }}回</p>
<p class="text-[var(--text-muted-color)] text-sm mt-1">今年</p>
</div>
</div>
</div>
</div>
</section>
<section>
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center mb-4 gap-4">
<h2 class="text-xl font-bold">ワークアウト履歴</h2>
</div>
<div class="overflow-x-auto rounded-md border border-[var(--border-color)] bg-[var(--card-background-color)] shadow-sm">
<table class="w-full text-sm text-left">
<thead class="bg-gray-50 border-b border-[var(--border-color)]">
<tr>
<th class="px-4 py-3 font-semibold tracking-wider" scope="col">日付</th>
<th class="px-4 py-3 font-semibold tracking-wider" scope="col">運動の種類</th>
<th class="px-4 py-3 font-semibold tracking-wider text-center" scope="col">セット数</th>
<th class="px-4 py-3 font-semibold tracking-wider hidden md:table-cell" scope="col">レップ数</th>
<th class="px-4 py-3 font-semibold tracking-wider hidden sm:table-cell" scope="col">重量 (kg)</th>
</tr>
</thead>
<tbody class="divide-y divide-[var(--border-color)]">
    {% for workout in workout_history_7times %}
    <tr class="hover:bg-gray-50">
        <td class="px-4 py-4 whitespace-nowrap font-medium">{{ workout.date.strftime('%Y-%m-%d') }}</td>
        <td class="px-4 py-4 whitespace-nowrap text-[var(--text-muted-color)]">{{ workout.type }}</td>
        <td class="px-4 py-4 whitespace-nowrap text-[var(--text-muted-color)] text-center">{{ workout.sets }}</td>
        <td class="px-4 py-4 whitespace-nowrap text-[var(--text-muted-color)] hidden md:table-cell">{{ workout.reps }}</td>
        <td class="px-4 py-4 whitespace-nowrap text-[var(--text-muted-color)] hidden sm:table-cell">{{ workout.weights_kg }}</td>
    </tr>
    {% else %}
    <tr>
        <td colspan="5" class="text-center py-8 text-[var(--text-muted-color)]">ワークアウト履歴がありません。</td>
    </tr>
    {% endfor %}
</tbody>
</table>
</div>
</section>
</div>
</main>
<footer class="border-t border-[var(--border-color)] py-6 text-center text-sm text-[var(--text-muted-color)]">
  <p>Powered by WB-Workout</p>
</footer>
</div>
</div>
<script>
    const mobileMenuButton = document.getElementById('mobile-menu-button');
    const mobileMenu = document.getElementById('mobile-menu');
    mobileMenuButton.addEventListener('click', () => {
        mobileMenu.classList.toggle('active');
    });

    const workoutData = [
        {% for workout in workout_history_7times %}
        {
            date: '{{ workout.date.strftime('%Y-%m-%d') }}',
            weight: {{ workout.weights_kg}}
        }{% if not loop.last %},{% endif %}
        {% endfor %}
    ];
    
    const ctx = document.getElementById('totalLiftChart').getContext('2d');

    const primaryColor = '#2a8fed';
    const gradient = ctx.createLinearGradient(0, 0, 0, 300);
    gradient.addColorStop(0, `${primaryColor}4D`);
    gradient.addColorStop(1, `${primaryColor}00`);

    new Chart(ctx, {
        type: 'line',
        data: {
            labels: workoutData.map(d => d.date),
            datasets: [{
                label: '総リフト重量',
                data: workoutData.map(d => d.weight),
                borderColor: primaryColor,
                backgroundColor: gradient,
                fill: true,
                tension: 0.4,
                borderWidth: 2,
                pointRadius: 0,
                pointHoverRadius: 6,
                pointHoverBackgroundColor: primaryColor,
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: false,
            interaction: {
                mode: 'index',
                intersect: false,
            },
            scales: {
                y: {
                    display: true,
                    position: 'right',
                    grid: {
                        color: '#e5e7eb',
                    },
                    ticks: {
                        color: '#6b7280',
                        maxTicksLimit: 6,
                        callback: function(value) {
                            return value.toLocaleString() + ' kg';
                        }
                    }
                },
                x: {
                    grid: {
                        display: false,
                    },
                    ticks: {
                        color: '#6b7280',
                        font: { size: 11, },
                    }
                }
            },
            plugins: {
                legend: {
                    display: false
                },
                tooltip: {
                    enabled: true, 
                    backgroundColor: '#111827',
                    titleFont: { size: 14, weight: 'bold' },
                    bodyFont: { size: 12 },
                    padding: 12,
                    cornerRadius: 6,
                    displayColors: false,
                    callbacks: {
                        title: function(context) {
                            return context[0].label;
                        },
                        label: function(context) {
                            return `合計: ${context.parsed.y.toLocaleString()} kg`;
                        }
                    }
                }
            }
        }
    });
</script>
</body>
</html>