#pragma once

#include <vector>
#include <string>
#include "imgui.h"
#include "file_dialog.h"
#include "gui/icons_fa.h"

// Forward declaration to avoid pulling in SDL headers in every includer
struct SDL_Texture;
union SDL_Event;

// Shared globals moved into the ImGui implementation files
extern std::vector<const char*> qs_models;
extern std::vector<const char*> qs_configs;
extern ImTextureID about_logo_texture;

// Texture helpers that abstract SDL_Texture (SDLRenderer2) vs GLuint (OpenGL3)
struct SDL_Surface;
ImTextureID gui_create_texture(SDL_Surface* surface, int* out_w, int* out_h);
void gui_destroy_texture(ImTextureID tex);

bool BeginGroupBox(const char* name, bool collapsible = false);
void EndGroupBox(const char* name);

void AmigaBevel(ImVec2 min, ImVec2 max, bool recessed);
void AmigaCircularBevel(ImVec2 center, float radius, bool recessed);
// Amiga-style widget wrappers
bool AmigaButton(const char* label, const ImVec2& size = ImVec2(0, 0));
bool AmigaCheckbox(const char* label, bool* v);
bool AmigaInputText(const char* label, char* buf, size_t buf_size);
bool AmigaRadioButton(const char* label, bool active);
bool AmigaRadioButton(const char* label, int* v, int v_button);

// Delayed tooltip on the previous widget (shown after hover delay)
void ShowHelpMarker(const char* desc);

void render_panel_about();
void render_panel_paths();
void render_panel_quickstart();
void Quickstart_ApplyDefaults(); // Helper to apply quickstart model defaults
void render_panel_configurations();
void render_panel_cpu();
void render_panel_chipset();
void render_panel_adv_chipset();
void render_panel_rom();
void render_panel_ram();
void render_panel_floppy();
void render_panel_hd();
void render_panel_expansions();
void copycpuboardmem(bool tomem);
void render_panel_rtg();
void render_panel_hwinfo();
void render_panel_display();
void render_panel_sound();
void render_panel_input();
void render_panel_io();
void render_panel_custom();
void render_panel_diskswapper();
void render_panel_misc();
// Returns true while the Misc panel's hotkey-capture modal is open.
// Used by the GUI main loop to suppress its own keyboard shortcuts while
// the user is picking a key combination.
bool HotkeyCapture_IsActive();
void render_panel_prio();
void render_panel_savestates();
void render_panel_virtual_keyboard();
void render_panel_whdload();
void render_panel_themes();
void render_panel_filter();

// Controller mapping modal (ImGui)
void ControllerMap_Open(int device, bool map_touchpad);
bool ControllerMap_IsActive();
bool ControllerMap_ConsumeResult(std::string& out_mapping);
bool ControllerMap_HandleEvent(const SDL_Event& event);
void ControllerMap_RenderModal();
