/* ──────────────────────────────────────────────────────────
   Planning Workbench — Four-panel data visualization
   Lives inside #vizDrawerContent (Analytics drawer)
   ────────────────────────────────────────────────────────── */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
  --wb-text: #231F20;
  --wb-secondary: #444441;
  --wb-muted: #5F5E5A;
  --wb-border: #D3D1C7;
  --wb-surface: #F7F5F0;
  --wb-surface-alt: #F1EFE8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wb-text: #C2C0B6;
    --wb-secondary: #6E6C65;
    --wb-muted: #6E6C65;
    --wb-border: rgba(255,255,255,0.1);
    --wb-surface: #1C1C1A;
    --wb-surface-alt: #252523;
  }
}

/* Dark mode via data-theme attribute (overrides prefers-color-scheme) */
[data-theme="dark"] {
  --wb-text: #C2C0B6;
  --wb-secondary: #6E6C65;
  --wb-muted: #6E6C65;
  --wb-border: rgba(255,255,255,0.1);
  --wb-surface: #1C1C1A;
  --wb-surface-alt: #252523;
}

/* ── Stats Row ─────────────────────────────────────────── */
.wb-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.wb-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  background: var(--wb-surface-alt);
  border-radius: 8px;
  border: 0.5px solid var(--wb-border);
}

.wb-stat-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--wb-text);
  line-height: 1.2;
}

.wb-stat-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--wb-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Two-column grid for half-width panels ─────────────── */
.wb-grid-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* ── Full-width panels ─────────────────────────────────── */
.wb-panel-full {
  width: 100%;
  margin-top: 8px;
}

.wb-panel-full:first-of-type {
  margin-top: 0;
}

/* ── Panel Chrome ──────────────────────────────────────── */
.wb-panel {
  border: 0.5px solid var(--wb-border);
  border-radius: 10px;
  background: var(--wb-surface);
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease;
}

.wb-panel-header {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  background: var(--wb-surface-alt);
  gap: 8px;
  border-bottom: 0.5px solid var(--wb-border);
  min-height: 28px;
}

.wb-panel-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wb-muted);
}

.wb-panel-meta {
  font-size: 9px;
  color: var(--wb-muted);
  opacity: 0.7;
}

.wb-panel-controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.wb-toggle-btn,
.wb-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--wb-muted);
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.wb-toggle-btn:hover,
.wb-expand-btn:hover {
  opacity: 1;
  background: var(--wb-surface);
}

.wb-panel-body {
  padding: 10px;
  overflow-x: auto;
}

/* ── Expanded (overlay) state ──────────────────────────── */
.wb-expanded {
  position: fixed !important;
  top: 60px;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  margin-top: 0 !important;
}

.wb-expanded .wb-panel-body {
  height: calc(100% - 40px);
  overflow-y: auto;
}

/* ── Empty state ───────────────────────────────────────── */
.wb-empty {
  text-align: center;
  color: var(--wb-muted);
  font-size: 11px;
  padding: 20px;
}

/* ── Sankey ─────────────────────────────────────────────── */
#wbSankeyBody {
  min-height: 250px;
  position: relative;
}

#wbSankeyChart svg {
  display: block;
}

.wb-sankey-tooltip {
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  white-space: nowrap;
}

/* ── Bubble Matrix ──────────────────────────────────────── */
.wb-bubble-matrix {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wb-bubble-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.wb-bubble-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  flex: 1;
}

.wb-bubble-corner {
  min-width: 80px;
  flex: 0 0 80px;
}

.wb-bubble-stage {
  min-width: 80px;
  flex: 0 0 80px;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.wb-bubble-ch {
  font-size: 9px;
  font-weight: 500;
  color: var(--wb-muted);
  writing-mode: horizontal-tb;
  text-align: center;
  word-break: break-word;
  padding: 0 2px;
  line-height: 1.15;
}

.wb-bubble-data {
  position: relative;
}

.wb-bubble {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.wb-bubble:hover {
  transform: scale(1.15);
}

.wb-bubble-label {
  font-size: 9px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ── Donut Array ────────────────────────────────────────── */
.wb-donut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wb-donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.wb-donut-canvas {
  display: block;
}

.wb-donut-center {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.wb-donut-total {
  font-size: 16px;
  font-weight: 500;
  color: var(--wb-text);
}

.wb-donut-stage {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin-top: 4px;
  text-transform: uppercase;
}

.wb-donut-legend {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.wb-donut-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--wb-secondary);
}

.wb-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.wb-legend-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Stacked Bar ────────────────────────────────────────── */
.wb-stacked-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wb-stacked-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
}

.wb-stacked-label {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.wb-stacked-bar-container {
  flex: 1;
  height: 20px;
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  background: var(--wb-surface-alt);
}

.wb-stacked-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8.5px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  transition: opacity 0.15s;
}

.wb-stacked-segment:hover {
  opacity: 0.85;
}

.wb-stacked-count {
  width: 30px;
  flex-shrink: 0;
  text-align: right;
  font-size: 10px;
  font-weight: 500;
  color: var(--wb-muted);
}

.wb-stacked-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 0.5px solid var(--wb-border);
}

.wb-stacked-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--wb-secondary);
}

/* ── RESPONSIVE BREAKPOINTS ────────────────────────────── */

/* Tablet: stack half-width panels */
@media (max-width: 768px) {
  .wb-grid-half {
    grid-template-columns: 1fr;
  }
  .wb-donut-grid {
    grid-template-columns: 1fr 1fr; /* keep 2x2 */
  }
}

/* Mobile: everything stacks, donuts go 1-column */
@media (max-width: 480px) {
  .wb-grid-half {
    grid-template-columns: 1fr;
  }
  .wb-donut-grid {
    grid-template-columns: 1fr;
  }
  .wb-stats-row {
    grid-template-columns: 1fr 1fr; /* 2x2 instead of 4-across */
  }
}
