{#
    Health signals card partial for deal view.
    Expected variables:
      - vm: DealViewViewModel instance (provides health summary methods)
      - deal: Deal entity
#}
{% set health = vm.getHealthSummary() %}

<div class="dv-card" id="dvCardHealth">
    <div class="dv-card-header" onclick="DealView.toggleCard('dvCardHealth')">
        <h3>Health Signals <span class="dv-chevron"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z"/></svg></span></h3>
    </div>
    <div class="dv-card-body">
        <div class="dv-health-grid">
            <div class="dv-health-item">
                <div class="dv-label">Last Updated</div>
                <div class="dv-value dv-{{ health.updatedColor }}">{{ health.updatedDaysAgo == 0 ? 'Today' : health.updatedDaysAgo ~ ' day' ~ (health.updatedDaysAgo > 1 ? 's' : '') ~ ' ago' }}</div>
            </div>
            <div class="dv-health-item">
                <div class="dv-label">Days to Close</div>
                {% if health.daysToClose is not null %}
                    <div class="dv-value dv-{{ health.closeColor }}">{{ health.daysToClose < 0 ? (0 - health.daysToClose) ~ ' days overdue' : health.daysToClose ~ ' day' ~ (health.daysToClose != 1 ? 's' : '') }}</div>
                {% else %}
                    <div class="dv-value dv-gray">Not set</div>
                {% endif %}
            </div>
            <div class="dv-health-item">
                <div class="dv-label">Overdue Tasks</div>
                <div class="dv-value dv-{{ health.overdueColor }}">{{ health.overdueCount }}</div>
            </div>
            <div class="dv-health-item">
                <div class="dv-label">Confidence</div>
                <div class="dv-value dv-{{ health.confidenceColor }}">{{ deal.getConfidence() is not null ? deal.getConfidence() ~ '%' : 'Not set' }}</div>
            </div>
        </div>
    </div>
</div>
