<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Health Dashboard - Multi-Cloud Orchestration</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        :root {
            --primary: #667eea;
            --success: #10b981;
            --warning: #f59e0b;
            --error: #ef4444;
            --bg: #f5f7fa;
            --card-bg: #ffffff;
            --text: #1f2937;
            --text-light: #6b7280;
            --border: #e5e7eb;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: var(--bg);
            color: var(--text);
        }
        
        .navbar {
            background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
            color: white;
            padding: 1rem 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .navbar a {
            color: white;
            text-decoration: none;
            margin-right: 1rem;
        }
        
        .container {
            max-width: 1600px;
            margin: 0 auto;
            padding: 2rem;
        }
        
        .header {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 2rem;
            margin-bottom: 2rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        
        .header h1 {
            font-size: 2rem;
            margin-bottom: 0.5rem;
        }
        
        .health-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }
        
        .health-card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border-left: 4px solid;
        }
        
        .health-card.healthy {
            border-color: var(--success);
        }
        
        .health-card.degraded {
            border-color: var(--warning);
        }
        
        .health-card.unhealthy {
            border-color: var(--error);
        }
        
        .health-card h3 {
            font-size: 1.25rem;
            margin-bottom: 1rem;
        }
        
        .health-metrics {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 1rem;
            margin-top: 1rem;
        }
        
        .metric {
            text-align: center;
            padding: 0.75rem;
            background: var(--bg);
            border-radius: 6px;
        }
        
        .metric .label {
            font-size: 0.75rem;
            color: var(--text-light);
            margin-bottom: 0.25rem;
        }
        
        .metric .value {
            font-size: 1.5rem;
            font-weight: 600;
        }
        
        .comparison-table {
            background: var(--card-bg);
            border-radius: 12px;
            padding: 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            overflow-x: auto;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
        }
        
        th, td {
            padding: 0.75rem;
            text-align: left;
            border-bottom: 1px solid var(--border);
        }
        
        th {
            background: var(--bg);
            font-weight: 600;
        }
        
        .status-badge {
            padding: 0.25rem 0.75rem;
            border-radius: 12px;
            font-size: 0.75rem;
            font-weight: 600;
        }
        
        .status-badge.healthy {
            background: #d1fae5;
            color: #065f46;
        }
        
        .status-badge.degraded {
            background: #fef3c7;
            color: #92400e;
        }
        
        .status-badge.unhealthy {
            background: #fee2e2;
            color: #991b1b;
        }
    </style>
</head>
<body>
    <div class="navbar">
        <a href="/"><i class="fas fa-arrow-left"></i> Back to Dashboard</a>
        <span>Health Dashboard</span>
    </div>
    
    <div class="container">
        <div class="header">
            <h1><i class="fas fa-heartbeat"></i> Environment Health Comparison</h1>
            <p>Real-time health status across all environments</p>
        </div>
        
        <div class="health-grid">
                    <% health_data.forEach(env => { %>
            <div class="health-card <%= env.health %>">
                <h3><%= env.name %></h3>
                <div style="margin-bottom: 1rem;">
                    <span class="status-badge <%= env.health %>">
                        <%= (env.health || '').toUpperCase() %>
                    </span>
                    <span style="color: var(--text-light); margin-left: 1rem;">
                        <%= (env.provider || '').toUpperCase() %> - <%= env.region %>
                    </span>
                </div>
                <div class="health-metrics">
                    <div class="metric">
                        <div class="label">CPU</div>
                        <div class="value"><%= env.status.cpu_usage_percent %>%</div>
                    </div>
                    <div class="metric">
                        <div class="label">Memory</div>
                        <div class="value"><%= env.status.memory_usage_percent %>%</div>
                    </div>
                    <div class="metric">
                        <div class="label">Nodes</div>
                        <div class="value"><%= env.status.node_count %></div>
                    </div>
                    <div class="metric">
                        <div class="label">Pods</div>
                        <div class="value"><%= env.status.pods_running %>/<%= env.status.pods_total %></div>
                    </div>
                </div>
            </div>
            <% }); %>
        </div>
        
        <div class="comparison-table">
            <h2 style="margin-bottom: 1rem;">Detailed Comparison</h2>
            <table>
                <thead>
                    <tr>
                        <th>Environment</th>
                        <th>Provider</th>
                        <th>Region</th>
                        <th>Health</th>
                        <th>CPU %</th>
                        <th>Memory %</th>
                        <th>Nodes</th>
                        <th>Uptime</th>
                    </tr>
                </thead>
                <tbody>
                    <% health_data.forEach(env => { %>
                    <tr>
                        <td><strong><%= env.name %></strong></td>
                        <td><%= (env.provider || '').toUpperCase() %></td>
                        <td><%= env.region %></td>
                        <td>
                            <span class="status-badge <%= env.health %>">
                                <%= (env.health || '').toUpperCase() %>
                            </span>
                        </td>
                        <td><%= env.status.cpu_usage_percent %>%</td>
                        <td><%= env.status.memory_usage_percent %>%</td>
                        <td><%= env.status.node_count %></td>
                        <td><%= env.status.uptime_days %> days</td>
                    </tr>
                    <% }); %>
                </tbody>
            </table>
        </div>
    </div>
</body>
</html>

