/*
 * Crony Workbench — Batch 3 streaming UI styles
 * Step rail, token streaming bubble, citation chips, citation drawer.
 *
 * Import this file in any page that uses workbench.js v1.7.0+:
 *   <link rel="stylesheet" href="/css/workbench-stream.css">
 */

/* ============================================================
   Step Rail  (.wb-step-rail)
   Lives above the streaming bubble, replaced by wb-steps-wrap
   once the stream completes.
   ============================================================ */

.wb-step-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-left: 2px solid var(--border-subtle, rgba(255,255,255,0.1));
  font-size: var(--text-xs, 11px);
  color: var(--text-kicker, #888);
}

.wb-step-row {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
  padding: 1px 0;
  transition: color 0.15s ease;
}

.wb-step-row.wb-step-running { color: var(--text-secondary, #aaa); }
.wb-step-row.wb-step-done    { color: var(--color-success, #34d399); }
.wb-step-row.wb-step-error   { color: var(--color-danger,  #f87171); }

/* Animated spinner icon */
.wb-step-spinner svg {
  animation: wb-spin 0.9s linear infinite;
  display: block;
}
@keyframes wb-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Static done / error icon */
.wb-step-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.wb-step-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Meta tags: "6 chunks", "I2C", "0x60013000" */
.wb-step-meta-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-raised, rgba(255,255,255,0.06));
  color: var(--text-kicker, #888);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ============================================================
   Streaming bubble  (.wb-streaming)
   The .message-bubble while tokens are arriving.
   ============================================================ */

.wb-streaming {
  position: relative;
}

/* Blinking cursor at the end of the stream */
.wb-streaming .wb-stream-text::after {
  content: '▍';
  display: inline-block;
  opacity: 1;
  animation: wb-cursor-blink 0.6s step-end infinite;
  margin-left: 1px;
  color: var(--color-primary, #60a5fa);
  font-size: 0.85em;
  vertical-align: baseline;
}
@keyframes wb-cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ============================================================
   Citation chips  (.wb-cite-chip)
   Inline [N] markers in the reply text.
   ============================================================ */

.wb-cite-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--color-primary-muted, rgba(96,165,250,0.15));
  color: var(--color-primary, #60a5fa);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--color-primary-border, rgba(96,165,250,0.3));
  cursor: pointer;
  vertical-align: middle;
  margin: 0 1px;
  transition: background 0.12s ease, transform 0.1s ease;
  line-height: 1;
}

.wb-cite-chip:hover {
  background: var(--color-primary-muted-hover, rgba(96,165,250,0.28));
  transform: translateY(-1px);
}

.wb-cite-chip:active {
  transform: translateY(0);
}

/* ============================================================
   Citation drawer  (#wb-citation-drawer)
   Slides in from the right side of the viewport.
   ============================================================ */

.wb-citation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 900;
  cursor: default;
}

#wb-citation-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: clamp(280px, 36vw, 480px);
  background: var(--surface-base, #1a1a2e);
  border-left: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  z-index: 901;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#wb-citation-drawer.wb-citation-drawer-open {
  transform: translateX(0);
}

/* Header row */
.wb-citation-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.wb-citation-ref-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--color-primary-muted, rgba(96,165,250,0.15));
  color: var(--color-primary, #60a5fa);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.wb-citation-label {
  flex: 1;
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  line-height: 1.4;
  word-break: break-word;
}

.wb-citation-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-kicker, #888);
  cursor: pointer;
  transition: background 0.1s;
}
.wb-citation-close:hover {
  background: var(--surface-raised, rgba(255,255,255,0.08));
  color: var(--text-primary, #e2e8f0);
}

/* Meta chips row */
.wb-citation-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  flex-shrink: 0;
}

.wb-citation-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-raised, rgba(255,255,255,0.07));
  color: var(--text-secondary, #94a3b8);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Excerpt area */
.wb-citation-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle, rgba(255,255,255,0.1)) transparent;
}

.wb-citation-excerpt {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-sunken, rgba(0,0,0,0.25));
  color: var(--text-secondary, #94a3b8);
  font-family: var(--font-mono, 'JetBrains Mono', 'Fira Code', monospace);
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

/* Footer with PDF link */
.wb-citation-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  flex-shrink: 0;
}

.wb-citation-pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
