/* ============================================================
   Bridge Loop — Control Plane Dashboard
   ============================================================ */

/* ── Loop Header ── */
.bl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.bl-goal {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 200px;
}
.bl-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.bl-status-pending { background: var(--s3); color: var(--muted); }
.bl-status-running { background: var(--green-dim); color: var(--green); }
.bl-status-paused { background: var(--yellow-dim); color: var(--yellow); }
.bl-status-complete { background: var(--green-dim); color: var(--green); }
.bl-status-failed { background: var(--red-dim); color: var(--red); }
.bl-status-cancelled { background: var(--s3); color: var(--muted); }

/* ── Loop Stats ── */
.bl-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.bl-stat {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.bl-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.bl-stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.bl-stat.verified .bl-stat-num { color: var(--green); }
.bl-stat.running .bl-stat-num { color: var(--blue); }
.bl-stat.failed .bl-stat-num { color: var(--red); }
.bl-stat.blocked .bl-stat-num { color: var(--yellow); }

/* ── Controls ── */
.bl-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.bl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--s1);
  color: var(--text);
  transition: all 0.15s;
}
.bl-btn:hover { border-color: var(--accent); background: var(--accent-glow); }
.bl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.bl-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.bl-btn-primary:hover { background: var(--accent-hover); }
.bl-btn-danger { color: var(--red); border-color: rgba(196, 96, 96, 0.3); }
.bl-btn-danger:hover { background: var(--red-dim); border-color: var(--red); }

/* ── Node List ── */
.bl-nodes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bl-node {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: all 0.2s;
}
.bl-node:hover { border-color: var(--border-2); box-shadow: var(--sh-sm); }
.bl-node-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.bl-node-status.queued { background: var(--muted2); }
.bl-node-status.blocked { background: var(--yellow); }
.bl-node-status.running { background: var(--blue); animation: bl-pulse 1.5s infinite; }
.bl-node-status.verifying { background: var(--purple); animation: bl-pulse 1.5s infinite; }
.bl-node-status.verified { background: var(--green); }
.bl-node-status.failed { background: var(--red); }
.bl-node-status.cancelled { background: var(--muted2); }

@keyframes bl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.bl-node-content { flex: 1; min-width: 0; }
.bl-node-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.bl-node-objective {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 4px;
}
.bl-node-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--muted2);
}
.bl-node-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.bl-node-deps {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 4px;
}
.bl-dep-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-size: 9.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--muted);
}
.bl-dep-chip.verified { background: var(--green-dim); color: var(--green); border-color: rgba(90, 138, 106, 0.3); }
.bl-dep-chip.failed { background: var(--red-dim); color: var(--red); border-color: rgba(196, 96, 96, 0.3); }

.bl-node-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}
.bl-node-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--muted);
  transition: all 0.15s;
}
.bl-node-btn:hover { border-color: var(--accent); color: var(--accent); }
.bl-node-btn.pass { color: var(--green); border-color: rgba(90, 138, 106, 0.3); }
.bl-node-btn.pass:hover { background: var(--green-dim); }
.bl-node-btn.fail { color: var(--red); border-color: rgba(196, 96, 96, 0.3); }
.bl-node-btn.fail:hover { background: var(--red-dim); }

/* ── Dependency Graph ── */
.bl-graph {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  min-height: 200px;
  position: relative;
}
.bl-graph-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.bl-graph-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.bl-graph-node {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--s2);
  color: var(--muted);
}
.bl-graph-node.verified { background: var(--green-dim); color: var(--green); border-color: rgba(90, 138, 106, 0.3); }
.bl-graph-node.running { background: var(--blue-dim); color: var(--blue); border-color: rgba(90, 138, 170, 0.3); }
.bl-graph-node.failed { background: var(--red-dim); color: var(--red); border-color: rgba(196, 96, 96, 0.3); }
.bl-graph-node.blocked { background: var(--yellow-dim); color: var(--yellow); border-color: rgba(184, 154, 74, 0.3); }
.bl-graph-arrow {
  color: var(--muted2);
  font-size: 14px;
}

/* ── Events Timeline ── */
.bl-events {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1rem;
  max-height: 300px;
  overflow-y: auto;
}
.bl-event {
  display: flex;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
}
.bl-event:last-child { border-bottom: none; }
.bl-event-time {
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}
.bl-event-text { color: var(--text); }

/* ── Create Loop Form ── */
.bl-create-form {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.bl-form-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}
.bl-form-row label {
  font-size: 11px;
  color: var(--muted);
  min-width: 80px;
  font-weight: 500;
}
.bl-form-row input, .bl-form-row textarea, .bl-form-row select {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--s2);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.bl-form-row input:focus, .bl-form-row textarea:focus { border-color: var(--accent); }
.bl-form-row textarea { min-height: 60px; resize: vertical; }

/* ── Loop List Sections ── */
.bl-section {
  margin-bottom: 1rem;
}
.bl-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.bl-section-header:hover { color: var(--accent); }
.bl-section-toggle {
  font-size: 10px;
  color: var(--muted2);
  width: 12px;
  flex-shrink: 0;
}
.bl-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.bl-section-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted2);
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.05rem 0.5rem;
  min-width: 18px;
  text-align: center;
}

/* ── Empty State ── */
.bl-empty {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 13px;
}

/* ── Loading ── */
.bl-loading {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 12px;
}

/* ── Dependency Graph Rows ── */
.bl-graph-inner { flex-direction: column; align-items: stretch; }
.bl-graph-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.25rem 0;
}

/* ── Live indicator ── */
.bl-live {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 10.5px;
  color: var(--green);
  font-family: var(--mono);
  letter-spacing: 0.5px;
  margin-left: auto;
}
.bl-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: bl-pulse 1.5s infinite;
}

/* ── Node selection + verification chip ── */
.bl-node { cursor: pointer; }
.bl-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow, rgba(90, 120, 200, 0.15));
}
.bl-verify-chip {
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  font-size: 10px;
  font-family: var(--mono);
  border: 1px solid var(--border);
}
.bl-verify-chip.verified_pass { background: var(--green-dim); color: var(--green); }
.bl-verify-chip.verified_fail { background: var(--red-dim); color: var(--red); }
.bl-verify-chip.verification_error { background: var(--yellow-dim); color: var(--yellow); }

/* ── Node Detail Panel ── */
.bl-node-detail {
  background: var(--s1);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1rem;
  margin-top: 1rem;
}
.bl-nd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.bl-nd-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bl-nd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.bl-nd-section {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.bl-nd-sec-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.bl-kv {
  display: flex;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
}
.bl-kv:last-child { border-bottom: none; }
.bl-kv-k {
  color: var(--muted);
  min-width: 110px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 10.5px;
}
.bl-kv-v {
  color: var(--text);
  word-break: break-all;
  font-family: var(--mono);
  font-size: 10.5px;
}
.bl-nd-evidence {
  margin-top: 0.5rem;
  max-height: 200px;
  overflow: auto;
  background: var(--s3);
  border-radius: 6px;
  padding: 0.5rem;
}
.bl-nd-evidence pre {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Live Execution Console ── */
.bl-activity {
  margin-top: 1rem;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.bl-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--border);
}
.bl-activity-title { font-size: 12px; font-weight: 600; }
.bl-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); display: inline-block; margin-right: 5px;
  animation: bl-pulse 1.2s infinite;
}
.bl-activity-stream {
  max-height: 360px; overflow-y: auto; padding: .5rem .7rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.bl-activity-item {
  display: grid; grid-template-columns: 62px 118px 1fr;
  gap: .45rem; padding: .35rem .25rem; border-bottom: 1px solid var(--border);
  font-size: 10.5px; line-height: 1.45;
}
.bl-activity-time { color: var(--muted2); }
.bl-activity-type { color: var(--blue); font-weight: 600; }
.bl-activity-item.tool .bl-activity-type { color: var(--purple); }
.bl-activity-item.file .bl-activity-type { color: var(--blue); }
.bl-activity-item.verify .bl-activity-type { color: var(--green); }
.bl-activity-item.error .bl-activity-type { color: var(--red); }
.bl-activity-item.stage .bl-activity-type { color: var(--yellow); }
.bl-activity-message { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.bl-activity-meta { color: var(--muted2); margin-top: 2px; }
.bl-activity-empty { padding: 1rem; color: var(--muted); font-size: 11px; }
