/* ── Dashboard Insights Widget ─────────────────────────────────────────────── */

/* Header controls: time toggle + tab strip side-by-side */
.insights-header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Time window pill-group */
.insights-time-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.insights-time-btn {
  background: none;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  transition: background 0.1s, color 0.1s;
}

.insights-time-btn:hover { color: var(--color-text-primary); }

.insights-time-btn.active {
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.10);
  color: var(--color-primary);
}

/* Tab strip */
.insights-tab-strip {
  display: flex;
  gap: var(--space-2);
}

.insights-tab {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.insights-tab.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Pro plan pill inside Chemicals tab */
.insights-plan-pill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--color-info-light);
  color: var(--color-info);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Panels */
.insights-body { padding-top: var(--space-4); }
.insights-panel { }
.insights-panel-hidden { display: none; }

/* Stat row: 4 equal tiles */
.insights-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.insights-stat-tile {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.insights-stat-tile-value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.insights-stat-tile-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.insights-stat-tile-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* Panel toolbar (metric select) */
.insights-panel-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.insights-toolbar-label {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.insights-metric-select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
}

.insights-metric-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(0,155,141,0.15);
}

/* Trend chart above the heatmap */
.insights-chart { margin-bottom: var(--space-3); }
.insights-chart:empty { display: none; }

/* Heatmap grid */
.insights-heatmap-wrap { overflow-x: auto; margin-bottom: var(--space-2); }

.insights-heatmap {
  display: grid;
  gap: 2px;
  font-size: 11px;
  min-width: 360px;
}

.insights-heatmap-corner { /* empty top-left cell */ }

.insights-heatmap-hour-label {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 10px;
  padding-bottom: 2px;
  line-height: 1.2;
}

.insights-heatmap-day-label {
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  padding-right: var(--space-2);
  white-space: nowrap;
}

.insights-heatmap-cell {
  height: 18px;
  border-radius: 2px;
  background: var(--color-surface-alt);
  cursor: default;
  transition: opacity 0.1s;
}

.insights-heatmap-cell:hover { opacity: 0.75; }

.insights-heatmap-legend {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-4);
  margin-top: var(--space-2);
  color: var(--color-text-muted);
  font-size: 10px;
}
.insights-heatmap-legend span { display: inline-flex; align-items: center; gap: 5px; }
.insights-heatmap-legend i { width: 12px; height: 8px; border-radius: 2px; }
.insights-heatmap-legend .legend-low { background: #d8efec; }
.insights-heatmap-legend .legend-normal { background: #75c9c0; }
.insights-heatmap-legend .legend-busy { background: #009b8d; }

/* Floating tooltip */
.insights-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  font-size: 12px;
  line-height: 1.5;
  padding: var(--space-2) var(--space-3);
  pointer-events: none;
  display: none;
  max-width: 200px;
}

.insights-tooltip-title {
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.insights-tooltip-row { color: var(--color-text-secondary); }

/* Loading / empty states */
.insights-loading {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: var(--space-4) 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.insights-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  padding: var(--space-8) 0;
  text-align: center;
}

/* Status badges (kept for any inline use) */
.insights-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
}

.insights-status-balanced { background: #DCFCE7; color: #16A34A; }
.insights-status-warning  { background: #FEF9C3; color: #D97706; }
.insights-status-danger   { background: #FEE2E2; color: #DC2626; }

/* Responsive */
@media (max-width: 900px) {
  .insights-stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .insights-header-controls { gap: var(--space-2); }
  .insights-stat-row { grid-template-columns: repeat(2, 1fr); }
  .insights-tab-strip { flex-wrap: wrap; }
}
