/* 组合回测样式 */

/* 回测配置区 */
.backtest-config {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.backtest-config__row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.backtest-config__item {
  flex: 1;
  min-width: 150px;
}

.backtest-config__label {
  font-size: 11px;
  color: #71717a;
  margin-bottom: 4px;
  display: block;
}

.backtest-config__input,
.backtest-config__select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e4e4e7;
  font-size: 13px;
  box-sizing: border-box;
}

.backtest-config__input:focus,
.backtest-config__select:focus {
  outline: none;
  border-color: #6366f1;
}

.backtest-config__input::placeholder {
  color: #52525b;
}

/* 基金列表 */
.backtest-funds {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.backtest-funds__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.backtest-funds__title {
  font-size: 13px;
  font-weight: 600;
  color: #e4e4e7;
}

.backtest-funds__weight-sum {
  font-size: 11px;
  color: #a1a1aa;
}

.backtest-funds__weight-sum--ok {
  color: #22c55e;
}

.backtest-funds__weight-sum--error {
  color: #ef4444;
}

.backtest-fund-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 8px;
}

.backtest-fund-item:last-child {
  margin-bottom: 0;
}

.backtest-fund-item__info {
  flex: 1;
  min-width: 0;
}

.backtest-fund-item__name {
  font-size: 13px;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backtest-fund-item__code {
  font-size: 11px;
  color: #71717a;
  font-family: 'JetBrains Mono', monospace;
}

.backtest-fund-item__weight {
  display: flex;
  align-items: center;
  gap: 8px;
}

.backtest-fund-item__weight-input {
  width: 60px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #e4e4e7;
  font-size: 12px;
  text-align: center;
}

.backtest-fund-item__weight-label {
  font-size: 11px;
  color: #71717a;
}

.backtest-fund-item__remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  color: #ef4444;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.backtest-fund-item__remove:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* 搜索基金 */
.backtest-search {
  position: relative;
  margin-bottom: 12px;
}

.backtest-search__input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e4e4e7;
  font-size: 13px;
  box-sizing: border-box;
}

.backtest-search__input:focus {
  outline: none;
  border-color: #6366f1;
}

.backtest-search__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #27272a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}

.backtest-search__item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s;
}

.backtest-search__item:last-child {
  border-bottom: none;
}

.backtest-search__item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.backtest-search__item-name {
  font-size: 13px;
  color: #e4e4e7;
}

.backtest-search__item-code {
  font-size: 11px;
  color: #71717a;
  font-family: 'JetBrains Mono', monospace;
}

.backtest-search__empty {
  padding: 20px;
  text-align: center;
  color: #71717a;
  font-size: 12px;
}

/* 运行按钮 */
.backtest-run-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}

.backtest-run-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.backtest-run-btn:disabled {
  background: #3f3f46;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 结果区 */
.backtest-result {
  margin-top: 20px;
}

.backtest-result__title {
  font-size: 14px;
  font-weight: 600;
  color: #e4e4e7;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 主布局：左侧指标 + 右侧图表 */
.backtest-result__main {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.backtest-result__sidebar {
  width: 180px;
  flex-shrink: 0;
}

.backtest-result__chart-area {
  flex: 1;
  min-width: 0;
}

/* 指标卡片 - 纵向排列 */
.backtest-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backtest-metric {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.backtest-metric__label {
  font-size: 11px;
  color: #71717a;
}

.backtest-metric__value {
  font-size: 15px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.backtest-metric__value--positive {
  color: #22c55e;
}

.backtest-metric__value--negative {
  color: #ef4444;
}

.backtest-metric__value--neutral {
  color: #e4e4e7;
}

.backtest-metric__value--warning {
  color: #f59e0b;
}

/* 图表区 */
.backtest-chart {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 16px;
  height: 280px;
}

.backtest-chart__title {
  font-size: 12px;
  color: #a1a1aa;
  margin-bottom: 12px;
}

.backtest-chart__canvas {
  width: 100%;
  height: 220px;
}

/* 基准对比 */
.backtest-benchmark {
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.backtest-benchmark__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.backtest-benchmark__name {
  font-size: 13px;
  font-weight: 600;
  color: #a78bfa;
}

.backtest-benchmark__badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.backtest-benchmark__badge--win {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.backtest-benchmark__badge--lose {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.backtest-benchmark__stats {
  display: flex;
  gap: 24px;
}

.backtest-benchmark__stat-item {
  font-size: 12px;
  color: #71717a;
}

.backtest-benchmark__stat-value {
  color: #e4e4e7;
  font-family: 'JetBrains Mono', monospace;
}

/* 贡献度分析 */
.backtest-contribution {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 16px;
}

.backtest-contribution__title {
  font-size: 13px;
  font-weight: 600;
  color: #e4e4e7;
  margin-bottom: 12px;
}

.backtest-contribution__item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  margin-bottom: 8px;
}

.backtest-contribution__item:last-child {
  margin-bottom: 0;
}

.backtest-contribution__name {
  font-size: 13px;
  font-weight: 500;
  color: #e4e4e7;
  margin-bottom: 8px;
}

.backtest-contribution__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #a1a1aa;
}

.backtest-contribution__value {
  font-size: 12px;
  color: #a1a1aa;
  font-family: 'JetBrains Mono', monospace;
}

/* 模式切换 */
.backtest-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.backtest-mode-btn {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #a1a1aa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.backtest-mode-btn--active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #a78bfa;
}

/* 空状态 */
.backtest-empty {
  text-align: center;
  padding: 40px;
  color: #71717a;
}

.backtest-empty__icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.backtest-empty__text {
  font-size: 13px;
  margin-bottom: 16px;
}

.backtest-load-holdings-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.backtest-load-holdings-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.backtest-funds__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.backtest-load-holdings-btn--small {
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  color: #a78bfa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.backtest-load-holdings-btn--small:hover {
  background: rgba(99, 102, 241, 0.25);
}

/* 加载状态 */
.backtest-loading {
  text-align: center;
  padding: 60px;
  color: #71717a;
}

.backtest-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
