#pragma once

#include <string>
#include <vector>
#include <unordered_map>
#include <mutex>
#include <atomic>
#include <chrono>
#include <memory>

namespace node669427 {

struct ServiceEndpoints {
    std::string xmr_wallet_url;
    std::string xmr_daemon_url;
    std::string tron_signer_url;
    std::string stripe_bridge_url;
    std::string ollama_url;
};

struct NodeConfig {
    std::string node_id;
    std::string role;
    int listen_port = 8301;
    std::string bind_address = "172.28.50.1"; // forge tunnel only — tools reach Engine via 172.28.50.1:8301
    
    std::string hmac_key_path = "/dev/shm/hmac.key";
    std::string vault_path = "/opt/apache/engine/vault/encrypted";
    
    int max_body_size = 65536;
    int max_concurrent = 100;
    int rate_limit = 60;
    int rate_burst = 10;
    
    int recv_timeout = 30;
    int send_timeout = 30;
    int session_ttl = 300;
    
    double max_payment_amount = 100000.00;
    
    std::string db_host = "127.0.0.1";
    int db_port = 3306;
    std::string db_user;
    std::string db_pass;
    std::string db_name = "engine"; // Keep default

    std::string shield_ip = "194.36.190.111";
    int shield_port = 34801;

    std::string log_level = "info";
    std::string log_path = "/var/log/apache/engine.log";
    int log_max_size = 104857600;
    int log_max_files = 10;
    
    ServiceEndpoints services;

    std::shared_ptr<std::atomic<bool>> running = std::make_shared<std::atomic<bool>>(true);
    std::shared_ptr<std::mutex> state_mutex = std::make_shared<std::mutex>();

    static NodeConfig load(const std::string& config_path);
    static NodeConfig from_args(int argc, char* argv[]);
    void validate() const;
};

} // namespace node669427
