<div class="content" id="statistics_content">
    <!-- Active Trades Section -->
    <div class="stats-section">
        <h4>Active Trades</h4>
        <div class="trades-summary-grid">
            <div class="trades-summary-item">
                <span class="trades-summary-label">Total</span>
                <span class="trades-summary-value" id="stat_active_trades">0</span>
            </div>
            <div class="trades-summary-item">
                <span class="trades-summary-label">Paper</span>
                <span class="trades-summary-value paper" id="stat_paper_trades">0</span>
            </div>
            <div class="trades-summary-item">
                <span class="trades-summary-label">Live</span>
                <span class="trades-summary-value live" id="stat_live_trades">0</span>
            </div>
            <div class="trades-summary-item">
                <span class="trades-summary-label">Total P/L</span>
                <span class="trades-summary-value" id="stat_trades_pl">$0.00</span>
            </div>
        </div>
    </div>

    <hr>

    <!-- Running Strategies Section -->
    <div class="stats-section">
        <h4>Running Strategies</h4>
        <div id="running_strategies_list">
            <p class="no-data-msg">No strategies running</p>
        </div>
    </div>

    <hr>

    <!-- Selected Strategy Stats -->
    <div class="stats-section" id="selected_strategy_stats" style="display: none;">
        <h4>Strategy Performance</h4>
        <div class="stats-grid">
            <div class="stat-item">
                <span class="stat-label">Starting Balance</span>
                <span class="stat-value" id="stat_starting_balance">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">Current Balance</span>
                <span class="stat-value" id="stat_current_balance">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">P&L</span>
                <span class="stat-value" id="stat_pnl">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">P&L %</span>
                <span class="stat-value" id="stat_pnl_pct">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">Total Trades</span>
                <span class="stat-value" id="stat_total_trades">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">Open Positions</span>
                <span class="stat-value" id="stat_open_positions">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">Win Rate</span>
                <span class="stat-value" id="stat_win_rate">-</span>
            </div>
            <div class="stat-item">
                <span class="stat-label">Runtime</span>
                <span class="stat-value" id="stat_runtime">-</span>
            </div>
        </div>

        <!-- Mini Equity Curve -->
        <div id="mini_equity_chart" style="height: 100px; margin-top: 10px;"></div>
    </div>

    <hr>

    <!-- Trade History Section -->
    <div class="stats-section">
        <h4>Recent Trades</h4>
        <div id="trade_history_list" class="trade-history">
            <p class="no-data-msg">No trades yet</p>
        </div>
    </div>

    <!-- Activity Log -->
    <div class="stats-section">
        <h4>Activity Log</h4>
        <div id="activity_log" class="activity-log">
            <p class="no-data-msg">No activity</p>
        </div>
    </div>
</div>

<style>
    #statistics_content {
        min-height: 200px;
    }

    .stats-section {
        margin-bottom: 10px;
    }

    .stats-section h4 {
        margin: 5px 0;
        color: #333;
        font-size: 13px;
        border-bottom: 1px solid #ddd;
        padding-bottom: 3px;
    }

    .no-data-msg {
        color: #888;
        font-style: italic;
        font-size: 12px;
        margin: 5px 0;
    }

    /* Trades summary grid */
    .trades-summary-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        margin: 8px 0;
    }

    .trades-summary-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 6px;
        background: #f5f5f5;
        border-radius: 4px;
    }

    .trades-summary-label {
        font-size: 10px;
        color: #666;
        text-transform: uppercase;
    }

    .trades-summary-value {
        font-size: 14px;
        font-weight: bold;
        font-family: monospace;
        color: #333;
    }

    .trades-summary-value.paper {
        color: #9e9e9e;
    }

    .trades-summary-value.live {
        color: #2196f3;
    }

    .trades-summary-value.positive {
        color: #2e7d32;
    }

    .trades-summary-value.negative {
        color: #c62828;
    }

    /* Running strategies list */
    .running-strategy-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 8px;
        margin: 3px 0;
        background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
        border-radius: 5px;
        cursor: pointer;
        font-size: 12px;
        transition: background 0.2s;
    }

    .running-strategy-item:hover {
        background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
    }

    .running-strategy-item.selected {
        background: linear-gradient(135deg, #bbdefb, #90caf9);
        border: 1px solid #2196f3;
    }

    .strategy-name {
        font-weight: bold;
        color: #2e7d32;
    }

    .strategy-mode {
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 3px;
        background: #4caf50;
        color: white;
    }

    .strategy-mode.live {
        background: #f44336;
    }

    .strategy-mode.live.testnet {
        background: #ff9800;
    }

    .strategy-balance {
        font-family: monospace;
        color: #1565c0;
    }

    /* Stats grid */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .stat-item {
        display: flex;
        justify-content: space-between;
        padding: 3px 5px;
        background: #f5f5f5;
        border-radius: 3px;
        font-size: 11px;
    }

    .stat-label {
        color: #666;
    }

    .stat-value {
        font-weight: bold;
        font-family: monospace;
    }

    .stat-value.positive {
        color: #2e7d32;
    }

    .stat-value.negative {
        color: #c62828;
    }

    /* Trade history */
    .trade-history {
        max-height: 120px;
        overflow-y: auto;
    }

    .trade-item {
        display: grid;
        grid-template-columns: 50px 1fr 60px 70px;
        gap: 5px;
        padding: 4px 6px;
        margin: 2px 0;
        background: #fafafa;
        border-radius: 3px;
        font-size: 11px;
        border-left: 3px solid #ccc;
    }

    .trade-item.buy {
        border-left-color: #4caf50;
    }

    .trade-item.sell {
        border-left-color: #f44336;
    }

    .trade-side {
        font-weight: bold;
    }

    .trade-side.buy {
        color: #2e7d32;
    }

    .trade-side.sell {
        color: #c62828;
    }

    /* Activity log */
    .activity-log {
        max-height: 80px;
        overflow-y: auto;
        font-size: 10px;
    }

    .activity-item {
        padding: 2px 5px;
        margin: 1px 0;
        background: #f9f9f9;
        border-radius: 2px;
        display: flex;
        gap: 5px;
    }

    .activity-time {
        color: #888;
        font-family: monospace;
    }

    .activity-msg {
        color: #333;
    }

    .activity-item.error {
        background: #ffebee;
        color: #c62828;
    }

    .activity-item.trade {
        background: #e8f5e9;
    }
</style>
