/* ==========================================================================
   Charts - Styles for chart containers and visualizations
   ========================================================================== */

.chart-container {
  position: relative;
  width: 100%;
}

.chart-container-sm {
  height: 200px;
}

.chart-container-md {
  height: 300px;
}

.chart-container-lg {
  height: 400px;
}

.chart-container-xl {
  height: 500px;
}

/* Chart Card Wrapper */
.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.chart-card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.chart-card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

.chart-card-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Chart Legend */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.chart-legend-dot-blue {
  background: var(--chart-blue);
}

.chart-legend-dot-green {
  background: var(--chart-green);
}

.chart-legend-dot-orange {
  background: var(--chart-orange);
}

.chart-legend-dot-purple {
  background: var(--chart-purple);
}

.chart-legend-dot-teal {
  background: var(--chart-teal);
}

.chart-legend-dot-red {
  background: var(--chart-red);
}

/* Inline Legend (horizontal) */
.chart-legend-inline {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-top: var(--space-4);
}

/* Sparkline Container */
.sparkline {
  width: 100%;
  height: 40px;
}

.sparkline-sm {
  height: 24px;
}

.sparkline-lg {
  height: 60px;
}

/* Mini Chart in Cards */
.mini-chart {
  width: 80px;
  height: 32px;
}

/* Donut Chart Container */
.donut-chart-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.donut-chart {
  position: relative;
}

.donut-chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-chart-center-value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  line-height: 1;
}

.donut-chart-center-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

/* Funnel Chart */
.funnel-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.funnel-stage {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.funnel-bar-container {
  flex: 1;
  position: relative;
}

.funnel-bar {
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--space-4);
  transition: width var(--transition-slow);
}

.funnel-bar-value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-inverse);
}

.funnel-label {
  width: 150px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  flex-shrink: 0;
}

.funnel-conversion {
  width: 80px;
  text-align: right;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

/* Heatmap */
.heatmap-container {
  overflow-x: auto;
}

.heatmap {
  display: grid;
  gap: 2px;
}

.heatmap-cell {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-primary);
  transition: transform var(--transition-fast);
}

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

.heatmap-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  text-align: center;
}

/* Heatmap Color Intensity */
.heatmap-cell-0 { background: var(--color-background); }
.heatmap-cell-1 { background: #E3F2FD; }
.heatmap-cell-2 { background: #BBDEFB; }
.heatmap-cell-3 { background: #90CAF9; }
.heatmap-cell-4 { background: #64B5F6; }
.heatmap-cell-5 { background: #42A5F5; color: white; }
.heatmap-cell-6 { background: #2196F3; color: white; }
.heatmap-cell-7 { background: #1E88E5; color: white; }
.heatmap-cell-8 { background: #1976D2; color: white; }
.heatmap-cell-9 { background: #1565C0; color: white; }

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--color-background);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar-blue { background: var(--color-blue); }
.progress-bar-green { background: var(--color-green); }
.progress-bar-orange { background: var(--color-orange); }
.progress-bar-purple { background: var(--color-purple); }
.progress-bar-red { background: var(--color-red); }

/* Comparison Bars */
.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.comparison-bar-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.comparison-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comparison-bar-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.comparison-bar-value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

/* Chart Loading State */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background);
  border-radius: var(--radius-lg);
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* Chart Tooltip Override (for Chart.js) */
.chartjs-tooltip {
  background: var(--color-surface) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-dropdown) !important;
  padding: var(--space-3) var(--space-4) !important;
  font-family: var(--font-family) !important;
}

/* Trend Arrow */
.trend-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.trend-arrow-up {
  color: var(--color-green);
}

.trend-arrow-down {
  color: var(--color-red);
}

.trend-arrow svg {
  width: 14px;
  height: 14px;
}

/* Chart Metric Tabs - Pill-style tabs for switching chart metrics */
.chart-metric-tabs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  background: var(--color-background);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  margin-bottom: var(--space-3);
}

.chart-metric-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chart-metric-tab:hover {
  color: var(--color-text-primary);
  background: var(--color-surface);
}

.chart-metric-tab.active {
  color: var(--color-text-primary);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* Responsive - stack tabs on mobile */
@media (max-width: 640px) {
  .chart-metric-tabs {
    flex-wrap: wrap;
  }

  .chart-metric-tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }
}
