<?php
/**
 * API - Obtener configuración del sistema
 * Fecha: 13 de noviembre de 2025
 */

require_once '../config/config.php';

// Verificar autenticación
requireAuthentication();

header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Content-Type');

try {
    $db = Database::getInstance();
    
    $configs = $db->fetchAll(
        "SELECT config_key, config_value FROM system_config"
    );
    
    $system_config = [];
    foreach ($configs as $config) {
        $system_config[$config['config_key']] = $config['config_value'];
    }
    
    echo json_encode($system_config);
    
} catch (Exception $e) {
    error_log("Error in get_system_config.php: " . $e->getMessage());
    http_response_code(500);
    echo json_encode(['error' => 'Error interno del servidor']);
}
?>