<?php

require_once __DIR__ . '/../config/bootstrap.php';

use ControleFrotas\Utils\Response;

?>
<!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>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .welcome-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            backdrop-filter: blur(10px);
        }
        .icon-feature {
            font-size: 3rem;
            margin-bottom: 1rem;
        }
        .btn-custom {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            color: white;
            padding: 12px 30px;
            border-radius: 25px;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        .btn-custom:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
            color: white;
        }
        .feature-item {
            text-align: center;
            padding: 2rem;
            margin: 1rem;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.1);
            transition: transform 0.3s ease;
        }
        .feature-item:hover {
            transform: translateY(-5px);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-10">
                <div class="welcome-card p-5">
                    <!-- Header -->
                    <div class="text-center mb-5">
                        <i class="fas fa-truck-moving text-primary" style="font-size: 4rem;"></i>
                        <h1 class="display-4 fw-bold text-primary mt-3">Sistema de Controle de Frotas</h1>
                        <p class="lead text-muted">Gerencie sua frota de veículos de forma inteligente e eficiente</p>
                    </div>

                    <!-- Features -->
                    <div class="row mb-5">
                        <div class="col-md-4">
                            <div class="feature-item">
                                <i class="fas fa-route text-success icon-feature"></i>
                                <h4>Rastreamento GPS</h4>
                                <p class="text-muted">Monitore viagens em tempo real com precisão de localização</p>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="feature-item">
                                <i class="fas fa-chart-line text-info icon-feature"></i>
                                <h4>Relatórios Avançados</h4>
                                <p class="text-muted">Análises detalhadas de produtividade e custos operacionais</p>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="feature-item">
                                <i class="fas fa-mobile-alt text-warning icon-feature"></i>
                                <h4>App Mobile</h4>
                                <p class="text-muted">Aplicativo Android para técnicos em campo</p>
                            </div>
                        </div>
                    </div>

                    <!-- API Status -->
                    <div class="row mb-4">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="mb-0">
                                        <i class="fas fa-server me-2"></i>
                                        Status da API
                                    </h5>
                                </div>
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="d-flex align-items-center mb-2">
                                                <span class="badge bg-success me-2">
                                                    <i class="fas fa-circle"></i>
                                                </span>
                                                <strong>Sistema Online</strong>
                                            </div>
                                            <small class="text-muted">
                                                <?php
                                                try {
                                                    $dbInfo = \ControleFrotas\Config\Database::getDatabaseInfo();
                                                    echo "Banco: MySQL {$dbInfo['version']} | ";
                                                    echo "Charset: {$dbInfo['charset']}";
                                                } catch (Exception $e) {
                                                    echo "Erro na conexão com banco de dados";
                                                }
                                                ?>
                                            </small>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="d-flex align-items-center mb-2">
                                                <span class="badge bg-info me-2">
                                                    <i class="fas fa-clock"></i>
                                                </span>
                                                <strong>Última atualização</strong>
                                            </div>
                                            <small class="text-muted"><?php echo date('d/m/Y H:i:s'); ?></small>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Actions -->
                    <div class="text-center">
                        <div class="row">
                            <div class="col-md-6">
                                <a href="../admin/" class="btn btn-custom btn-lg w-100 mb-3">
                                    <i class="fas fa-tachometer-alt me-2"></i>
                                    Acessar Painel Administrativo
                                </a>
                                <p class="text-muted small">Para gestores e administradores</p>
                            </div>
                            <div class="col-md-6">
                                <a href="#" class="btn btn-outline-secondary btn-lg w-100 mb-3" onclick="mostrarInfoApp()">
                                    <i class="fab fa-android me-2"></i>
                                    Download App Android
                                </a>
                                <p class="text-muted small">Para técnicos em campo</p>
                            </div>
                        </div>
                    </div>

                    <!-- API Endpoints -->
                    <div class="mt-5">
                        <details class="text-center">
                            <summary class="btn btn-link">
                                <i class="fas fa-code me-2"></i>
                                Ver Endpoints da API
                            </summary>
                            <div class="mt-3">
                                <div class="card">
                                    <div class="card-body text-start">
                                        <h6>Principais Endpoints:</h6>
                                        <ul class="list-unstyled">
                                            <li><code>POST /api/auth/login</code> - Autenticação</li>
                                            <li><code>GET/POST /api/sync/viagens</code> - Sincronização de viagens</li>
                                            <li><code>GET /api/relatorios/dashboard</code> - Dados do dashboard</li>
                                            <li><code>GET /api/viagens</code> - Listar viagens</li>
                                            <li><code>GET /api/veiculos</code> - Listar veículos</li>
                                            <li><code>GET /api/usuarios</code> - Listar usuários</li>
                                        </ul>
                                        <p class="text-muted small">
                                            Todos os endpoints requerem autenticação JWT via header Authorization: Bearer {token}
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </details>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="appInfoModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">
                        <i class="fab fa-android me-2"></i>
                        App Android
                    </h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="text-center">
                        <i class="fab fa-android text-success" style="font-size: 3rem;"></i>
                        <h4 class="mt-3">Aplicativo para Técnicos</h4>
                        <p class="text-muted">
                            O aplicativo Android permite que os técnicos:
                        </p>
                        <ul class="list-unstyled">
                            <li><i class="fas fa-check text-success me-2"></i>Iniciem e finalizem viagens</li>
                            <li><i class="fas fa-check text-success me-2"></i>Registrem rastreamento GPS</li>
                            <li><i class="fas fa-check text-success me-2"></i>Visualizem histórico de viagens</li>
                            <li><i class="fas fa-check text-success me-2"></i>Sincronizem dados offline</li>
                        </ul>
                        <div class="alert alert-info">
                            <i class="fas fa-info-circle me-2"></i>
                            O APK está sendo compilado e estará disponível em breve.
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        function mostrarInfoApp() {
            new bootstrap.Modal(document.getElementById('appInfoModal')).show();
        }
    </script>
</body>
</html> 
