/**
 * 高级图表增强样式
 * 包含：缩放提示、时间选择器、导出工具栏、对比统计面板
 */

/* ══════════════════════════════════════
   缩放提示
   ══════════════════════════════════════ */
.zoom-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.65);
  color: #a1a1aa;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
  font-family: 'Outfit', sans-serif;
}

.zoom-hint:hover,
.chart-container:hover .zoom-hint {
  opacity: 1 !important;
}

/* 图表容器（需要 position:relative 以定位提示） */
.chart-container {
  position: relative;
}

.chart-container canvas {
  cursor: grab;
}

.chart-container canvas:active {
  cursor: grabbing;
}

/* ══════════════════════════════════════
   时间范围选择器
   ══════════════════════════════════════ */
.time-range-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.trp-label {
  font-size: 12px;
  color: #71717a;
  font-weight: 500;
  margin-right: 4px;
  white-space: nowrap;
}

.trp-presets {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.trp-preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #a1a1aa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: 'Outfit', sans-serif;
}

.trp-preset-btn .icon {
  font-size: 11px;
}

.trp-preset-btn:hover {
  background: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
  transform: translateY(-1px);
}

.trp-preset-btn.active {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.25), rgba(99, 102, 241, 0.25));
  border-color: rgba(167, 139, 250, 0.5);
  color: #e9d5ff;
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.15);
  font-weight: 600;
}

/* 自定义日期范围 */
.trp-custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.trp-date-input {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fafafa;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  font-family: 'JetBrains Mono', monospace;
}

.trp-date-input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

/* Webkit 日期输入样式优化 */
.trp-date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.trp-separator {
  color: #52525b;
  font-size: 12px;
}

.trp-apply-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}

.trp-apply-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.trp-toggle-btn {
  padding: 7px 12px;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #71717a;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
  white-space: nowrap;
}

.trp-toggle-btn:hover {
  border-color: rgba(167, 139, 250, 0.4);
  color: #a78bfa;
}

.trp-toggle-btn.active {
  border-style: solid;
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* ══════════════════════════════════════
   导出工具栏
   ══════════════════════════════════════ */
.export-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.export-label {
  font-size: 12px;
  color: #71717a;
  font-weight: 500;
  margin-right: 4px;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #a1a1aa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Outfit', sans-serif;
  white-space: nowrap;
}

.export-btn .btn-icon {
  font-size: 13px;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.export-btn.png-btn:hover {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.export-btn.jpeg-btn:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.export-btn.csv-btn:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.export-btn.copy-btn:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.export-btn:active {
  transform: scale(0.96);
}

/* ══════════════════════════════════════
   对比统计增强面板
   ══════════════════════════════════════ */
.compare-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.compare-stat-card {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
}

.compare-stat-card:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.compare-stat-card .label {
  display: block;
  font-size: 11px;
  color: #71717a;
  margin-bottom: 6px;
}

.compare-stat-card .value {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #e4e4e7;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-stat-card .rate {
  display: block;
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.compare-stat-card.best {
  border-left: 3px solid #22c55e;
}

.compare-stat-card.worst {
  border-left: 3px solid #ef4444;
}

.compare-stat-card.spread {
  border-left: 3px solid #a78bfa;
}

/* ══════════════════════════════════════
   图表区域包装器（用于缩放容器）
   ══════════════════════════════════════ */
.chart-wrapper-zoomable {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.chart-wrapper-zoomable::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to top, rgba(28, 25, 23, 0.4), transparent);
  pointer-events: none;
  z-index: 1;
}

/* ══════════════════════════════════════
   动画效果
   ══════════════════════════════════════ */

@keyframes zoomPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.zoom-hint.pulse {
  animation: zoomPulse 2s infinite;
}

@keyframes exportFadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.export-toolbar {
  animation: exportFadeIn 0.3s ease-out;
}

@keyframes presetSlideIn {
  from { opacity: 0; transform: translateX(-5px); }
  to { opacity: 1; transform: translateX(0); }
}

.trp-preset-btn {
  animation: presetSlideIn 0.2s ease-out backwards;
}

.trp-preset-btn:nth-child(1) { animation-delay: 0.02s; }
.trp-preset-btn:nth-child(2) { animation-delay: 0.04s; }
.trp-preset-btn:nth-child(3) { animation-delay: 0.06s; }
.trp-preset-btn:nth-child(4) { animation-delay: 0.08s; }
.trp-preset-btn:nth-child(5) { animation-delay: 0.10s; }
.trp-preset-btn:nth-child(6) { animation-delay: 0.12s; }

/* ══════════════════════════════════════
   响应式适配
   ══════════════════════════════════════ */
@media (max-width: 768px) {
  .time-range-picker {
    padding: 8px 10px;
    gap: 4px;
  }

  .trp-preset-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .trp-preset-btn span:not(.icon) {
    /* 移动端只显示图标 */
    display: none;
  }

  .trp-toggle-btn span:not(:first-child) {
    display: none;
  }

  .export-toolbar {
    gap: 4px;
    padding: 8px 10px;
  }

  .export-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .export-label {
    display: none;
  }

  .compare-stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .compare-stat-card {
    padding: 10px 12px;
  }

  .zoom-hint {
    font-size: 10px;
    padding: 3px 8px;
  }
}

@media (max-width: 480px) {
  .trp-presets {
    width: 100%;
    justify-content: space-between;
  }

  .trp-preset-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 4px;
  }
}
