/*
 * Bailder — overrides e componentes específicos do orquestrador.
 * Carregado após application.css via require_tree.
 */

:root {
  --color-primary: #7C3AED;
  --color-primary-hover: #6D28D9;
  --color-accent: #22D3EE;
  --color-purple: #A855F7;
}

/* Layout dashboard — sidebar + main */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-bg-card);
  border-right: 1px solid var(--color-border);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: var(--space-lg);
}
.sidebar__nav { display: flex; flex-direction: column; gap: var(--space-xs); }
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar__link:hover { background: var(--color-bg-hover); color: var(--color-text); }
.sidebar__link.is-active { background: var(--color-bg-elevated); color: var(--color-text); border-left: 2px solid var(--color-primary); }
.sidebar__footer { margin-top: auto; font-size: 0.85rem; color: var(--color-text-faded); }

.main { padding: var(--space-xl) var(--space-2xl); max-width: 1400px; }
.main__title { margin: 0 0 var(--space-xs) 0; font-size: 1.6rem; }
.main__subtitle { margin: 0 0 var(--space-xl) 0; color: var(--color-text-muted); }

.grid { display: grid; gap: var(--space-md); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--2up { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* Tier badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge--green  { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.badge--yellow { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.badge--red    { background: rgba(255,71,87,0.12); color: #fca5a5; border-color: rgba(255,71,87,0.3); }
.badge--blue   { background: rgba(34,211,238,0.12); color: #67e8f9; border-color: rgba(34,211,238,0.3); }
.badge--gray   { background: rgba(255,255,255,0.06); color: var(--color-text-muted); }
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* Worker status */
.status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status--pending   { color: var(--color-text-muted); }
.status--running   { color: var(--color-accent); animation: pulse 1.6s ease-in-out infinite; }
.status--completed { color: var(--color-success); }
.status--failed    { color: var(--color-danger); }
.status--cancelled { color: var(--color-text-faded); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Event stream */
.event-stream {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-size: 0.9rem;
  max-height: 75vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Block — qualquer item do timeline */
.b {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
}
.b__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  color: var(--color-text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.b__head--final { cursor: default; }
.b__role {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  color: var(--color-accent);
  flex-shrink: 0;
  min-width: 80px;
}
.b__role--muted { color: var(--color-text-faded); }
.b__role--success { color: var(--color-success); }
.b__role--danger { color: var(--color-danger); }
.b__tool {
  font-family: var(--font-mono);
  color: var(--color-purple);
  font-size: 0.85rem;
  flex-shrink: 0;
  min-width: 110px;
}
.b__time {
  margin-left: auto;
  color: var(--color-text-faded);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.b__preview {
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.b__preview--code { font-family: var(--font-mono); font-size: 0.82rem; color: var(--color-text); }
.b__body {
  padding: var(--space-sm) 0 0 0;
  margin-top: var(--space-xs);
  border-top: 1px dashed var(--color-border);
}
.b__body--text {
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: none;
  padding-top: var(--space-xs);
}
.b__body--thinking {
  color: var(--color-text-muted);
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
}
.b__label {
  color: var(--color-text-faded);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}
.b__code {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  margin: 0;
}
.b__code--result { border-left: 2px solid var(--color-accent); }
.b__code--error { border-left: 2px solid var(--color-danger); color: #fca5a5; }
.b__kv {
  width: 100%;
  font-size: 0.85rem;
}
.b__kv th {
  text-align: left;
  color: var(--color-text-faded);
  padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
  font-weight: 500;
  vertical-align: top;
  width: 130px;
}
.b__kv td {
  padding: var(--space-xs) 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
}

/* Role-tinted left border */
.b--assistant { border-left: 2px solid var(--color-accent); }
.b--user      { border-left: 2px solid var(--color-text-faded); }
.b--system    { border-left: 2px solid var(--color-purple); }

/* Tipos especiais */
.b--text      { background: var(--color-bg-elevated); }
.b--thinking  { background: rgba(255,255,255,0.02); }
.b--tool-use  { background: var(--color-bg-card); }
.b--tool-result { background: var(--color-bg); }
.b--final-result {
  background: rgba(16,185,129,0.06);
  border-left: 2px solid var(--color-success);
}
.b--error {
  background: rgba(255,71,87,0.06);
  border-left: 2px solid var(--color-danger);
}

/* <details> open state */
.b__details summary { list-style: none; }
.b__details summary::-webkit-details-marker { display: none; }
.b__details summary::before {
  content: "▸";
  color: var(--color-text-faded);
  font-size: 0.7rem;
  margin-right: var(--space-xs);
  transition: transform var(--transition-fast);
  display: inline-block;
}
.b__details[open] summary::before { transform: rotate(90deg); }

/* Project card */
.project-card {
  position: relative;
  padding: var(--space-lg);
}
.project-card__slug {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-faded);
  text-transform: uppercase;
}
.project-card__name { margin: var(--space-xs) 0; font-size: 1.1rem; }
.project-card__desc { color: var(--color-text-muted); font-size: 0.9rem; min-height: 2.7em; }
.project-card__meta {
  display: flex; gap: var(--space-md); margin-top: var(--space-md);
  font-size: 0.82rem; color: var(--color-text-faded);
}

/* Confirmation list */
.confirmation {
  border-left: 4px solid var(--color-danger);
  padding-left: var(--space-md);
}
.confirmation--yellow { border-left-color: var(--color-warning); }
.confirmation__actions { display: flex; gap: var(--space-sm); margin-top: var(--space-md); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--space-sm) var(--space-md); text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { color: var(--color-text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:hover td { background: var(--color-bg-hover); }

/* Devise auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--space-lg); }
.auth__card { width: 100%; max-width: 420px; padding: var(--space-2xl); }
.auth__title { text-align: center; margin: 0 0 var(--space-lg) 0; }

/* ============================================================
   Worker show — sticky header, filtros, métricas
   ============================================================ */
.worker-show__header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: linear-gradient(180deg, var(--color-bg) 70%, rgba(6,6,15,0.6) 100%);
  backdrop-filter: blur(8px);
  padding: var(--space-md) 0 var(--space-md);
  margin: calc(-1 * var(--space-xl)) calc(-1 * var(--space-2xl)) 0;
  padding-left: var(--space-2xl);
  padding-right: var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
}
.worker-show__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}
.worker-show__meta-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.worker-show__meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}
.worker-show__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-md) 0 var(--space-lg);
}
.metric {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.metric__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faded);
  margin-bottom: 2px;
}
.metric__value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.metric--accent .metric__value { color: var(--color-accent); }
.metric--success .metric__value { color: var(--color-success); }
.metric--warning .metric__value { color: var(--color-warning); }
.metric--danger  .metric__value { color: var(--color-danger); }

/* Section heading com linha */
.section-heading {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-xl) 0 var(--space-md);
  font-size: 1.02rem;
  color: var(--color-text);
}
.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ============================================================
   Subagent timeline
   ============================================================ */
.subagents {
  background: linear-gradient(180deg, rgba(124,58,237,0.04), rgba(34,211,238,0.03));
  border: 1px solid rgba(124,58,237,0.18);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}
.subagents__header { margin-bottom: var(--space-md); }
.subagents__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.subagents__title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text);
}
.subagents__icon { font-size: 1.15rem; }
.subagents__count {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-purple);
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.3);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}
.subagents__count--empty {
  color: var(--color-text-faded);
  background: transparent;
  border-color: var(--color-border);
}
.subagents__stats {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.subagents__stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}
.subagents__stat--running { color: var(--color-accent); border-color: rgba(34,211,238,0.3); }
.subagents__stat--success { color: var(--color-success); border-color: rgba(16,185,129,0.3); }
.subagents__stat--failed  { color: var(--color-danger);  border-color: rgba(255,71,87,0.3); }
.subagents__stat--eta     { color: var(--color-text-muted); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.dot--pulse {
  animation: dotPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 currentColor;
}
@keyframes dotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,211,238,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(34,211,238,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
}

.subagents__empty {
  text-align: center;
  padding: var(--space-lg);
  color: var(--color-text-muted);
}
.subagents__empty code {
  background: var(--color-bg-elevated);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.subagents__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.subagents__gantt-legend {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-sm);
  padding: 0 var(--space-xs);
}

.subagent {
  position: relative;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.subagent:hover { border-color: var(--color-border-strong); }
.subagent--running { border-left: 3px solid var(--color-accent); }
.subagent--success { border-left: 3px solid var(--color-success); }
.subagent--failed  { border-left: 3px solid var(--color-danger); }

/* Gantt bar de fundo — barra horizontal que cresce com a duração */
.subagent__bar {
  position: absolute;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-purple), var(--color-accent));
  opacity: 0.7;
  transition: width var(--transition-slow), left var(--transition-slow);
  pointer-events: none;
}
.subagent--running .subagent__bar {
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent));
  animation: ganttPulse 1.6s ease-in-out infinite;
}
.subagent--failed  .subagent__bar { background: var(--color-danger); }
.subagent--success .subagent__bar { background: var(--color-success); }
@keyframes ganttPulse { 50% { opacity: 0.4; } }

.subagent__details summary { list-style: none; cursor: pointer; }
.subagent__details summary::-webkit-details-marker { display: none; }

.subagent__head {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-sm) var(--space-md);
}

.subagent__status-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.subagent--success .subagent__status-indicator {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.4);
  color: var(--color-success);
}
.subagent--failed .subagent__status-indicator {
  background: rgba(255,71,87,0.12);
  border-color: rgba(255,71,87,0.4);
  color: var(--color-danger);
}
.subagent--running .subagent__status-indicator {
  background: rgba(34,211,238,0.08);
  border-color: rgba(34,211,238,0.35);
}

.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(34,211,238,0.25);
  border-top-color: var(--color-accent);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.checkmark {
  font-size: 1rem;
  font-weight: 700;
  animation: checkmarkPop 320ms cubic-bezier(0.22, 1.4, 0.36, 1);
}
@keyframes checkmarkPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cross {
  font-size: 1rem;
  font-weight: 700;
}

.subagent__heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.subagent__label-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.subagent__index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-faded);
}
.subagent__label {
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.subagent__type {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-purple);
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.3);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.subagent__preview {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subagent__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: var(--font-mono);
}
.subagent__duration {
  font-size: 0.95rem;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.subagent__status-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faded);
}
.subagent--success .subagent__status-label { color: var(--color-success); }
.subagent--failed  .subagent__status-label { color: var(--color-danger); }
.subagent--running .subagent__status-label { color: var(--color-accent); }

.subagent__body {
  padding: 0 var(--space-md) var(--space-md);
  border-top: 1px dashed var(--color-border);
  margin-top: var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.subagent__section {
  padding-top: var(--space-sm);
}
.subagent__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}
.subagent__section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faded);
}
.subagent__prompt, .subagent__output {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
}
.subagent__output--error { border-left: 2px solid var(--color-danger); color: #fca5a5; }

.subagent__copy {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.subagent__copy:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.subagent__copy--flash { color: var(--color-success); border-color: rgba(16,185,129,0.4); }

.subagent__progress {
  height: 4px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.subagent__progress-bar {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
  animation: indeterminate 1.4s linear infinite;
  width: 35%;
}
@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(380%); }
}

/* Animação de entrada de card novo (via Stimulus) */
.subagent--enter {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 350ms ease, transform 350ms cubic-bezier(0.22, 1.4, 0.36, 1);
}
.subagent--enter.subagent--enter-active {
  opacity: 1;
  transform: translateY(0);
}
.subagent--just-completed {
  animation: justCompleted 1.2s ease;
}
@keyframes justCompleted {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.0); }
  20%  { box-shadow: 0 0 0 6px rgba(16,185,129,0.25); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.0); }
}
.subagent--just-failed {
  animation: justFailed 0.7s cubic-bezier(.36,.07,.19,.97);
}
@keyframes justFailed {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ============================================================
   Filtros + segmented control (timeline events)
   ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.segmented__item {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.segmented__item:hover { color: var(--color-text); }
.segmented__item.is-active {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* Tweak: event-stream se ajusta quando dentro de filtros */
.event-stream [data-event-kind].is-hidden { display: none; }

/* ============================================================
   Empty states — versão grande, ilustrada
   ============================================================ */
.empty-state--rich {
  background: var(--color-bg-card);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
}
.empty-state__action { margin-top: var(--space-md); }

/* ============================================================
   Status badge animado (do header do worker)
   ============================================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}
.status-pill::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.status-pill--pending   { color: var(--color-text-muted); }
.status-pill--running {
  color: var(--color-accent);
  border-color: rgba(34,211,238,0.4);
}
.status-pill--running::before {
  animation: dotPulse 1.4s ease-in-out infinite;
}
.status-pill--completed {
  color: var(--color-success);
  border-color: rgba(16,185,129,0.4);
  background: rgba(16,185,129,0.08);
}
.status-pill--failed {
  color: var(--color-danger);
  border-color: rgba(255,71,87,0.4);
  background: rgba(255,71,87,0.08);
}
.status-pill--cancelled { color: var(--color-text-faded); }

/* Tooltip mínimo */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: var(--z-dropdown);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Acessibilidade — focus visível em tudo que é clicável */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.btn:focus-visible, .sidebar__link:focus-visible {
  outline-offset: 3px;
}

/* ============================================================
   Marketing — brand cards, header, chat
   ============================================================ */
.brand-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.brand-card__swatch {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.brand-card__initials {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2rem;
  color: rgba(0,0,0,0.8);
  text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}
.brand-card__body { padding: var(--space-md); }

.brand-header {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: var(--space-lg);
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-xl);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand-primary, var(--color-primary)) 18%, transparent),
    color-mix(in srgb, var(--brand-secondary, var(--color-accent)) 12%, transparent));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.brand-header__avatar {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-primary, var(--color-primary)), var(--brand-secondary, var(--color-accent)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: rgba(0,0,0,0.78);
  box-shadow: var(--shadow-md);
}

/* Layout grid pra brand show */
.brand-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-xl);
  align-items: flex-start;
}

/* Chat */
.brand-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 280px);
  min-height: 560px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.brand-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}
.brand-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.brand-chat__empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-2xl) var(--space-md);
}
.brand-chat__form {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.brand-chat__form textarea {
  flex: 1;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  padding: var(--space-sm) var(--space-md);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 48px;
  max-height: 200px;
}
.brand-chat__form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.brand-chat__hint {
  padding: 0 var(--space-lg) var(--space-md);
  font-size: 0.75rem;
  background: var(--color-bg);
}
.brand-chat__hint kbd {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* Bolhas */
.chat-bubble {
  max-width: 86%;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
}
.chat-bubble--user {
  align-self: flex-end;
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.3);
}
.chat-bubble--assistant {
  align-self: flex-start;
  background: rgba(34,211,238,0.06);
  border-color: rgba(34,211,238,0.2);
}
.chat-bubble--thinking { opacity: 0.7; }
.chat-bubble__role {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faded);
  margin-bottom: 2px;
}
.chat-bubble__body {
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
}

.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-accent);
  animation: thinkingPulse 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkingPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
  40%           { opacity: 1;   transform: scale(1.1); }
}

/* Cards de ação inline (post criado, imagem gerada) */
.chat-action {
  align-self: stretch;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}
.chat-action__label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-purple);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-sm);
}
.chat-action__image {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius-sm);
  display: block;
  margin: var(--space-sm) 0;
}
.chat-action__title { font-weight: 600; margin-bottom: var(--space-xs); }
.chat-action__caption { color: var(--color-text); font-size: 0.9rem; line-height: 1.5; }
.chat-action__tags { color: var(--color-accent); font-size: 0.82rem; margin-top: var(--space-xs); }
.chat-action__form { margin-top: var(--space-md); }

/* Contextos */
.context-group { padding: var(--space-xs) 0; }
.context-group summary {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  cursor: pointer;
  padding: var(--space-xs) 0;
  list-style: none;
}
.context-group summary::-webkit-details-marker { display: none; }
.context-list {
  margin: var(--space-xs) 0 0 var(--space-md);
  padding: 0;
  list-style: disc;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Post mini cards */
.post-mini {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}
.post-mini__head {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  margin-bottom: var(--space-xs);
}
.post-mini__cover {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  max-height: 180px;
  object-fit: cover;
}
.post-mini__caption {
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.45;
}

/* Observability dashboard */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
}
.stat-card__label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faded);
}
.stat-card__value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-card__sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.obs-bars {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-sm);
  align-items: end;
  height: 160px;
  padding: var(--space-md);
}
.obs-bars__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: end;
  gap: var(--space-xs);
}
.obs-bars__bar {
  width: 100%;
  background: linear-gradient(to top, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height var(--transition-normal);
}
.obs-bars__label {
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.2;
}

.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }

/* Post cards (grid posts page) */
.post-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.post-card__cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--color-bg);
}
.post-card__cover--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faded);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.post-card__body { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); }
.post-card__footer {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

/* Mobile */
@media (max-width: 768px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: var(--space-md); }
  .worker-show__header {
    margin: calc(-1 * var(--space-md)) calc(-1 * var(--space-md)) 0;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
  .subagent__head { grid-template-columns: 32px 1fr auto; gap: var(--space-sm); }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .brand-layout { grid-template-columns: 1fr; }
  .brand-header { grid-template-columns: 64px 1fr; padding: var(--space-md); gap: var(--space-md); }
  .brand-header__avatar { width: 64px; height: 64px; font-size: 1.5rem; }
  .brand-chat { height: auto; min-height: 480px; }
}

/* ====== Multi-agent dashboard ====== */
.agent-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.agent-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.agent-card__icon { font-size: 1.6rem; }
.agent-card__title { margin: 0; font-size: 1.05rem; }
.agent-card__slug { font-size: 0.85rem; margin: 0; }
.agent-card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}
.agent-card__stats > div { min-width: 0; }
.agent-card__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-xs);
}

.msg-row {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}
.msg-row:last-child { border-bottom: none; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.code-block {
  background: var(--color-bg, #1a1a22);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 4px);
  padding: var(--space-sm);
  font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--color-text);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 480px;
  overflow-y: auto;
}
.code-block--sm { font-size: 0.78rem; max-height: 320px; }
.code-block--danger { border-left: 3px solid var(--color-danger); }

.form-input--mono { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.85rem; }
.text-mono { font-family: var(--font-mono, ui-monospace, monospace); }
.text-bold { font-weight: 600; }
.text-sm   { font-size: 0.85rem; }
.text-center { text-align: center; }

.badge--warning { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
.badge--muted   { background: rgba(255, 255, 255, 0.06); color: var(--color-text-muted); border-color: transparent; }

/* ─── Modal de detalhe de Post — mockup Instagram + insights ─── */

.post-card--clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.post-card--clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.ig-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ig-modal__sheet {
  background: var(--color-bg);
  border-radius: 16px;
  max-width: 1100px;
  width: 100%;
  max-height: 92vh;
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ig-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: background 0.15s;
}
.ig-modal__close:hover { background: rgba(255, 255, 255, 0.2); }

.ig-modal__grid {
  display: grid;
  grid-template-columns: 470px 1fr;
  height: 92vh;
  max-height: 880px;
}
@media (max-width: 900px) {
  .ig-modal__grid { grid-template-columns: 1fr; height: auto; max-height: 92vh; overflow: auto; }
}

/* ─── ESQUERDA: Mockup Instagram ─── */

.ig-mock {
  background: #fafafa;
  color: #262626;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ig-mock__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #efefef;
  flex-shrink: 0;
}
.ig-mock__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.ig-mock__handle { flex: 1; line-height: 1.1; }
.ig-mock__handle strong { display: block; font-size: 14px; color: #262626; }
.ig-mock__location { font-size: 11px; color: #737373; }
.ig-mock__more { background: none; border: none; font-size: 18px; color: #262626; padding: 0 8px; }

.ig-mock__image-wrap {
  background: #000;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ig-mock__image {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  display: block;
}
.ig-mock__image--empty {
  padding: 60px;
  color: #999;
  background: #f1f1f1;
  width: 100%;
}

.ig-mock__actions {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  font-size: 22px;
}
.ig-mock__icon { cursor: default; user-select: none; }
.ig-mock__icon--right { margin-left: auto; }

.ig-mock__likes {
  padding: 0 16px 6px;
  font-size: 14px;
  color: #262626;
}

.ig-mock__caption {
  padding: 4px 16px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #262626;
}
.ig-mock__caption strong { margin-right: 6px; }
.ig-mock__caption p { margin: 4px 0; }
.ig-mock__hashtags {
  color: #00376b;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.ig-mock__meta {
  padding: 0 16px 14px;
  font-size: 11px;
  color: #737373;
  text-transform: uppercase;
  border-bottom: 1px solid #efefef;
}
.ig-mock__meta a { color: #00376b; text-decoration: none; }
.ig-mock__meta a:hover { text-decoration: underline; }

/* ─── DIREITA: Metadata + insights ─── */

.ig-side {
  background: var(--color-bg);
  padding: 24px;
  overflow-y: auto;
  color: var(--color-text);
}

.ig-side__head h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.ig-side__head .badge { margin-right: 6px; margin-bottom: 6px; }

.ig-side__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0;
}
.btn--full { width: 100%; text-align: center; justify-content: center; }

.ig-side__section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.ig-side__section h4 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ig-dl { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0; font-size: 13px; }
.ig-dl dt { color: var(--color-text-muted); font-size: 11px; text-transform: uppercase; margin-top: 8px; }
.ig-dl dd { margin: 0; color: var(--color-text); line-height: 1.4; }
.ig-dl dd code { background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.ig-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.ig-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
}
.ig-metric__val {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-accent, #00E5FF);
}
.ig-metric__key {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.ig-side__meta-tiny {
  margin-top: 10px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}

.ig-asset-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ig-asset {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
}
.ig-asset img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-asset__placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--color-text-muted); font-size: 11px;
}
.ig-asset__id {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
}

/* Link pra ver decisões/tracking do AgentRun */
.chat-run-link { margin: 6px 0; text-align: center; }
.chat-run-link .run-link {
  display: inline-block;
  font-size: 12px;
  color: var(--color-accent, #00E5FF);
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.2);
  padding: 4px 12px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.15s;
}
.chat-run-link .run-link:hover { background: rgba(0, 229, 255, 0.14); }
