<div class="worker-health-component">
    <!-- Summary Stats -->
    <div class="worker-summary">
        <div class="worker-summary__item">
            <span class="worker-summary__value">{{ activeWorkers }}</span>
            <span class="worker-summary__label">Active Workers</span>
        </div>
        <div class="worker-summary__divider"></div>
        <div class="worker-summary__item">
            <span class="worker-summary__value">{{ jobsInProgress }}</span>
            <span class="worker-summary__label">Jobs in Progress</span>
        </div>
    </div>

    <!-- Worker Details List -->
    <if condition="workerDetails && count(workerDetails) > 0">
        <div class="worker-list">
            <for items="workerDetails" as="workerId,worker">
                <div class="worker-item">
                    <div class="worker-item__header">
                        <div class="worker-item__title">
                            <span class="worker-item__hostname">{{ worker.hostname }}</span>
                            <span class="worker-item__pid">PID: {{ worker.processId }}</span>
                        </div>
                        <if condition="worker.healthy">
                            <span class="worker-badge worker-badge--healthy">✓ Healthy</span>
                        </if>
                        <if condition="!worker.healthy">
                            <span class="worker-badge worker-badge--unhealthy">⚠ Unhealthy</span>
                        </if>
                    </div>
                    <div class="worker-item__body">
                        <div class="worker-stat">
                            <span class="worker-stat__label">Jobs:</span>
                            <span class="worker-stat__value">{{ worker.jobs }} / {{ worker.maxJobs }}</span>
                        </div>
                        <div class="worker-stat">
                            <span class="worker-stat__label">CPU:</span>
                            <span class="worker-stat__value">{{ worker.cpuUsage }}%</span>
                        </div>
                        <div class="worker-stat">
                            <span class="worker-stat__label">Memory:</span>
                            <span class="worker-stat__value">{{ worker.memoryUsageMb }} MB</span>
                        </div>
                        <div class="worker-stat">
                            <span class="worker-stat__label">Last Heartbeat:</span>
                            <span class="worker-stat__value">{{ worker.lastHeartbeat }}</span>
                        </div>
                    </div>
                </div>
            </for>
        </div>
    </if>

    <if condition="!workerDetails || count(workerDetails) === 0">
        <div class="worker-empty">
            <div class="worker-empty__icon">🔌</div>
            <div class="worker-empty__text">No active workers</div>
        </div>
    </if>

    <div class="component-footer">
        <span class="component-footer__text">Last updated: {{ lastUpdated }}</span>
        <span class="component-footer__badge">Updates every 5s</span>
    </div>
</div>

<style>
.worker-health-component {
    padding: 0;
}

.worker-summary {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.worker-summary__item {
    text-align: center;
}

.worker-summary__value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.worker-summary__label {
    display: block;
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.worker-summary__divider {
    width: 1px;
    height: 3rem;
    background: rgba(255,255,255,0.3);
}

.worker-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.worker-item {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

.worker-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.worker-item__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.worker-item__title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.worker-item__hostname {
    font-weight: 600;
    font-size: 0.875rem;
}

.worker-item__pid {
    font-size: 0.75rem;
    color: #666;
}

.worker-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.worker-badge--healthy {
    background: #d4edda;
    color: #155724;
}

.worker-badge--unhealthy {
    background: #f8d7da;
    color: #721c24;
}

.worker-item__body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.worker-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.worker-stat__label {
    color: #666;
}

.worker-stat__value {
    font-weight: 600;
}

.worker-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}

.worker-empty__icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.worker-empty__text {
    font-size: 1rem;
}

.component-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #666;
}

.component-footer__badge {
    background: #007bff;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
}
</style>
