<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sistema de Controle de Frotas</title>
    <style>
        body { 
            font-family: Arial, sans-serif; 
            margin: 40px; 
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        .container { 
            max-width: 800px; 
            margin: 0 auto; 
            background: rgba(255,255,255,0.95); 
            padding: 30px; 
            border-radius: 15px; 
            box-shadow: 0 10px 30px rgba(0,0,0,0.3);
            color: #333;
        }
        .ok { color: #28a745; font-weight: bold; }
        .erro { color: #dc3545; font-weight: bold; }
        .aviso { color: #ffc107; font-weight: bold; }
        h1 { 
            color: #333; 
            text-align: center;
            border-bottom: 3px solid #007bff; 
            padding-bottom: 15px; 
            margin-bottom: 30px;
        }
        .btn { 
            background: #007bff; 
            color: white; 
            padding: 12px 25px; 
            text-decoration: none; 
            border-radius: 8px; 
            display: inline-block; 
            margin: 10px 5px;
            font-weight: bold;
            transition: background 0.3s;
        }
        .btn:hover { background: #0056b3; }
        .success-box {
            background: #d4edda;
            border: 2px solid #c3e6cb;
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }
        .info-box {
            background: #e3f2fd;
            border: 2px solid #2196f3;
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
        }
        .status-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        .status-card {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 10px;
            border-left: 5px solid #007bff;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🚛 Sistema de Controle de Frotas</h1>
        
        <div class="success-box">
            <h2>✅ PHP Funcionando Perfeitamente!</h2>
            <p><strong>PHP Versão:</strong> <?php echo phpversion(); ?></p>
            <p><strong>Servidor:</strong> <?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'Apache/PHP'; ?></p>
            <p><strong>Data/Hora:</strong> <?php echo date('d/m/Y H:i:s'); ?></p>
        </div>

        <div class="status-grid">
            <div class="status-card">
                <h3>🔧 Extensões PHP</h3>
                <?php
                $extensoes = ['pdo', 'pdo_mysql', 'json', 'openssl', 'curl', 'mbstring'];
                foreach ($extensoes as $ext) {
                    if (extension_loaded($ext)) {
                        echo "<p><span class='ok'>✅ $ext</span></p>";
                    } else {
                        echo "<p><span class='erro'>❌ $ext</span></p>";
                    }
                }
                ?>
            </div>

            <div class="status-card">
                <h3>📁 Arquivos do Sistema</h3>
                <?php
                $arquivos = [
                    '.env' => 'Configurações',
                    'composer.json' => 'Dependências',
                    'api/auth/login.php' => 'API Login',
                    'admin/index.html' => 'Painel Admin',
                    'database/schema.sql' => 'Schema DB'
                ];
                foreach ($arquivos as $arquivo => $desc) {
                    if (file_exists($arquivo)) {
                        echo "<p><span class='ok'>✅ $desc</span></p>";
                    } else {
                        echo "<p><span class='aviso'>⚠️ $desc</span></p>";
                    }
                }
                ?>
            </div>
        </div>

        <div class="info-box">
            <h2>🗄️ Teste de Conexão MySQL</h2>
            <?php
            try {
                // Configurações padrão
                $host = 'localhost';
                $username = 'root';
                $password = '';
                
                $pdo = new PDO("mysql:host=$host;charset=utf8mb4", $username, $password, [
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
                ]);
                
                echo "<p><span class='ok'>✅ Conexão MySQL estabelecida!</span></p>";
                
                // Verificar se o banco existe
                $stmt = $pdo->query("SHOW DATABASES LIKE 'controle_frotas'");
                if ($stmt->rowCount() > 0) {
                    echo "<p><span class='ok'>✅ Banco 'controle_frotas' encontrado</span></p>";
                    
                    $pdo->exec("USE controle_frotas");
                    $stmt = $pdo->query("SHOW TABLES");
                    $tabelas = $stmt->rowCount();
                    
                    if ($tabelas > 0) {
                        echo "<p><span class='ok'>✅ $tabelas tabela(s) encontrada(s)</span></p>";
                    } else {
                        echo "<p><span class='aviso'>⚠️ Banco vazio - importe schema.sql</span></p>";
                    }
                } else {
                    echo "<p><span class='aviso'>⚠️ Banco 'controle_frotas' não existe</span></p>";
                }
                
            } catch (Exception $e) {
                echo "<p><span class='erro'>❌ Erro MySQL:</span> " . $e->getMessage() . "</p>";
                echo "<p><strong>Solução:</strong> Verifique se MySQL está rodando no XAMPP</p>";
            }
            ?>
        </div>

        <div class="info-box">
            <h2>🚀 Próximos Passos</h2>
            <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px;">
                <a href="http://localhost/phpmyadmin" class="btn" target="_blank">📊 phpMyAdmin</a>
                <a href="test-conexao.php" class="btn">🧪 Teste Completo</a>
                <a href="admin/" class="btn">⚙️ Painel Admin</a>
                <a href="api/auth/login.php" class="btn">🔌 Testar API</a>
            </div>
        </div>

        <div class="info-box">
            <h2>🔑 Informações Importantes</h2>
            <p><strong>Credenciais Padrão:</strong></p>
            <ul>
                <li>Email: admin@controledefrotas.com</li>
                <li>Senha: admin123</li>
            </ul>
            <p><strong>URL da API para o App Android:</strong></p>
            <code>http://localhost/controlefrota/backend-php/api/</code>
            <br><br>
            <p><strong>Para rede local (outros dispositivos):</strong></p>
            <code>http://SEU-IP-LOCAL/controlefrota/backend-php/api/</code>
        </div>
    </div>
</body>
</html> 
