{% extends "service_monitor/base.html" %}
{% block title %}监测目标{% endblock %}
{% block content %}
<div class="section-head">
    <div class="section-title">📊 监测目标</div>
    {% if is_admin %}
    <a href="/service-monitor/targets" class="btn-add">+ 目标管理</a>
    {% endif %}
</div>

{% if targets %}
<div class="target-grid">
    {% for t in targets %}
    <div class="target-card">
        <div class="target-card-head">
            <div class="target-icon">{{ '🖥️' if t.type == 'local' else '🌐' }}</div>
            <div class="target-name">{{ t.name }}</div>
            {% if t.built_in %}<span class="target-badge">内置</span>{% endif %}
        </div>
        <div class="target-meta">
            {{ '本机容器' if t.type == 'local' else (t.host ~ ':' ~ t.port ~ '  ' ~ t.username) }}
        </div>
        {% if is_admin %}
        <div class="target-actions">
            <a href="/service-monitor/run/{{ t.id }}?suite=quick" class="btn-suite btn-quick">⚡ 快速巡检</a>
            <a href="/service-monitor/run/{{ t.id }}?suite=full" class="btn-suite btn-full">🔍 全量巡检</a>
        </div>
        {% else %}
        <div class="target-actions">
            <span class="btn-suite btn-quick" style="cursor:default; opacity:.5;">⚡ 快速巡检</span>
            <span class="btn-suite btn-full" style="cursor:default; opacity:.5;">🔍 全量巡检</span>
        </div>
        {% endif %}
    </div>
    {% endfor %}
</div>
{% else %}
<div class="empty">📭 暂无监测目标</div>
{% endif %}
{% endblock %}

{% block extra_css %}
<style>
    /* 目标卡片网格 */
    .target-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 36px; }
    .target-card {
        background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
        border: 1px solid var(--gray-200);
    }
    .target-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
    .target-icon { font-size: 28px; }
    .target-name { font-size: 16px; font-weight: 700; color: var(--gray-900); }
    .target-meta { font-size: 13px; color: var(--gray-500); margin-bottom: 14px; }
    .target-actions { display: flex; gap: 8px; }
    .btn-suite {
        flex: 1; padding: 8px 0; border-radius: 8px; font-size: 13px; font-weight: 600;
        text-align: center; text-decoration: none; cursor: pointer; border: none;
    }
    .btn-quick { background: var(--gray-100); color: var(--gray-700); }
    .btn-quick:hover { background: var(--gray-200); }
    .btn-full { background: #eef2ff; color: var(--primary); }
    .btn-full:hover { background: #e0e7ff; }
    .target-badge {
        display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 4px;
        background: var(--gray-100); color: var(--gray-500); margin-left: auto;
    }

    @media screen and (max-width: 1024px) { .target-grid { grid-template-columns: repeat(2, 1fr); } }
    @media screen and (max-width: 768px) { .target-grid { grid-template-columns: 1fr; } }
</style>
{% endblock %}