<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Workout Report - {{ workout.metadata.activity_name }}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1, h2, h3 {
            color: #333;
        }
        .summary-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        .summary-card {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 5px;
            text-align: center;
        }
        .summary-card h3 {
            margin: 0 0 10px 0;
            color: #666;
            font-size: 14px;
        }
        .summary-card .value {
            font-size: 24px;
            font-weight: bold;
            color: #007bff;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f8f9fa;
            font-weight: bold;
        }
        .footer {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #eee;
            color: #666;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Workout Report: {{ workout.metadata.activity_name }}</h1>
        <p><strong>Date:</strong> {{ workout.metadata.start_time }}</p>
        <p><strong>Activity Type:</strong> {{ workout.metadata.activity_type }}</p>
        
        <h2>Summary</h2>
        <div class="summary-grid">
            <div class="summary-card">
                <h3>Duration</h3>
                <div class="value">{{ workout.summary.duration_minutes|format_duration }}</div>
            </div>
            <div class="summary-card">
                <h3>Distance</h3>
                <div class="value">{{ workout.summary.distance_km|format_distance }}</div>
            </div>
            <div class="summary-card">
                <h3>Avg Power</h3>
                <div class="value">{{ workout.summary.avg_power|format_power }}</div>
            </div>
            <div class="summary-card">
                <h3>Avg Heart Rate</h3>
                <div class="value">{{ workout.summary.avg_heart_rate|format_heart_rate }}</div>
            </div>
            <div class="summary-card">
                <h3>Avg Speed</h3>
                <div class="value">{{ workout.summary.avg_speed_kmh|format_speed }}</div>
            </div>
            <div class="summary-card">
                <h3>Calories</h3>
                <div class="value">{{ workout.summary.calories|int }}</div>
            </div>
        </div>
        
        <h2>Detailed Analysis</h2>
        
        <h3>Power Analysis</h3>
        <table>
            <tr>
                <th>Metric</th>
                <th>Value</th>
            </tr>
            <tr>
                <td>Average Power</td>
                <td>{{ workout.power_analysis.avg_power|format_power }}</td>
            </tr>
            <tr>
                <td>Maximum Power</td>
                <td>{{ workout.power_analysis.max_power|format_power }}</td>
            </tr>
            <tr>
                <td>Normalized Power</td>
                <td>{{ workout.summary.normalized_power|format_power }}</td>
            </tr>
            <tr>
                <td>Intensity Factor</td>
                <td>{{ "%.2f"|format(workout.summary.intensity_factor) }}</td>
            </tr>
        </table>
        
        <h3>Heart Rate Analysis</h3>
        <table>
            <tr>
                <th>Metric</th>
                <th>Value</th>
            </tr>
            <tr>
                <td>Average Heart Rate</td>
                <td>{{ workout.heart_rate_analysis.avg_heart_rate|format_heart_rate }}</td>
            </tr>
            <tr>
                <td>Maximum Heart Rate</td>
                <td>{{ workout.heart_rate_analysis.max_heart_rate|format_heart_rate }}</td>
            </tr>
        </table>
        
        <h3>Speed Analysis</h3>
        <table>
            <tr>
                <th>Metric</th>
                <th>Value</th>
            </tr>
            <tr>
                <td>Average Speed</td>
                <td>{{ workout.speed_analysis.avg_speed|format_speed }}</td>
            </tr>
            <tr>
                <td>Maximum Speed</td>
                <td>{{ workout.speed_analysis.max_speed|format_speed }}</td>
            </tr>
        </table>
        
        <div class="footer">
            <p>Report generated on {{ report.generated_at }} using {{ report.tool }} v{{ report.version }}</p>
        </div>
    </div>
</body>
</html>