/* components.css — 可复用组件样式 */

/* ===== 图标 ===== */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon svg { width: 100%; height: 100%; }

/* ===== 导航栏 ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  margin: calc(var(--space-6) * -1) calc(var(--space-5) * -1) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-brand { display: flex; align-items: center; gap: var(--space-2); }
.nav-logo { color: var(--color-accent); width: 20px; height: 20px; }
.nav-title { font-size: var(--text-md); font-weight: var(--fw-semibold); letter-spacing: -0.2px; }
.nav-links { display: flex; gap: var(--space-1); }
.nav-link {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--fg-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease);
  position: relative;
}
.nav-link:hover { color: var(--fg-primary); background: var(--bg-surface); }
.nav-link.active {
  color: var(--fg-primary);
  font-weight: var(--fw-semibold);
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -17px;
  left: var(--space-3);
  right: var(--space-3);
  height: 2px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
}
.nav-actions { display: flex; align-items: center; }
.theme-toggle {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}
.theme-toggle:hover { color: var(--color-accent); border-color: var(--border-strong); }
.theme-toggle .icon { width: 17px; height: 17px; }

/* ===== 卡片 / 面板 ===== */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-4) var(--space-2);
}
.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-title .icon { color: var(--color-neutral); width: 16px; height: 16px; }
.card-hint { font-size: var(--text-xs); color: var(--fg-tertiary); font-weight: var(--fw-regular); }
.card-body { padding: var(--space-2) var(--space-4) var(--space-4); }

/* ===== Stat 卡片 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}
.stat-value {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--fg-primary);
}
.stat-value.pos { color: var(--color-long); }
.stat-value.neg { color: var(--color-short); }
.stat-label {
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  margin-top: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ===== 数据表格 ===== */
.table-scroll {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
  border-radius: var(--radius-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  padding: var(--table-padding-y) var(--table-padding-x);
  text-align: right;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border-default);
}
.data-table td {
  padding: var(--table-padding-y) var(--table-padding-x);
  text-align: right;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle);
}
.data-table th.left, .data-table td.left { text-align: left; }
.data-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-elevated);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
}
.data-table tr:hover td { background: var(--bg-surface); }
.data-table tr.row-long td { border-left: 3px solid var(--color-long); }
.data-table tr.row-short td { border-left: 3px solid var(--color-short); }
.data-table tr.row-warn { background: var(--bg-warn); }

/* ===== Badge / Tag ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--fg-secondary);
  white-space: nowrap;
}
.badge-long { color: var(--color-long); background: var(--bg-long); border-color: transparent; }
.badge-short { color: var(--color-short); background: var(--bg-short); border-color: transparent; }
.badge-warn { color: var(--color-warn); background: var(--bg-warn); border-color: transparent; }
.badge-neutral { color: var(--color-neutral); background: var(--bg-neutral); border-color: transparent; }
.badge-info { color: var(--color-info); background: var(--bg-info); border-color: transparent; }
.badge-hold { color: var(--color-hold); background: var(--bg-hold); border-color: transparent; }
/* outline 风格 badge（session 状态等）*/
.badge.outline { background: transparent; }
.badge.outline.badge-long { border-color: var(--color-long); }
.badge.outline.badge-short { border-color: var(--color-short); }
.badge.outline.badge-warn { border-color: var(--color-warn); }
.badge.outline.badge-neutral { border-color: var(--color-neutral); }
.badge.outline.badge-info { border-color: var(--color-info); }

/* ===== 按钮 ===== */
.btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--duration-fast) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}
.btn-secondary:hover { background: var(--bg-accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 分段控制器 ===== */
.segmented {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  font-family: inherit;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  white-space: nowrap;
}
.seg-btn.active {
  background: var(--bg-elevated);
  color: var(--fg-primary);
  box-shadow: var(--shadow-sm);
}
.seg-btn:not(.active):hover { color: var(--fg-primary); }

/* ===== Range Slider ===== */
input[type=range] {
  width: 100%;
  height: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
input[type=checkbox] { accent-color: var(--color-accent); }

/* ===== 输入框 / 选择框 ===== */
.input, .select, input[type=number], input[type=text], select {
  width: 100%;
  background: var(--bg-surface);
  color: var(--fg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease);
}
.input:focus, .select:focus, input[type=number]:focus, input[type=text]:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
}
input:disabled, select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== 参数组 ===== */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label {
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field label .val { color: var(--color-accent); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
}

/* ===== 配置 Tab ===== */
.config-tabs {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  margin-bottom: var(--space-4);
}
.cfg-tab {
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  font-family: inherit;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
}
.cfg-tab.active {
  background: var(--bg-elevated);
  color: var(--fg-primary);
  box-shadow: var(--shadow-sm);
}
.cfg-tab:not(.active):hover { color: var(--fg-primary); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 64px;
  right: var(--space-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--fg-primary);
  opacity: 0;
  transform: translateX(100%);
  transition: all var(--duration-normal) var(--ease-out);
  pointer-events: auto;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--color-long); }
.toast-success .icon { color: var(--color-long); }
.toast-error { border-left: 3px solid var(--color-short); }
.toast-error .icon { color: var(--color-short); }
.toast-info { border-left: 3px solid var(--color-info); }
.toast-info .icon { color: var(--color-info); }

/* ===== Skeleton ===== */
.skeleton-row {
  height: var(--table-row-height);
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-1);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--fg-tertiary);
}
.empty-state .empty-icon { opacity: 0.4; margin-bottom: var(--space-2); width: 28px; height: 28px; }
.empty-text { font-size: var(--text-md); color: var(--fg-secondary); }
.empty-hint { font-size: var(--text-sm); margin-top: var(--space-1); }

/* ===== 警告横幅 ===== */
.warn-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-warn);
  color: var(--color-warn);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-warn);
}
.warn-banner .icon { color: var(--color-warn); flex-shrink: 0; }

/* ===== 状态栏 ===== */
.status-bar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.countdown {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  color: var(--color-accent);
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
}
.countdown .label { font-size: var(--text-xs); color: var(--fg-secondary); font-weight: var(--fw-regular); }
