<?php
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, max-age=0');

require_once __DIR__ . '/../../models/model_config_envio.php';

try {
    $cfg = (new ModelConfigEnvio())->getConfig();
    echo json_encode([
        'success' => true,
        'data' => [
            'minimo_compra_gratis' => (float)$cfg['minimo_compra_gratis'],
            'costo_envio' => (float)$cfg['costo_envio'],
            'envio_habilitado' => (int)$cfg['envio_habilitado'] === 1,
            'telefono_whatsapp' => $cfg['telefono_whatsapp'],
        ],
    ], JSON_UNESCAPED_UNICODE);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode(['success' => false, 'message' => 'No se pudo cargar configuración de envío']);
}
