/* ============================================================
   Digital Worker Activity Bar — Pipeline Kanban
   Clean line-art style. Horizontal flow left→right.
   CCode(instruct) → Siobhan → [ASSIGNING] → Workers → [NEXT STEPS] → WIP #NNN
   Light theme — matches EPW Azia Light (ADR-044)
   ============================================================ */

/* ---- Keyframes ---- */
@keyframes ab-spin {
  to { transform: rotate(360deg); }
}

@keyframes ab-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.4); }
}

@keyframes ab-dot-travel {
  from { left: 0; opacity: 1; }
  to   { left: calc(100% - 5px); opacity: 1; }
}

/* One-shot pulse: travel once then vanish */
@keyframes ab-dot-once {
  0%   { left: 0; opacity: 1; }
  85%  { left: calc(100% - 5px); opacity: 1; }
  100% { left: calc(100% - 5px); opacity: 0; }
}

/* Vertical pulse traveling UP into a worker pill */
@keyframes ab-dot-up {
  0%   { bottom: 0; opacity: 1; }
  85%  { bottom: calc(100% - 5px); opacity: 1; }
  100% { bottom: calc(100% - 5px); opacity: 0; }
}

@keyframes ab-emerge {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ---- Bar Container ---- */
#activity-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  font-family: 'Consolas', 'Courier New', monospace;
  border-top: 2px solid #0693E3;
  background: #0B1929;
  color: #38BDF8;
  display: flex;
  flex-direction: column;
  transition: height 0.3s ease;
}

#activity-bar.ab-collapsed { height: 32px; }
#activity-bar.ab-collapsed .ab-body { display: none; }
#activity-bar.ab-expanded  { height: 340px; }

/* ---- Header ---- */
.ab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #0F2238;
  cursor: pointer;
  flex-shrink: 0;
  height: 32px;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(56, 189, 248, 0.15);
}

.ab-header:hover { background: #132D4A; }

.ab-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ab-hdr-gear {
  color: #38BDF8;
  animation: ab-spin 2.5s linear infinite;
  display: block;
  flex-shrink: 0;
}

.ab-header-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #EF4444;
}

.ab-header-count {
  font-size: 10px;
  color: #64748B;
}

.ab-header-toggle {
  font-size: 12px;
  color: #64748B;
  transition: transform 0.25s ease;
}

#activity-bar.ab-collapsed .ab-header-toggle {
  transform: rotate(180deg);
}

/* ---- Body (scrollable lanes) ---- */
.ab-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

.ab-body::-webkit-scrollbar { width: 4px; }
.ab-body::-webkit-scrollbar-track { background: #0B1929; }
.ab-body::-webkit-scrollbar-thumb { background: #1E3A5F; border-radius: 2px; }

.ab-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 11px;
  color: #4ADE80;
  font-style: italic;
}

/* ============================================================
   LANE — one per distinct task/activity
   ============================================================ */
.ab-lane-wrap {
  padding: 0 16px 4px;
  will-change: transform, opacity;
}

/* Task label row */
.ab-lane-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 2px;
}

.ab-lane-action {
  font-size: 10px;
  font-weight: 600;
  color: #4ADE80;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
  flex-shrink: 1;
}

.ab-lane-ts {
  font-size: 9px;
  color: #38BDF8;
  font-family: 'Consolas', monospace;
  flex-shrink: 0;
}

.ab-lane-evts {
  font-size: 9px;
  color: #64748B;
  flex-shrink: 0;
}

/* ============================================================
   PIPELINE — the horizontal flow
   ============================================================ */
.ab-pipeline {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  min-height: 60px;
  padding: 4px 0 0;
  /* Compact from left — not full-width */
  justify-content: flex-start;
}

/* The horizontal backbone line — only spans content width */
.ab-pipeline::before {
  display: none;
}

/* ============================================================
   PILL — a node on the pipeline (CCode, Siobhan, or Worker)
   ============================================================ */
.ab-pill {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: #132D4A;
  border: 1.5px solid #1E3A5F;
  border-radius: 20px;
  padding: 4px 10px 4px 5px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
}

.ab-pill-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #CBD5E1;
}

.ab-pill-name {
  font-size: 10px;
  font-weight: 700;
  color: #E2E8F0;
  white-space: nowrap;
}

.ab-pill-role {
  font-size: 8px;
  color: #64748B;
  white-space: nowrap;
}

/* Active pill glow */
.ab-pill.ab-pill-active {
  border-color: #0693E3;
  box-shadow: 0 0 8px rgba(6, 147, 227, 0.2);
}

/* Done pill */
.ab-pill.ab-pill-done {
  border-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.15);
}

/* Dimmed pill (waiting) */
.ab-pill.ab-pill-dim {
  opacity: 0.35;
}

/* CCode pill has gear icon instead of avatar */
.ab-pill-gear {
  width: 22px;
  height: 22px;
  color: #0693E3;
  flex-shrink: 0;
  animation: ab-spin 2s linear infinite;
}

.ab-pill-gear.ab-gear-stopped {
  animation: none;
}

/* QC badge on CCode-right pill (kept for backward compat) */
.ab-pill-qc {
  font-size: 7px;
  font-weight: 800;
  color: #0693E3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 2px;
}

/* ============================================================
   STAGE LABEL — floating box above the pipeline
   ============================================================ */
.ab-stage-label {
  position: relative;
  z-index: 3;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748B;
  background: #0F2238;
  border: 1.5px solid #1E3A5F;
  border-radius: 4px;
  padding: 2px 8px;
  text-align: center;
  white-space: nowrap;
  margin-bottom: 4px;
  opacity: 0.5;
  transition: border-color 0.3s ease, color 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
}

.ab-stage-label.ab-stage-label-active {
  color: #38BDF8;
  border-color: #38BDF8;
  background: #0F2238;
  opacity: 1;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.ab-stage-label.ab-stage-label-done {
  color: #4ADE80;
  border-color: #4ADE80;
  background: #0F2238;
  opacity: 0.7;
  box-shadow: none;
}

/* ============================================================
   ZONE WRAP — contains ASSIGNING label + worker zone
   ============================================================ */
.ab-zone-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0;
}

/* ============================================================
   WIP WRAP — contains NEXT STEPS label + WIP pill
   ============================================================ */
.ab-wip-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0;
}

/* ============================================================
   WIP PILL — final tracked output node
   ============================================================ */
.ab-pill.ab-pill-wip {
  border-style: dashed;
  border-color: #1E3A5F;
  padding: 4px 10px;
  background: #0F2238;
}

.ab-pill-wip-id {
  font-size: 10px;
  font-weight: 800;
  font-family: 'Consolas', 'Courier New', monospace;
  color: #64748B;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* WIP pill when ID is assigned — solid green border */
.ab-pill.ab-pill-wip.ab-pill-wip-assigned {
  border-style: solid;
  border-color: #4ADE80;
  background: #0F2238;
  opacity: 1;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.ab-pill.ab-pill-wip.ab-pill-wip-assigned .ab-pill-wip-id {
  color: #059669;
}

/* WIP pill active state */
.ab-pill.ab-pill-wip.ab-pill-active {
  border-style: dashed;
  border-color: #38BDF8;
  background: #0F2238;
}

.ab-pill.ab-pill-wip.ab-pill-active .ab-pill-wip-id {
  color: #0693E3;
}

/* WIP pill done state */
.ab-pill.ab-pill-wip.ab-pill-done {
  border-style: solid;
  border-color: #4ADE80;
  background: #0F2238;
}

.ab-pill.ab-pill-wip.ab-pill-done .ab-pill-wip-id {
  color: #4ADE80;
}

/* ============================================================
   CONNECTOR — arrow between pills on the pipeline
   ============================================================ */
.ab-connector {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 2px;
  width: 22px;
  flex: 0 0 22px;
  margin: 0 1px;
  /* sits on the backbone line */
  margin-bottom: 17px;
}

.ab-connector-line {
  position: relative;
  width: 100%;
  height: 2px;
  background: #1E3A5F;
  border-radius: 1px;
  overflow: visible;
}

.ab-connector-dot {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0693E3;
  box-shadow: 0 0 6px 2px rgba(6, 147, 227, 0.4);
  opacity: 0;
}

/* One-shot: pulse travels once then fades */
.ab-connector-dot.ab-dot-fire {
  animation: ab-dot-once 0.6s ease-out forwards;
}

/* Vertical pulse dot (inside worker zone) */
.ab-vdot {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0693E3;
  box-shadow: 0 0 6px 2px rgba(6, 147, 227, 0.4);
  animation: ab-dot-up 0.4s ease-out forwards;
  pointer-events: none;
  z-index: 10;
}

.ab-connector-head {
  font-size: 10px;
  color: #1E3A5F;
  margin-left: -1px;
  flex-shrink: 0;
  line-height: 1;
}

/* ============================================================
   WORKER ZONE — center of pipeline, workers emerge upward
   ============================================================ */
.ab-worker-zone {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0 4px;
  margin-bottom: 2px;
}

/* ============================================================
   WORKER PILL — compact inline chip (avatar + name + role + status)
   ============================================================ */
.ab-worker-pill {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: #132D4A;
  border: 1.5px solid #1E3A5F;
  border-left: 3px solid #1E3A5F;
  border-radius: 20px;
  padding: 4px 10px 4px 5px;
  flex-shrink: 0;
  will-change: transform, opacity;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.3s ease;
}

.ab-worker-pill.ab-wp-active {
  border-color: #0693E3;
}

.ab-wp-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ab-wp-name {
  font-size: 10px;
  font-weight: 700;
  color: #E2E8F0;
  white-space: nowrap;
}

.ab-wp-role {
  font-size: 8px;
  color: #64748B;
  white-space: nowrap;
}

/* Status indicator on worker pill */
.ab-wp-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 2px;
}

.ab-wp-status.ab-wps-active {
  background: #0693E3;
  animation: ab-pulse-dot 1.5s ease infinite;
}

.ab-wp-status.ab-wps-done {
  background: #10b981;
  animation: none;
}

.ab-wp-status.ab-wps-error {
  background: #ef4444;
  animation: none;
}

/* ============================================================
   LANE ACTIVITY LOG — full-width readable text
   ============================================================ */
.ab-lane-log {
  max-height: 140px;
  overflow-y: auto;
  padding: 4px 8px 6px;
  background: #081421;
  border: 1px solid #1E3A5F;
  border-radius: 4px;
  margin-top: 4px;
}

.ab-lane-log:empty {
  display: none;
}

.ab-lane-log::-webkit-scrollbar { width: 3px; }
.ab-lane-log::-webkit-scrollbar-track { background: #081421; }
.ab-lane-log::-webkit-scrollbar-thumb { background: #1E3A5F; border-radius: 2px; }

.ab-log-entry {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  line-height: 1.4;
}

.ab-log-ts {
  font-size: 11px;
  color: #38BDF8;
  font-family: 'Consolas', 'Courier New', monospace;
  flex-shrink: 0;
  white-space: nowrap;
}

.ab-log-worker {
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}

.ab-log-text {
  font-size: 11px;
  color: #4ADE80;
  flex: 1;
  min-width: 0;
  /* NEVER truncate — readability is #1 priority */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Collapsed worker (after done — small chip on the line) */
.ab-wp-collapsed {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #132D4A;
  border: 1px solid #1E3A5F;
  border-radius: 12px;
  padding: 2px 6px 2px 3px;
  margin-right: 4px;
}

.ab-wp-collapsed img {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  object-fit: cover;
}

.ab-wp-collapsed span {
  font-size: 8px;
  color: #94A3B8;
  font-weight: 600;
}

/* Collapsed workers row (sits on the baseline after done) */
.ab-collapsed-row {
  display: none;
  align-items: center;
  padding: 2px 0 0;
  gap: 3px;
  margin-bottom: 4px;
}

/* ============================================================
   LANE SEPARATOR
   ============================================================ */
hr.ab-lane-sep {
  border: none;
  border-top: 1px solid #1E3A5F;
  margin: 2px 16px;
}

.ab-body > hr.ab-lane-sep:first-child {
  display: none;
}

/* ============================================================
   Content Occlusion Prevention
   ============================================================ */
body.ab-active .epw-view {
  padding-bottom: 346px;
}

body:not(.ab-active) .epw-view {
  padding-bottom: 36px;
}

#timeline-view {
  transition: bottom 0.25s ease;
}

body.ab-bar-present #timeline-view {
  bottom: 36px;
}

body.ab-active #timeline-view {
  bottom: 340px;
}
