<?php
declare(strict_types=1);
// 🔒 Ensure session cookie is valid for entire app
ini_set('session.cookie_path', '/');
ini_set('session.cookie_httponly', '1');

// Optional but recommended if HTTPS
// ini_set('session.cookie_secure', '1');

/**
 * ================================
 * APPLICATION PATH CONSTANTS
 * ================================
 */

/**
 * Filesystem base path
 * /var/www/html/nwx
 */
//define('BASE_PATH', dirname(__DIR__));
define('BASE_PATH', dirname(__DIR__, 2));

define('LOG_PATH', BASE_PATH . '/logs/');

/**
 * ================================
 * URL / ROUTING CONSTANTS
 * ================================
 */

/**
 * Application root folder
 * Local  → /nwx
 * Live   → '' (empty string)
 */
define('APP_ROOT', 'https://quicksports.in/');

/**
 * Base site URL
 * http://localhost
 * https://example.com
 */
define(
    'BASE_URL',
    (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')
    . '://' . $_SERVER['HTTP_HOST']
);

/**
 * Dealer Frontent base URL
 * /dealers/
 */
define('DEALERS_BASE_URL', 
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http')
    . '://' . $_SERVER['HTTP_HOST'] . '/dealers/');

/**
 * Admin base URL
 * /nwx/admin/
 */
define('ADMIN_BASE_URL', APP_ROOT . '/admin/');

/**
 * Public upload URL
 * /nwx/uploads
 */
define('UPLOAD_BASE_URL', APP_ROOT . '/uploads');

/**
 * ================================
 * SESSION & SECURITY
 * ================================
 */

define('SESSION_NAME', 'NWX_ADMIN_SESSION');
define('SESSION_LIFETIME', 7200); // 2 hours

define('PASSWORD_MIN_LENGTH', 8);

/**
 * ================================
 * UPLOAD RULES
 * ================================
 */

define('MAX_IMAGE_SIZE', 2 * 1024 * 1024); // 2MB
define('MAX_DOC_SIZE', 5 * 1024 * 1024);   // 5MB

define('ALLOWED_IMAGE_TYPES', [
    'image/jpeg',
    'image/png',
    'image/webp'
]);

define('ALLOWED_DOC_TYPES', [
    'application/pdf'
]);
