/**
 * TopBar — Terminal Operator HUD
 * EPIC 8.2: Fixed position, live KPIs, freshness badges
 * AI Worker: Component Builder
 * Health: topbar_render_ms
 * DoD: Build SHA, p50, uptime, ingest all visible without JS
 */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 60px;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: var(--fw-semibold);
  color: var(--text-0);
  font-size: var(--fs-md);
}

.topbar__kpis {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  flex: 1;
  justify-content: flex-end;
}

.topbar__kpi {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.topbar__kpi-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.topbar__kpi-value {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-0);
  font-family: var(--font-mono);
}

/* Freshness badge (inline with value) */
.topbar__kpi-freshness {
  display: inline-block;
  font-size: var(--fs-xs);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: var(--s-2);
  font-weight: var(--fw-medium);
}

.topbar__kpi-freshness[data-freshness="live"] {
  background: rgba(0, 255, 136, 0.1);
  color: var(--live);
  border: 1px solid var(--live);
}

.topbar__kpi-freshness[data-freshness="cached"] {
  background: rgba(59, 130, 246, 0.1);
  color: var(--cached);
  border: 1px solid var(--cached);
}

.topbar__kpi-freshness[data-freshness="stale"] {
  background: rgba(255, 184, 0, 0.1);
  color: var(--stale);
  border: 1px solid var(--stale);
}

.topbar__kpi-freshness[data-freshness="error"] {
  background: rgba(255, 71, 87, 0.1);
  color: var(--error);
  border: 1px solid var(--error);
}

/* Mobile: Stack KPIs */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .topbar__kpis {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: var(--s-3);
  }
  
  .topbar__kpi {
    flex: 1 1 calc(50% - var(--s-3));
    min-width: 120px;
  }
}
