#pragma once

#include <QWidget>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QListWidget>
#include <QComboBox>
#include <QCheckBox>
#include <QRadioButton>
#include <QButtonGroup>
#include <QVariant>
#include "services/accountservice.h"

class SettingsView : public QWidget {
    Q_OBJECT

public:
    explicit SettingsView(QWidget *parent = nullptr);
    ~SettingsView() override = default;

    void setAccountService(AccountService *service);

signals:
    void accountAddRequested();
    void accountEditRequested(int accountId);
    void accountDeleteRequested(int accountId);
    void themeChanged(const QString &theme);
    void settingChanged(const QString &key, const QVariant &value);

private slots:
    void onAccountListChanged();
    void loadAccounts();
    void onEditClicked();
    void onDeleteClicked();
    void onAccountSelectionChanged();

private:
    void setupUI();
    QWidget* createAccountsTab();
    QWidget* createGeneralTab();
    QWidget* createAppearanceTab();

    QTabWidget *m_tabWidget;
    QListWidget *m_accountList;
    QComboBox *m_syncIntervalCombo;
    QButtonGroup *m_themeGroup;
    QPushButton *m_editBtn;
    QPushButton *m_addBtn;
    QPushButton *m_deleteBtn;

    AccountService *m_accountService;
    int m_selectedAccountId;
};