/* AI 营养师 v2 · 内部测试 UI · 共享样式 */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --sidebar-bg: #1d1d1f;
  --sidebar-surface: #2c2c2e;
  --sidebar-border: #3a3a3c;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-on-dark: #f5f5f7;
  --text-on-dark-secondary: #98989d;
  --accent: #0a84ff;
  --accent-hover: #0071e3;
  --border: #d2d2d7;
  --border-light: #e5e5ea;
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --intent-high: #ff453a;
  --intent-medium: #ff9f0a;
  --intent-low: #86868b;
  --status-pending: #ff9f0a;
  --status-claimed: #0a84ff;
  --status-in-progress: #5e5ce6;
  --status-done: #30d158;
  --status-abandoned: #86868b;
  --status-expired: #ff453a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ============== 顶部导航条 ============== */
.topbar {
  height: 52px;
  background: var(--sidebar-bg);
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.topbar .nav {
  display: flex;
  gap: 4px;
  margin-left: 24px;
}
.topbar .nav a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-on-dark-secondary);
  transition: all 0.15s;
}
.topbar .nav a:hover {
  background: var(--sidebar-surface);
  color: var(--text-on-dark);
}
.topbar .nav a.active {
  background: var(--accent);
  color: white;
}
.topbar .spacer { flex: 1; }
.topbar .meta {
  font-size: 12px;
  color: var(--text-on-dark-secondary);
}

/* ============== 徽标 ============== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
}
.badge-mode-real {
  background: rgba(48, 209, 88, 0.15);
  color: #30d158;
  border: 1px solid rgba(48, 209, 88, 0.3);
}
.badge-mode-stub {
  background: rgba(255, 159, 10, 0.15);
  color: #ff9f0a;
  border: 1px solid rgba(255, 159, 10, 0.3);
}
.badge-mode-unknown {
  background: rgba(134, 134, 139, 0.15);
  color: #86868b;
  border: 1px solid rgba(134, 134, 139, 0.3);
}
.badge-intent-high { background: rgba(255, 69, 58, 0.12); color: var(--intent-high); }
.badge-intent-medium { background: rgba(255, 159, 10, 0.12); color: var(--intent-medium); }
.badge-intent-low { background: rgba(134, 134, 139, 0.12); color: var(--intent-low); }
.badge-intent-none { background: rgba(134, 134, 139, 0.08); color: var(--text-tertiary); }

.badge-status {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-status-pending { background: rgba(255, 159, 10, 0.15); color: #b25000; }
.badge-status-claimed { background: rgba(10, 132, 255, 0.15); color: #004cb3; }
.badge-status-in_progress { background: rgba(94, 92, 230, 0.15); color: #3a37a8; }
.badge-status-done { background: rgba(48, 209, 88, 0.15); color: #1a7a36; }
.badge-status-abandoned { background: rgba(134, 134, 139, 0.15); color: #4b4b50; }
.badge-status-expired { background: rgba(255, 69, 58, 0.15); color: #b32614; }

/* source 来源徽标：chat 灰 / agent_test 蓝 / sim_test 紫 */
.badge-source-chat { background: rgba(134, 134, 139, 0.15); color: #4b4b50; }
.badge-source-agent { background: rgba(10, 132, 255, 0.15); color: #004cb3; }
.badge-source-sim { background: rgba(149, 84, 230, 0.15); color: #5e2eb8; }
.badge-source-unknown { background: rgba(134, 134, 139, 0.08); color: var(--text-tertiary); }

/* ============== 按钮 ============== */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--accent);
  color: white;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--text-tertiary); cursor: not-allowed; }
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--border-light); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #d12d2a; }
.btn.success { background: var(--success); color: white; }
.btn.success:hover { background: #28b54c; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }

/* ============== 表单 ============== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.field input, .field select, .field textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

/* ============== 卡片 ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

/* ============== 列表 ============== */
.list-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
}
.list-item:hover { background: var(--border-light); }
.list-item.active {
  background: rgba(10, 132, 255, 0.08);
  border-color: var(--accent);
}

/* ============== 折叠区 ============== */
.collapse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.collapse-toggle:hover { background: var(--border-light); color: var(--text); }
.collapse-arrow { transition: transform 0.15s; display: inline-block; }
.collapse-toggle.open .collapse-arrow { transform: rotate(90deg); }

/* ============== 调试信息块 ============== */
.debug-block {
  background: #f8f8fa;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.debug-row {
  display: flex;
  gap: 12px;
  padding: 2px 0;
}
.debug-key {
  color: var(--text-tertiary);
  min-width: 100px;
}
.debug-val { color: var(--text); word-break: break-all; }
.debug-pre {
  white-space: pre-wrap;
  word-break: break-all;
  background: white;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
}

/* ============== Toast ============== */
#toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--sidebar-bg);
  color: var(--text-on-dark);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============== 加载与空态 ============== */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.empty-state .icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ============== 通用布局 ============== */
.page {
  min-height: calc(100vh - 52px);
}
.flex-row { display: flex; gap: 12px; }
.flex-col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.text-sm { font-size: 12px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; font-weight: 600; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-mono { font-family: "SF Mono", "Menlo", monospace; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
