<?php

// Basic App Settings
define('APP_NAME', 'Caregiver Deluxe');
define('APP_ENV', 'production');

// Database Configuration
define('DB_HOST', 'localhost');
define('DB_NAME', 'howardwe_caregiver_v2');
define('DB_USER', 'howardwe_cg_app');
define('DB_PASS', 'Jason21@!()');

// Session / Cookie Settings
define('SESSION_COOKIE_NAME', 'cg_platform_session');
define('SESSION_COOKIE_LIFETIME', 60 * 60 * 24 * 30); // 30 days
define('SESSION_TTL_SECONDS', 60 * 60 * 24 * 30); // 30 days

function db() {
    static $pdo = null;

    if ($pdo === null) {
        try {
            $pdo = new PDO(
                'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4',
                DB_USER,
                DB_PASS,
                [
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                ]
            );
        } catch (PDOException $e) {
            die('Database connection failed: ' . $e->getMessage());
        }
    }

    return $pdo;
}