<?php
/**
 * MINIMAL WORKING DASHBOARD
 * Use this if the main dashboard is still blank
 */

error_reporting(E_ALL);
ini_set('display_errors', 1);

// Define base path
define('BASE_PATH', dirname(__DIR__));

// Load essential files
require_once BASE_PATH . '/config/config.php';
require_once BASE_PATH . '/config/database.php';
require_once BASE_PATH . '/config/auth.php';

// Require authentication
if (function_exists('require_auth')) {
    require_auth();
}

// Get current user
$current_user = function_exists('current_user') ? current_user() : null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard | <?php echo defined('APP_NAME') ? APP_NAME : 'Ruhondo Resort'; ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" href="#"><?php echo defined('APP_NAME') ? APP_NAME : 'Ruhondo Resort'; ?></a>
            <div class="navbar-nav ms-auto">
                <span class="nav-item nav-link text-white">
                    <i class="fas fa-user"></i> 
                    <?php echo $current_user ? htmlspecialchars($current_user['username'] ?? 'User') : 'Guest'; ?>
                </span>
                <a class="nav-item nav-link" href="logout.php">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
            </div>
        </div>
    </nav>

    <div class="container-fluid mt-4">
        <h1>Welcome to Dashboard</h1>
        <p>If you can see this, the basic PHP is working.</p>
        
        <div class="row">
            <div class="col-md-4">
                <div class="card text-white bg-primary mb-3">
                    <div class="card-body">
                        <h5 class="card-title">System Status</h5>
                        <p class="card-text">PHP Version: <?php echo phpversion(); ?></p>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card text-white bg-success mb-3">
                    <div class="card-body">
                        <h5 class="card-title">User</h5>
                        <p class="card-text">Logged in as: <?php echo $current_user ? htmlspecialchars($current_user['username'] ?? 'Unknown') : 'Not logged in'; ?></p>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card text-white bg-info mb-3">
                    <div class="card-body">
                        <h5 class="card-title">Database</h5>
                        <p class="card-text">
                            <?php 
                            if (function_exists('test_db_connection') && test_db_connection()) {
                                echo '<span class="text-success">✓ Connected</span>';
                            } else {
                                echo '<span class="text-danger">✗ Not connected</span>';
                            }
                            ?>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>