<?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 (SQLite demo)
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
define('DB_NAME', getenv('SQLITE_DB_PATH') ?: __DIR__ . '/../../data/saleos_demo.sqlite');
define('DB_USER', '');
define('DB_PASS', '');
define('DB_CHARSET', 'utf8');

// 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', '0');
define('OPENAI_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).
define('SALEOS_DEMO_MODE', true);
