#pragma once

#include <QMainWindow>
#include <QStatusBar>
#include <QLabel>
#include <QTimer>
#include "ui/user_list_widget.h"
#include "ui/chat_widget.h"
#include "ui/video_grid_widget.h"
#include "connection/client_connection.h"
#include "config/client_config.h"
#include <memory>

namespace scar {

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    explicit MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

private slots:
    void showLoginDialog();
    void onConnected();
    void onDisconnected();
    void onLoginSuccess(const QString& token);
    void onLoginFailed(const QString& error);
    void onMessageReceived(const QString& sender, const QString& content);
    void onSendMessage(const QString& content);
    void updateClock();
    void updateConnectionStatus(const QString& status);
    void updateUserCount(int count);

private:
    void setupUI();
    void setupStatusBar();
    void applyDarkTheme();
    void createMenuBar();
    
    // UI Widgets
    UserListWidget* userListWidget_;
    ChatWidget* chatWidget_;
    VideoGridWidget* videoGridWidget_;
    
    // Status bar labels
    QLabel* connectionStatusLabel_;
    QLabel* userCountLabel_;
    QLabel* clockLabel_;
    
    // Connection
    std::unique_ptr<ClientConnection> connection_;
    std::unique_ptr<ClientConfig> config_;
    
    // Timer for clock
    QTimer* clockTimer_;
    
    QString currentUsername_;
};

} // namespace scar
