#pragma once
#include <string>
#include <vector>
#include <ctime>

struct WeatherData {
  bool ok = false;
  double temp = 0.0;
  double hi = 0.0;
  double lo = 0.0;
  // Daily forecast (2 days: [0]=today, [1]=tomorrow)
  double tomorrow_hi = 0.0;
  double tomorrow_lo = 0.0;
  int today_code = 3;
  int tomorrow_code = 3;
  int today_pop = 0;       // precipitation probability max (%)
  int tomorrow_pop = 0;

  int code = 0;
  std::string label;
  std::time_t fetched_at = 0;

  std::vector<double> next_temps;   // next N hours
  std::vector<int> next_pop;        // precip probability %
};

bool FetchWeatherOpenMeteo(double lat, double lon, bool fahrenheit, int hours, WeatherData *out);
std::string WeatherLabelFromCode(int code);

bool LoadWeatherCache(const std::string &path, WeatherData *out);
void SaveWeatherCache(const std::string &path, const WeatherData &w);


