/* =====================================================================
   components.css — 可复用组件
   按钮、卡片、徽章、状态条、表单、测试面板。全部只引用语义色变量。
   ===================================================================== */

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--brand); }

/* ---- 卡片 ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-icon { font-size: 1.8rem; margin-bottom: var(--space-2); }
.card h3 { margin-bottom: var(--space-2); }
.card p { margin: 0; color: var(--text-muted); }

/* ---- 徽章 / 状态点 ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.badge-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); }
.badge-err { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, var(--border)); }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); }
.dot-err { background: var(--error); }
.dot-pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 45%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---- 状态条 ---- */
.statusbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---- 表单 ---- */
.field { margin-bottom: var(--space-4); }
.field label { display: block; margin-bottom: var(--space-2); font-weight: 600; font-size: var(--fs-sm); }
.input, .select, .textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.select { width: auto; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); outline: none; }
.textarea { min-height: 120px; resize: vertical; }
.form-hint { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--space-1); }

/* ---- 测试面板 / 结果日志 ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.metrics {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
}
.metric .value { font-size: var(--fs-xl); font-weight: 800; font-family: var(--font-mono); color: var(--brand); }
.metric .label { font-size: var(--fs-sm); color: var(--text-muted); }

.log {
  background: #0d1117;
  color: #c9d1d9;
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log .ok { color: #3fb950; }
.log .err { color: #f85149; }
.log .info { color: #58a6ff; }

/* ---- 进度条 ---- */
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress > span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.3s ease; }

/* ---- 图集 ---- */
.gallery-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.gallery-item {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  aspect-ratio: 4 / 3;
}
.gallery-item svg { width: 100%; height: 100%; display: block; }

/* ---- 页内内容排版（子页面通用） ---- */
.page { padding: var(--space-5) 0 var(--space-6); }
.page-title { margin-bottom: var(--space-2); }
.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--space-5); }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-5) 0; }

/* ---- 环境信息表 ---- */
.env-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.env-table th, .env-table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.env-table th { color: var(--text-muted); font-weight: 600; width: 140px; white-space: nowrap; }
.env-table td { font-family: var(--font-mono); word-break: break-all; }
