<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Casal Perfeito</title>
    <link rel="manifest" href="/manifest.json">
    <meta name="theme-color" content="#FF1493">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .container {
            background: white;
            border-radius: 10px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            padding: 40px;
            text-align: center;
            max-width: 500px;
        }

        h1 {
            color: #FF1493;
            margin-bottom: 10px;
        }

        p {
            color: #666;
            margin: 10px 0;
        }

        .status {
            margin-top: 30px;
            padding: 20px;
            background: #f0f0f0;
            border-radius: 5px;
        }

        .status-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 5px 0;
        }

        .status-label {
            text-align: left;
        }

        .status-value {
            font-weight: bold;
            color: #667eea;
        }

        .online {
            color: #28a745;
        }

        .offline {
            color: #dc3545;
        }

        .version {
            margin-top: 20px;
            font-size: 12px;
            color: #999;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>💑 Casal Perfeito</h1>
        <p>Bem-vindo ao seu espaço especial</p>
        
        <div class="status">
            <div class="status-item">
                <span class="status-label">Servidor Web</span>
                <span class="status-value online">● Online</span>
            </div>
            <div class="status-item">
                <span class="status-label">API</span>
                <span class="status-value" id="api-status">Verificando...</span>
            </div>
            <div class="status-item">
                <span class="status-label">Banco de Dados</span>
                <span class="status-value" id="db-status">Verificando...</span>
            </div>
        </div>

        <div class="version">
            <p>v1.0.0 - 2026-05-09</p>
        </div>
    </div>

    <script>
        // Service Worker registration
        if ('serviceWorker' in navigator) {
            navigator.serviceWorker.register('/sw.js').catch(err => {
                console.log('SW registration failed:', err);
            });
        }

        // Check API status
        async function checkStatus() {
            try {
                const response = await fetch('/api/health');
                if (response.ok) {
                    document.getElementById('api-status').textContent = '● Online';
                    document.getElementById('api-status').className = 'status-value online';
                    
                    // Check DB status
                    const configResponse = await fetch('/api/config');
                    if (configResponse.ok) {
                        document.getElementById('db-status').textContent = '● Online';
                        document.getElementById('db-status').className = 'status-value online';
                    }
                }
            } catch (err) {
                document.getElementById('api-status').textContent = '● Offline';
                document.getElementById('api-status').className = 'status-value offline';
                document.getElementById('db-status').textContent = '● Offline';
                document.getElementById('db-status').className = 'status-value offline';
            }
        }

        checkStatus();
        setInterval(checkStatus, 5000);
    </script>
</body>
</html>
