<?php
/**
 * Application Constants
 */

// Set UTF-8 as default encoding for all string operations
ini_set('default_charset', 'UTF-8');
if (extension_loaded('mbstring')) {
    mb_internal_encoding('UTF-8');
}

// Database Configuration (MySQL)
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
define('DB_NAME', getenv('DB_NAME') ?: 'hanafiv1_cr');
define('DB_USER', getenv('DB_USER') ?: 'hanafiv1_cr');
define('DB_PASS', getenv('DB_PASS') ?: 'Mh1577472812');
define('DB_CHARSET', 'utf8mb4');

// OpenAI / AI Assistant Configuration
$openAiConfigPath = __DIR__ . '/openai.php';
$openAiConfig = is_file($openAiConfigPath) ? require $openAiConfigPath : [
    'enabled' => getenv('AI_FEATURE_ENABLED') ?: '0',
    'api_key' => getenv('OPENAI_API_KEY') ?: '',
    'model' => getenv('OPENAI_MODEL') ?: 'gpt-4.1-mini',
    'api_base' => getenv('OPENAI_API_BASE') ?: 'https://api.openai.com/v1',
    'timeout' => (int)(getenv('OPENAI_TIMEOUT') ?: 30),
];
define('OPENAI_FEATURE_ENABLED', (string)($openAiConfig['enabled'] ?? '0'));
define('OPENAI_API_KEY', (string)($openAiConfig['api_key'] ?? ''));
define('OPENAI_MODEL', (string)($openAiConfig['model'] ?? 'gpt-4.1-mini'));
define('OPENAI_API_BASE', (string)($openAiConfig['api_base'] ?? 'https://api.openai.com/v1'));
define('OPENAI_TIMEOUT', (int)($openAiConfig['timeout'] ?? 30));

// Didar API
define('DIDAR_API_BASE', 'https://app.didar.me/api');

// Logging
define('LOG_FILE', __DIR__ . '/../../logs/app.log');
define('ERROR_LOG_FILE', __DIR__ . '/../../logs/error.log');

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

// Temporary offline UI mode (no external assets).
