#pragma once

#include <map>
#include <string>
#include <vector>

#include <QWidget>

#include "BehaviorKind.h"
#include "ShipLayout.h"
#include "ShipStatsCalculator.h"

struct GameConfig;
class QLabel;

class ShipStatsPanel : public QWidget
{
    Q_OBJECT

public:
    explicit ShipStatsPanel(const GameConfig* config, QWidget* parent = nullptr);

    void refresh(const std::string& shipId,
                 const std::vector<PlacedModule>& modules);

    void refreshFromLive(const ShipStats& stats, float currentHp);

    // Displays the ship's current top-priority behavior (REQ-UI-SHIP-BEHAVIOR).
    void setBehavior(BehaviorKind kind);

    void setThreatCost(double cost);
    void setDebugDrawEnabled(bool enabled);

private:
    void applyStats(const ShipStats& stats, const QString& hpText);

    const GameConfig* m_config;
    bool m_debugDraw = false;

    QLabel* m_behaviorLabel;
    QLabel* m_hpLabel;
    QLabel* m_speedLabel;
    QLabel* m_sensorRangeLabel;
    QLabel* m_mainAccelLabel;
    QLabel* m_maneuveringAccelLabel;
    QLabel* m_angularAccelLabel;
    QLabel* m_maxRotSpeedLabel;
    QLabel* m_cargoCapacityLabel;

    QWidget* m_weaponSection;
    QLabel*  m_weaponDpsLabel;
    QLabel*  m_weaponRangeLabel;

    QWidget* m_salvageSection;
    QLabel*  m_salvageRateLabel;
    QLabel*  m_salvageRangeLabel;

    QWidget* m_repairSection;
    QLabel*  m_repairRateLabel;
    QLabel*  m_repairRangeLabel;

    QLabel* m_threatCostLabel;
};
