<?php
/**
 * Database Configuration — PDO MySQL Connection
 * Gym Booking System (FITZONE)
 */

// Define Base URL directly to avoid case-sensitivity issues on Windows
define('BASE_URL', '/gym5pdw');

$db_host = 'localhost';
$db_name = 'gym_booking';
$db_user = 'root';
$db_pass = '';

try {
    $pdo = new PDO(
        "mysql:host={$db_host};port=3306;dbname={$db_name};charset=utf8mb4",
        $db_user,
        $db_pass,
        [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES   => false,
        ]
    );
} catch (PDOException $e) {
    http_response_code(500);
    die('<div style="background:#1A1A1A;color:#ff6b6b;padding:2rem;font-family:Inter,sans-serif;text-align:center;margin-top:20vh;border-radius:12px;max-width:500px;margin-left:auto;margin-right:auto;">
        <h2 style="color:#D4F900;">⚠️ Database Connection Failed</h2>
        <p>' . htmlspecialchars($e->getMessage()) . '</p>
    </div>');
}
