/* ============================================
   图表容器样式 - charts.css
   专门处理各类图表的布局、响应式和交互样式
   ============================================ */

/* === 图表通用容器 === */
.chart-wrapper {
  position: relative;
  width: 100%;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  transition: box-shadow var(--transition-base);
}

.chart-wrapper:hover {
  box-shadow: var(--shadow-md);
}

.chart-wrapper-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.chart-wrapper-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}

.chart-wrapper-subtitle {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin-top: var(--space-xs);
}

/* === 图表工具栏 === */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.chart-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-light);
}

.chart-toolbar-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(255, 99, 132, 0.05);
}

.chart-toolbar-btn svg {
  width: 16px;
  height: 16px;
}

/* === 图表类型切换标签 === */
.chart-type-tabs {
  display: flex;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  margin-bottom: var(--space-md);
}

.chart-type-tab {
  padding: var(--space-xs) var(--space-md);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-light);
}

.chart-type-tab.active {
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* === 时间范围选择器 === */
.time-range-selector {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.time-range-btn {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.time-range-btn:hover,
.time-range-btn.active {
  border-color: var(--secondary);
  background: rgba(54, 162, 235, 0.08);
  color: var(--secondary);
}

/* === 图表画布区域 === */
.chart-area {
  position: relative;
  width: 100%;
  min-height: 250px;
}

.chart-area canvas {
  width: 100% !important;
  max-height: 400px;
}

/* === 图表图例 === */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-light);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.chart-legend-item:hover {
  opacity: 0.7;
}

.chart-legend-item.disabled {
  opacity: 0.3;
  text-decoration: line-through;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* === 雷达图容器 === */
.radar-chart-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.radar-chart-area {
  min-height: 300px;
}

.radar-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.radar-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.radar-checkbox:hover {
  border-color: var(--secondary);
  background: rgba(54, 162, 235, 0.05);
}

.radar-checkbox input[type="checkbox"] {
  accent-color: var(--primary);
}

@media (min-width: 768px) {
  .radar-chart-container {
    grid-template-columns: 2fr 1fr;
  }
}

/* === 热力图 === */
.heatmap-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap-grid {
  display: grid;
  gap: 2px;
  min-width: 600px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  transition: transform var(--transition-fast);
  cursor: pointer;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 1;
}

/* === 词云容器 === */
.wordcloud-container {
  width: 100%;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

.wordcloud-item {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
}

.wordcloud-item:hover {
  background: rgba(255, 99, 132, 0.1);
  transform: scale(1.1);
}

/* === 桑基图容器 === */
.sankey-container {
  width: 100%;
  min-height: 400px;
  overflow-x: auto;
}

.sankey-container svg {
  min-width: 800px;
}

/* === 散点图气泡 === */
.bubble-tooltip {
  position: absolute;
  background: var(--text);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
  white-space: nowrap;
}

.bubble-tooltip.visible {
  opacity: 1;
}

/* === 迷你图表（Sparklines） === */
.sparkline {
  display: inline-block;
  width: 80px;
  height: 24px;
  vertical-align: middle;
}

.sparkline svg {
  width: 100%;
  height: 100%;
}

/* === 数据指标卡片 === */
.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: all var(--transition-base);
}

.metric-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-xs);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin-bottom: var(--space-sm);
}

.metric-change {
  font-size: var(--text-xs);
  font-weight: 600;
}

.metric-change.positive {
  color: #4BC0C0;
}

.metric-change.negative {
  color: var(--primary);
}

/* === 图表加载骨架屏 === */
.chart-skeleton {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  animation: pulse 1.5s ease-in-out infinite;
}

.chart-skeleton-bar {
  height: 20px;
  background: var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
}

.chart-skeleton-bar:nth-child(1) { width: 80%; }
.chart-skeleton-bar:nth-child(2) { width: 60%; }
.chart-skeleton-bar:nth-child(3) { width: 90%; }
.chart-skeleton-bar:nth-child(4) { width: 45%; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === 图表全屏模式 === */
.chart-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  background: var(--bg);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
}

.chart-fullscreen .chart-area {
  flex: 1;
}

.chart-fullscreen-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  transition: all var(--transition-fast);
}

.chart-fullscreen-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}
