#ifndef mice_gui_h
#define mice_gui_h

#include <3ds.h>
#include <citro2d.h>
#include <stdbool.h>
#include "metadata.h"

/* GUI color definitions */
#define GUI_COLOR_BG_TOP      C2D_Color32(20, 20, 30, 255)
#define GUI_COLOR_BG_BOTTOM   C2D_Color32(15, 15, 25, 255)
#define GUI_COLOR_TEXT        C2D_Color32(255, 255, 255, 255)
#define GUI_COLOR_TEXT_DIM    C2D_Color32(180, 180, 180, 255)
#define GUI_COLOR_ACCENT      C2D_Color32(100, 150, 255, 255)
#define GUI_COLOR_HIGHLIGHT   C2D_Color32(50, 80, 150, 255)

/* Screen dimensions */
#define TOP_SCREEN_WIDTH  400
#define TOP_SCREEN_HEIGHT 240
#define BOTTOM_SCREEN_WIDTH  320
#define BOTTOM_SCREEN_HEIGHT 240

/**
 * Initialize the GUI system
 * 
 * \return 0 on success, -1 on failure
 */
int guiInit(void);

/**
 * Clean up and exit the GUI system
 */
void guiExit(void);

/**
 * Begin rendering a frame
 */
void guiBeginFrame(void);

/**
 * End rendering a frame and display it
 */
void guiEndFrame(void);

/**
 * Clear the top screen
 */
void guiClearTopScreen(void);

/**
 * Clear the bottom screen
 */
void guiClearBottomScreen(void);

/**
 * Display metadata on the top screen
 * 
 * \param metadata  Pointer to metadata structure
 * \param filename  Filename to display if no title is available
 */
void guiDisplayMetadata(struct metadata_t* metadata, const char* filename);

/**
 * Display log messages on the top screen
 * 
 * \param messages  Array of message strings
 * \param count     Number of messages
 * \param scroll    Scroll offset for messages
 */
void guiDisplayLog(const char** messages, int count, int scroll);

/**
 * Display file list on the bottom screen
 * 
 * \param files       Array of filenames
 * \param count       Number of files
 * \param selected    Index of selected file
 * \param scroll      Scroll offset
 */
void guiDisplayFileList(const char** files, int count, int selected, int scroll);

/**
 * Display playback controls and status on the bottom screen
 * 
 * \param isPlaying   Whether playback is active
 * \param isPaused    Whether playback is paused
 * \param position    Current position in seconds
 * \param duration    Total duration in seconds
 */
void guiDisplayPlaybackStatus(bool isPlaying, bool isPaused, float position, float duration);

/**
 * Display version text
 * 
 * \param version  Version string to display
 */
void guiDisplayVersion(const char* version);

/**
 * Draw a simple text string at specified position
 * 
 * \param screen  Target screen (GFX_TOP or GFX_BOTTOM)
 * \param x       X coordinate
 * \param y       Y coordinate
 * \param text    Text to display
 * \param color   Text color
 * \param scale   Text scale (default 0.5f)
 */
void guiDrawText(gfxScreen_t screen, float x, float y, const char* text, u32 color, float scale);

/**
 * Display progress bar on top screen
 * 
 * \param position  Current position in seconds
 * \param duration  Total duration in seconds
 */
void guiDisplayProgressBar(float position, float duration);

/**
 * Display current directory path on bottom screen
 * 
 * \param path  Current directory path
 */
void guiDisplayCurrentPath(const char* path);

#endif
