/* ======================================
   AI Agent 工作看板 - 样式
   白色主题 + 数据可视化
   ====================================== */

:root {
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-dim: #4a5568;
    --text-muted: #a0aec0;
    --blue: #3b82f6;
    --blue-light: #eff6ff;
    --green: #10b981;
    --green-light: #ecfdf5;
    --red: #ef4444;
    --red-light: #fef2f2;
    --yellow: #f59e0b;
    --yellow-light: #fffbeb;
    --purple: #8b5cf6;
    --cyan: #0891b2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.06), 0 4px 10px rgba(0,0,0,0.03);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== 顶部导航 ===== */
.nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.nav-brand .emoji { font-size: 26px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
}
.nav-links a:hover {
    color: var(--blue);
    background: var(--blue-light);
}
.nav-links a.active {
    color: var(--blue);
    background: var(--blue-light);
    font-weight: 600;
}
.nav-live { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.nav-live .dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== 主容器 ===== */
.main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.card-header h2 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--text); }
.card-header h2 .icon { font-size: 20px; }

/* ===== 统计卡片组 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon.green { background: var(--green-light); color: var(--green); }
.stat-icon.red { background: var(--red-light); color: var(--red); }
.stat-icon.purple { background: #f5f3ff; color: var(--purple); }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1.1; color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 进度条（成功率） ===== */
.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}
.progress-fill.green { background: var(--green); }
.progress-fill.red { background: var(--red); }
.progress-fill.blue { background: var(--blue); }

/* ===== 任务列表 ===== */
.task-list { }
.task-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: #f8fafc; margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 8px; }

.task-platform {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    color: white;
}
.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.task-title a { color: var(--blue); text-decoration: none; }
.task-title a:hover { text-decoration: underline; }
.task-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.task-meta span { display: flex; align-items: center; gap: 4px; }

.task-status { flex-shrink: 0; }

/* 状态标签 */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: var(--green-light); color: #059669; }
.badge-failed { background: var(--red-light); color: #dc2626; }
.badge-pending { background: var(--yellow-light); color: #d97706; }
.badge-cancelled { background: #f1f5f9; color: #94a3b8; }

/* ===== 平台统计网格 ===== */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.platform-item {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}
.platform-item:hover { background: #f1f5f9; }
.platform-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.platform-info { flex: 1; }
.platform-name { font-size: 14px; font-weight: 600; color: var(--text); }
.platform-count { font-size: 12px; color: var(--text-muted); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 16px; text-align: left; }
th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid #f1f5f9; color: var(--text); }
tr:hover td { background: #f8fafc; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
    background: #fff;
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-input::placeholder { color: var(--text-muted); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
}
.btn-primary { background: var(--blue); }
.btn-primary:hover { background: #2563eb; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.btn-success { background: var(--green); }
.btn-success:hover { background: #059669; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-outline {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ===== 筛选栏 ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}
.filter-bar .form-input,
.filter-bar .form-select {
    width: auto;
    min-width: 140px;
}

/* ===== 设置页 ===== */
.settings-section { margin-bottom: 32px; }
.settings-section h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.api-key-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.api-key-row code {
    font-family: "Fira Code", "Cascadia Code", monospace;
    font-size: 13px;
    color: var(--cyan);
    flex: 1;
    word-break: break-all;
}
.api-key-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ===== 图表容器 ===== */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
    margin-top: 16px;
    background: #fff;
    border-radius: var(--radius-sm);
}
.chart-container canvas { width: 100% !important; }

/* ===== 代码块 ===== */
pre {
    background: #f8fafc !important;
    border: 1px solid var(--border);
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 20px;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-dim);
    border: 1px solid var(--border);
    background: #fff;
}
.pagination a:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.pagination .active { background: var(--blue); border-color: var(--blue); color: white; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .nav { padding: 0 12px; }
    .nav-brand { font-size: 15px; }
    .nav-links a { padding: 6px 10px; font-size: 12px; }
    .main { padding: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 24px; }
    .platform-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar .form-input,
    .filter-bar .form-select { width: 100%; }
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== 内容预览 ===== */
.content-preview {
    font-size: 13px;
    color: var(--text-dim);
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 6px;
    max-height: 60px;
    overflow: hidden;
    line-height: 1.5;
    border: 1px solid #f1f5f9;
}
.error-msg {
    font-size: 12px;
    color: var(--red);
    background: var(--red-light);
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 4px;
}

/* ===== 元数据展开 ===== */
.meta-toggle {
    font-size: 11px;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
}
.meta-content {
    display: none;
    font-size: 11px;
    color: var(--text-dim);
    font-family: monospace;
    background: #f8fafc;
    padding: 6px 10px;
    border-radius: 4px;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid #f1f5f9;
}

/* ===== API 文档表格 ===== */
.card table th { background: #f8fafc; }
.card table td { color: var(--text); }
.card table td code { color: var(--cyan); background: #f0fdfa; padding: 1px 5px; border-radius: 3px; font-size: 13px; }
.card pre { color: var(--text-dim); }
