#ifndef CONFIG_H_
#define CONFIG_H_

#include <Arduino.h>

// Keep the structure compact to minimize padding and RAM usage.
// Order fields from wider to narrower types, and avoid inline default initializers.
// Defaults are applied in setDefaultConfig() to keep initialization simple and lightweight.
struct Config {
    // 32-bit values
    uint32_t sleepTime;          // ms
    uint32_t sleepDelay;         // ms
    uint32_t sleepMessageDelay;  // ms

    // 16-bit values
    uint16_t minVoltage;         // mV
    uint16_t voltage100Percent;  // mV

    // 8-bit values
    uint8_t  initialVolume;
    uint8_t  maxVolume;
    uint8_t  rfidLoopInterval;

    // flags
    bool     startAtStoredProgress;

    // WiFi credentials (fixed-size buffers, no heap allocations)
    char     wifiSSID[32];       // empty => use current mechanism
    char     wifiPassword[64];   // empty => use current mechanism
};

// Global config instance
extern Config config;

// Function declarations
bool loadConfig();
bool saveConfig();
void setDefaultConfig();

// Returns a pointer to a static buffer with the absolute config file path.
// Avoids dynamic allocation/Arduino String to reduce heap fragmentation.
const char* getConfigFilePath();

#endif
