<?php
// ============================================================
// SureCertificate - Global Configuration
// ============================================================

// Site Identity
define('SITE_NAME', 'SureCertificate');
define('SITE_TAGLINE', 'Professional Bootcamps and Certification Courses');
define('PHONE_NUMBER', '+1 (888) 765-8856');
define('EMAIL_ADDRESS', 'Admin@mytechcertificate.com');
define('WHATSAPP_NUMBER', '+919354009315');
define('PHYSICAL_ADDRESS', '1 E 2nd St, New York, NY 10005, USA');

// Base URLs - CRITICAL for path resolution
$scDocRoot = isset($_SERVER['DOCUMENT_ROOT']) ? str_replace('\\', '/', rtrim($_SERVER['DOCUMENT_ROOT'], '/')) : '';
$scSiteDir = str_replace('\\', '/', rtrim(__DIR__, '/'));
$scBasePath = '';
if ($scDocRoot !== '' && strpos($scSiteDir, $scDocRoot) === 0) {
    $scBasePath = substr($scSiteDir, strlen($scDocRoot));
}
$scBasePath = '/' . trim($scBasePath, '/');
if ($scBasePath === '/') {
    $scBasePath = '';
}
define('BASE_URL', $scBasePath . '/');
define('ASSET_URL', BASE_URL . 'assets/');
define('IMAGE_URL', BASE_URL . 'assets/images/');
define('CSS_URL', BASE_URL . 'assets/css/');
define('JS_URL', BASE_URL . 'assets/js/');

// CDN Assets (KnowledgeHut-style legacy support)
define('CDN_BASE', 'https://d2o2utebsixu4k.cloudfront.net/');

// Brand Colors
define('PRIMARY_COLOR', '#5DA363');
define('SECONDARY_COLOR', '#2C4765');
define('ACCENT_COLOR', '#22c55e');
define('DARK_COLOR', '#0f172a');
define('LIGHT_BG', '#f8fafc');

// Database (existing)
define('DB_HOST', 'localhost');
define('DB_USER', 'flightbo_surecertificate');
define('DB_PASS', 'flightbo_surecertificate');
define('DB_NAME', 'flightbo_surecertificate');

// Helper Functions
if (!function_exists('asset')) {
    function asset($path) {
        return BASE_URL . 'assets/' . ltrim($path, '/');
    }
}

if (!function_exists('image')) {
    function image($path) {
        return BASE_URL . 'assets/images/' . ltrim($path, '/');
    }
}

if (!function_exists('css')) {
    function css($path) {
        return BASE_URL . 'assets/css/' . ltrim($path, '/');
    }
}

if (!function_exists('js')) {
    function js($path) {
        return BASE_URL . 'assets/js/' . ltrim($path, '/');
    }
}

if (!function_exists('course_image')) {
    function course_image($filename) {
        // Fallback to Unsplash if local image missing
        $localPath = __DIR__ . '/assets/images/courses/' . $filename;
        if (file_exists($localPath)) {
            return BASE_URL . 'assets/images/courses/' . $filename;
        }
        // Default fallback images by category
        $fallbacks = [
            'agile' => 'photo-1531482615713-2afd69097998',
            'devops' => 'photo-1667372393119-3d4c48d07fc9',
            'cloud' => 'photo-1451187580459-43490279c0fa',
            'itil' => 'photo-1535905557-58cb6c7a44aa',
            'pmp' => 'photo-1507003211169-0a1dd7228f2d',
            'default' => 'photo-1522202176988-66273c2fd55f'
        ];
        $key = array_search($filename, array_keys($fallbacks)) !== false ? str_replace(['.jpg', '.png'], '', $filename) : 'default';
        return 'https://images.unsplash.com/' . ($fallbacks[$key] ?? $fallbacks['default']) . '?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80';
    }
}
?>
