/* Statistics view (workspace)
   The Statistics tab of the dataset workspace: a chart panel with a chart-type
   select, a bar chart, a legend and a data table. Reuses the workspace chrome
   (.dp-ws-*) and the console theme. */

.dp-stat-chart { padding: var(--dp-space-6); }

.dp-stat-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--dp-space-4);
  margin-bottom: var(--dp-space-5);
}

.dp-stat-chart-title {
  display: flex;
  align-items: center;
  gap: var(--dp-space-2);
  font-size: var(--dp-text-xl);
  font-weight: var(--dp-weight-bold);
  color: var(--dp-navy);
}

.dp-stat-chart-title svg { width: 1.1rem; height: 1.1rem; color: var(--dp-text-subtle); }

.dp-stat-chart-controls {
  display: flex;
  align-items: center;
  gap: var(--dp-space-3);
}

.dp-stat-chart-controls .dp-select { width: 12rem; }

/* Plot area */
.dp-stat-plot {
  display: flex;
  gap: var(--dp-space-3);
  height: 22rem;
  margin-bottom: var(--dp-space-4);
}

.dp-stat-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  width: 3.5rem;
  padding-bottom: 1.25rem;
  font-size: var(--dp-text-xs);
  color: var(--dp-text-subtle);
  font-variant-numeric: tabular-nums;
}

.dp-stat-bars {
  position: relative;
  flex: 1;
  border-left: 1px solid var(--dp-border);
  border-bottom: 1px solid var(--dp-border);
  background-image: repeating-linear-gradient(
    to top,
    transparent 0,
    transparent calc(16.666% - 1px),
    var(--dp-border) calc(16.666% - 1px),
    var(--dp-border) 16.666%
  );
}

.dp-stat-bar {
  position: absolute;
  bottom: 0;
  left: 6%;
  right: 6%;
  background: var(--dp-blue-700);
  border-radius: 2px 2px 0 0;
}

.dp-stat-toolbar {
  position: absolute;
  top: var(--dp-space-3);
  right: var(--dp-space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--dp-space-1);
  padding: var(--dp-space-1) var(--dp-space-2);
  background: var(--dp-surface);
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius-md);
  box-shadow: var(--dp-shadow-sm);
}

.dp-stat-toolbar button {
  display: inline-flex;
  border: 0;
  background: transparent;
  color: var(--dp-text-muted);
  cursor: pointer;
  padding: 3px;
}

.dp-stat-toolbar svg { width: 1rem; height: 1rem; }

/* Legend */
.dp-stat-legend {
  padding-top: var(--dp-space-4);
  border-top: 1px solid var(--dp-border);
  font-size: var(--dp-text-sm);
  color: var(--dp-text-muted);
}

.dp-stat-legend a { color: var(--dp-link); text-decoration: none; }
.dp-stat-legend b { color: var(--dp-navy); }

/* Data table */
.dp-stat-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--dp-space-4);
  font-size: var(--dp-text-sm);
}

.dp-stat-table th {
  text-align: left;
  padding: var(--dp-space-3) var(--dp-space-2);
  font-weight: var(--dp-weight-bold);
  color: var(--dp-navy);
  border-bottom: 1px solid var(--dp-border);
}

.dp-stat-table th.dp-stat-num,
.dp-stat-table td.dp-stat-num { text-align: right; font-variant-numeric: tabular-nums; }

.dp-stat-table td {
  padding: var(--dp-space-3) var(--dp-space-2);
  border-bottom: 1px solid var(--dp-border);
  color: var(--dp-text-muted);
}

.dp-stat-name {
  display: inline-flex;
  align-items: center;
  gap: var(--dp-space-2);
  color: var(--dp-navy);
}

.dp-stat-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: var(--dp-radius-full);
  background: var(--dp-blue-700);
}

.dp-stat-copy { margin-top: var(--dp-space-5); }
