/* ========================================================
   AIFast Bench - 现代高质感设计系统
   ======================================================== */

:root {
  --bg-primary: #0b0f17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: #1a2234;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.15), transparent 70%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

/* 全局重置 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 10%, rgba(139, 92, 246, 0.08), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* 布局容器 */
.app-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 32px 64px 32px;
}

/* 顶部导航与品牌栏 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 28px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  font-size: 22px;
}

.brand-info h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff !important;
  background: none !important;
  -webkit-text-fill-color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 选项卡导航 Tabs */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: rgba(26, 34, 52, 0.6);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  margin-bottom: 28px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #ffffff;
  background: var(--accent-blue);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* 统一卡片样式 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* 按钮设计 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.45);
}

.btn-gradient {
  background: var(--gradient-brand);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}
.btn-gradient:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* 输入框与表单 */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}

/* 徽章 Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-green { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-gray { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* ========================================================
   平台管理区 (Platform Manager)
   ======================================================== */
.platform-manager {
  margin-bottom: 28px;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.platform-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.platform-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.platform-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.platform-card-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.platform-card-url {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

/* 选中的全局模型池条 */
.model-pool-bar {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
}

.pool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pool-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  font-size: 12px;
  font-weight: 600;
  color: #bfdbfe;
}

.pool-tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
  transition: opacity 0.2s;
}
.pool-tag-remove:hover {
  opacity: 1;
  color: #f87171;
}

/* ========================================================
   压测看板与大表格 (Benchmark & Metrics)
   ======================================================== */
.benchmark-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: rgba(17, 24, 39, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 排行榜可视化柱状图 */
.leaderboard-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.chart-row {
  display: grid;
  grid-template-columns: 240px 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.chart-row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
}

.chart-model-info {
  display: flex;
  flex-direction: column;
}

.chart-model-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-platform-name {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-bar-track {
  height: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.chart-bar-fill.rank-1 {
  background: linear-gradient(90deg, #ec4899, #8b5cf6, #3b82f6);
}

.chart-stats-value {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-align: right;
  color: #38bdf8;
}

/* 性能指标大表格 */
.metrics-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.metrics-table th {
  background: rgba(30, 41, 59, 0.6);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.metrics-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.metrics-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.tps-highlight {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #38bdf8;
}

.ttft-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.ttft-fast { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.ttft-medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.ttft-slow { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ========================================================
   多模型对比竞技场 (Showdown Arena)
   ======================================================== */
.arena-header {
  margin-bottom: 24px;
}

.arena-prompt-selector {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.prompt-chip {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.prompt-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.prompt-chip.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-blue);
  color: #93c5fd;
  font-weight: 600;
}

.arena-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.arena-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 720px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s;
}

.arena-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.arena-card-header {
  padding: 14px 18px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.arena-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.arena-card-body {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 14px;
}

/* 深度思考过程抽屉 (Reasoning Drawer) */
.reasoning-drawer {
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.reasoning-toggle {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #c4b5fd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: rgba(139, 92, 246, 0.1);
  user-select: none;
}

.reasoning-content {
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.2);
}

/* 实时渲染沙箱模式 (SVG / HTML) */
.render-sandbox-wrapper {
  flex: 1;
  min-height: 380px;
  border-radius: var(--radius-md);
  background: #0d1117;
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.render-inline-svg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.render-inline-svg svg {
  max-width: 100%;
  max-height: 380px;
  width: auto;
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.4));
  border-radius: var(--radius-sm);
}

.render-sandbox-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.code-view-wrapper {
  flex: 1;
  background: #0d1117;
  border-radius: var(--radius-md);
  padding: 12px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: #e6edf3;
  white-space: pre-wrap;
  border: 1px solid var(--border-color);
}

/* ========================================================
   模态探测面板 (Modalities & Prober)
   ======================================================== */
.probe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.probe-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.probe-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.probe-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

/* 弹窗 Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(15, 23, 42, 0.4);
}

/* 优雅浮动通知 Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border-color);
}

.toast-info { background: rgba(30, 41, 59, 0.95); color: #93c5fd; border-color: rgba(59, 130, 246, 0.4); }
.toast-success { background: rgba(6, 78, 59, 0.95); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.toast-error { background: rgba(127, 29, 29, 0.95); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-mono { font-family: var(--font-mono); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* 响应式适配 */
@media (max-width: 768px) {
  .app-container {
    padding: 16px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .nav-tabs {
    overflow-x: auto;
    width: 100%;
  }
  .arena-grid {
    grid-template-columns: 1fr;
  }
  .chart-row {
    grid-template-columns: 140px 1fr 100px;
  }
}
