/**
 * 洞察子账户图表样式
 * 保持简洁优雅，与现有系统风格一致
 */

/* 图表网格布局 - 优化的响应式设计 */
.insight-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* 图表容器基础样式 */
.chart-container {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.chart-container:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

/* 图表头部 */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}

/* 图表主体 */
.chart-body {
  position: relative;
  height: 300px;
}

/* 特定图表样式调整 */
.trend-chart .chart-body {
  height: 320px;
}

.distribution-chart .chart-body {
  height: 280px;
}

.users-chart .chart-body {
  height: 360px;
}

.hourly-chart .chart-body {
  height: 280px;
}

.efficiency-chart .chart-body {
  height: 300px;
}

/* 全宽图表（成本趋势） */
.trend-chart {
  grid-column: 1 / -1;
}

/* 响应式设计 - 三层优化 */

/* 大屏幕 (>1280px) - 2列网格，成本趋势全宽，其他图表2x2 */
@media (min-width: 1281px) {
  .insight-charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .trend-chart {
    grid-column: 1 / -1;
  }
}

/* 中等屏幕 (768px - 1280px) - 单列布局，更流畅 */
@media (max-width: 1280px) and (min-width: 769px) {
  .insight-charts-grid {
    grid-template-columns: 1fr;
  }

  .trend-chart {
    grid-column: 1;
  }

  /* 中屏适当减小高度 */
  .chart-body {
    height: 280px;
  }

  .users-chart .chart-body {
    height: 340px;
  }
}

/* 小屏幕 (≤768px) - 单列布局，紧凑样式 */
@media (max-width: 768px) {
  .insight-charts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .trend-chart {
    grid-column: 1;
  }

  .chart-container {
    padding: 1rem;
    border-radius: 0.5rem;
  }

  .chart-body {
    height: 240px;
  }

  .trend-chart .chart-body {
    height: 260px;
  }

  /* 饼图需要更多垂直空间用于底部图例 */
  .distribution-chart .chart-body {
    height: 380px;
  }

  .users-chart .chart-body {
    height: 280px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .chart-title {
    font-size: 0.9375rem;
  }
}

/* 超小屏幕 (≤480px) - 进一步优化 */
@media (max-width: 480px) {
  .insight-charts-grid {
    gap: 0.75rem;
  }

  .chart-container {
    padding: 0.875rem;
  }

  .chart-body {
    height: 220px;
  }

  .trend-chart .chart-body {
    height: 240px;
  }

  /* 饼图需要更多垂直空间 */
  .distribution-chart .chart-body {
    height: 360px;
  }

  .users-chart .chart-body {
    height: 260px;
  }
}

/* 加载状态动画 */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #6b7280;
}

.chart-loading::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 空状态 */
.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #9ca3af;
}

.chart-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.chart-empty p {
  margin: 0;
  font-size: 0.875rem;
}

/* 图表工具提示样式覆盖 */
.chart-container canvas {
  max-width: 100%;
}

/* 动画 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 统计卡片网格优化（已存在的部分） */
.insight-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* 确保与现有的 stat-card 样式兼容 */
.insight-stats .stat-card {
  min-height: auto;
}

/* 图表切换动画 */
.chart-container {
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 深色模式支持（如果需要） */
@media (prefers-color-scheme: dark) {
  .chart-container {
    background: #1f2937;
    border-color: #374151;
  }

  .chart-title {
    color: #f3f4f6;
  }

  .chart-header {
    border-bottom-color: #374151;
  }
}