/* ── Loop Pipeline Visualizer ── */

#loop-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0d0d1a;
  font-size: 12px;
  min-height: 0;
}

#loop-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #2a2a4a;
  align-items: center;
  flex-shrink: 0;
  background: #1a1a2e;
}

.loop-filter-btn {
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  color: #565f89;
  padding: 4px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: 0.15s;
}
.loop-filter-btn:hover {
  border-color: #7dcfff;
  color: #a9b1d6;
}
.loop-filter-btn.active {
  background: #7dcfff15;
  border-color: #7dcfff;
  color: #7dcfff;
}

#loop-autoscroll {
  margin-left: auto;
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  color: #565f89;
  padding: 4px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: 0.15s;
}
#loop-autoscroll:hover {
  border-color: #7dcfff;
  color: #a9b1d6;
}
#loop-autoscroll.active {
  background: #7dcfff15;
  border-color: #7dcfff;
  color: #7dcfff;
}

#loop-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-family: 'Fira Code', Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: #2a2a4a transparent;
}

/* ── Turn container ── */
.loop-turn {
  margin-bottom: 12px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
  animation: loop-fadein 0.3s ease;
}

.loop-turn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #1a1a2e;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  color: #a9b1d6;
  transition: background 0.15s;
}
.loop-turn-header:hover {
  background: #2a2a4a;
}

.loop-turn-icon {
  font-size: 14px;
}

.loop-turn-toggle {
  margin-left: auto;
  color: #565f89;
  font-size: 10px;
}

.loop-turn-body {
  padding: 8px 12px;
}

.loop-turn-body.loop-collapsed {
  display: none;
}

/* ── Nodes ── */
.loop-node {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 2px;
  border-left: 2px solid #565f89;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.loop-node:hover {
  background: #1a1a2e55;
}

.loop-node-icon {
  flex-shrink: 0;
  font-size: 13px;
  width: 18px;
  text-align: center;
}

.loop-node-summary {
  flex: 1;
  color: #a9b1d6;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.4;
}

/* ── Spinner ── */
.loop-spinner {
  display: inline-block;
  animation: loop-spin 1s linear infinite;
  color: #7dcfff;
}

@keyframes loop-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Streaming bubble ── */
.loop-node.loop-streaming {
  background: #7dcfff08;
  border-left-color: #7dcfff;
}

/* ── Executing tool ── */
.loop-node.loop-executing {
  background: #e0af6808;
  border-left-color: #e0af68;
}

/* ── Detail panel ── */
.loop-detail-panel {
  margin-top: 8px;
  padding: 8px 12px;
  background: #0d0d1a;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  animation: loop-fadein 0.2s ease;
}

.loop-detail-section {
  margin-bottom: 8px;
}
.loop-detail-section:last-child {
  margin-bottom: 0;
}

.loop-detail-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #565f89;
  font-weight: 600;
  margin-bottom: 2px;
}

.loop-detail-pre {
  margin: 0;
  padding: 6px 8px;
  background: #1a1a2e;
  border-radius: 4px;
  font-family: 'Fira Code', Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #c0caf5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.loop-show-more {
  background: none;
  border: 1px solid #2a2a4a;
  color: #7dcfff;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  margin-top: 4px;
  transition: 0.15s;
}
.loop-show-more:hover {
  border-color: #7dcfff;
  background: #7dcfff10;
}

/* ── Tooltip ── */
.loop-tooltip {
  pointer-events: none;
  z-index: 9999;
}

/* ── Hint ── */
.loop-hint {
  color: #565f89;
  text-align: center;
  padding: 40px 20px;
  font-size: 13px;
}

/* ── Reconnect banner ── */
.loop-reconnect {
  animation: loop-fadein 0.3s ease;
}

/* ── Animations ── */
@keyframes loop-fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   LIGHT MODE OVERRIDES
   ═══════════════════════════════════════════════ */
body.light-mode .loop-show-more {
  color: #cc6a28;
  border-color: #ffdec4;
}
body.light-mode .loop-show-more:hover {
  border-color: #ff8c42;
  background: #ffeee0;
}
body.light-mode .loop-node:hover {
  background: #fff5eb;
}
body.light-mode .loop-node.loop-streaming {
  background: #fff5eb;
  border-left-color: #ff8c42;
}
body.light-mode .loop-node.loop-executing {
  background: #fff5eb;
  border-left-color: #d4873a;
}
body.light-mode .loop-spinner {
  color: #ff8c42;
}
