<?php
define('APP_NAME', 'نظام الكاشير');
define('APP_VERSION', '1.0.0');
define('ENVIRONMENT', 'production');

date_default_timezone_set('Asia/Riyadh');

session_start([
    'cookie_httponly' => true,
    'cookie_secure' => isset($_SERVER['HTTPS']),
    'cookie_samesite' => 'Strict'
]);

define('DB_HOST', 'localhost');
define('DB_USER', 'codvida');
define('DB_PASS', '123456');
define('DB_NAME', 'cashier_system');
define('DB_CHARSET', 'utf8mb4');

try {
    $pdo = new PDO(
        "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET,
        DB_USER,
        DB_PASS,
        [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
            PDO::ATTR_PERSISTENT => false
        ]
    );
} catch (PDOException $e) {
    error_log("Database connection failed: " . $e->getMessage());
    header('HTTP/1.1 503 Service Unavailable');
    exit('System temporarily unavailable');
}