<?php
// Database Configuration
define('DB_HOST', 'localhost');
define('DB_NAME', 'ahmeuesz_dino');
define('DB_USER', 'ahmeuesz_dino_user');
define('DB_PASS', 'doraemonnobita');
define('DB_CHARSET', 'utf8mb4');

// Create PDO connection
try {
    $dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET;
    $options = [
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
    ];
    $pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
} catch (PDOException $e) {
    http_response_code(500);
    die(json_encode(['error' => 'Database connection failed', 'message' => 'Unable to connect to database']));
}

// Timezone
date_default_timezone_set('Asia/Karachi');

// CORS headers (for AJAX requests)
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Authorization, User-Agent');
?>
