<?php
/**
 * Application Configuration
 */

define('APP_NAME', 'Inventory Count Management System');
define('APP_VERSION', '1.0.0');
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
define('APP_URL', $protocol . '://' . $host . '/invcount');
define('APP_ROOT', dirname(__DIR__));

// Database Configuration
define('DB_HOST', '127.0.0.1');
define('DB_PORT', 3306);
define('DB_NAME', 'invcount_db');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_CHARSET', 'utf8mb4');

// Session Configuration
define('SESSION_LIFETIME', 7200); // 2 hours
define('SESSION_NAME', 'INVCOUNT_SESS');

// Security
define('CSRF_TOKEN_NAME', '_csrf_token');
define('HASH_ALGO', 'bcrypt');
define('HASH_COST', 12);

// Pagination
define('ITEMS_PER_PAGE', 20);

// Upload
define('UPLOAD_MAX_SIZE', 10 * 1024 * 1024); // 10MB
define('EXPORT_PATH', APP_ROOT . '/uploads/exports/');
define('IMPORT_PATH', APP_ROOT . '/uploads/imports/');
define('LOG_PATH', APP_ROOT . '/storage/logs/');
define('BACKUP_PATH', APP_ROOT . '/storage/backups/');

// Roles
define('ROLE_ADMIN', 'admin');
define('ROLE_COUNTER', 'counter');
define('ROLE_CHECKER', 'checker');
define('ROLE_CONTROLLER', 'controller');

// Session Status
define('SESSION_DRAFT', 'draft');
define('SESSION_OPEN', 'open');
define('SESSION_IN_PROGRESS', 'in_progress');
define('SESSION_COMPLETED', 'completed');
define('SESSION_CANCELLED', 'cancelled');

// Assignment Status
define('ASSIGN_PENDING', 'pending');
define('ASSIGN_IN_PROGRESS', 'in_progress');
define('ASSIGN_COUNTED', 'counted');
define('ASSIGN_CHECKED', 'checked');
define('ASSIGN_APPROVED', 'approved');
define('ASSIGN_REJECTED', 'rejected');
define('ASSIGN_RECOUNT', 'recount');

// Timezone
date_default_timezone_set('Africa/Johannesburg');

// Offline / PWA Queue
define('OFFLINE_QUEUE_ENABLED',       true);
define('OFFLINE_DRAIN_ENDPOINT',     APP_URL . '/counter/api_sync.php');
define('OFFLINE_SYNC_TAG',            'drain-counts');
define('OFFLINE_QUEUE_BATCH_LIMIT',   50);
