/* ONEAI Page Package: runtime */
/* Golden Room 07 — System Observatory / Runtime Control Room */
/* Presentation only. Business data, handlers, auth, and service contracts remain in hq.js. */

/* ==========================================================================
   0. Route-scoped Shell Integration & Material Tokens
   ========================================================================== */
@media (min-width: 861px) {
  body[data-oneai-route="runtime"] #canvas { grid-column: 2 / -1; }
  body[data-oneai-route="runtime"] #rail { display: none; }
}

body[data-oneai-route="runtime"] {
  --run-bg: #07090e;
  --run-surface-0: #0a0d14;
  --run-surface-1: #0e121b;
  --run-surface-2: #141926;
  --run-surface-hover: rgba(255, 255, 255, 0.025);
  --run-line: rgba(255, 255, 255, 0.07);
  --run-line-soft: rgba(255, 255, 255, 0.035);
  --run-muted: #858d9f;
  --run-dim: #545b6d;
  --run-text: #f0f2f7;
  --run-text-bright: #ffffff;
  --run-green: #34d399;
  --run-green-soft: rgba(52, 211, 153, 0.10);
  --run-green-border: rgba(52, 211, 153, 0.22);
  --run-amber: #fbbf24;
  --run-amber-soft: rgba(251, 191, 36, 0.10);
  --run-amber-border: rgba(251, 191, 36, 0.24);
  --run-red: #f87171;
  --run-red-soft: rgba(248, 113, 113, 0.10);
  --run-red-border: rgba(248, 113, 113, 0.24);
  --run-cyan: #38bdf8;
  --run-cyan-soft: rgba(56, 189, 248, 0.10);
  --run-cyan-border: rgba(56, 189, 248, 0.24);
  --run-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ==========================================================================
   1. Observatory Room Envelope (One-Viewport Layout)
   ========================================================================== */
body[data-oneai-route="runtime"] .shared-view {
  box-sizing: border-box;
  width: 100%;
  max-width: 1240px;
  min-width: 0;
  height: calc(100vh - 44px);
  max-height: 100vh;
  margin: 0 auto;
  padding: 20px 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--run-text);
  background:
    radial-gradient(1100px 380px at 15% -6%, rgba(56, 189, 248, 0.035), transparent 62%),
    radial-gradient(850px 320px at 85% 6%, rgba(52, 211, 153, 0.025), transparent 55%);
  overflow: hidden;
}

body[data-oneai-route="runtime"] .shared-view * {
  min-width: 0;
  box-sizing: border-box;
}

body[data-oneai-route="runtime"] .shared-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

/* ==========================================================================
   2. Header Band
   ========================================================================== */
body[data-oneai-route="runtime"] .shared-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--run-line);
  flex: none;
}

body[data-oneai-route="runtime"] .shared-header > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body[data-oneai-route="runtime"] .shared-title {
  color: var(--run-text-bright);
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

body[data-oneai-route="runtime"] .shared-subtitle {
  color: var(--run-muted);
  font-size: 11.5px;
  line-height: 1.4;
  font-family: var(--run-mono);
}

body[data-oneai-route="runtime"] .shared-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

body[data-oneai-route="runtime"] .shared-actions .btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--run-muted);
  background: var(--run-surface-1);
  border: 1px solid var(--run-line);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

body[data-oneai-route="runtime"] .shared-actions .btn:hover:not(:disabled) {
  color: var(--run-text-bright);
  border-color: rgba(255, 255, 255, 0.16);
  background: var(--run-surface-2);
}

/* ==========================================================================
   3. Lightweight Instrumentation Band (Observatory Status)
   ========================================================================== */
body[data-oneai-route="runtime"] .runtime-sentinel-band {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  background: var(--run-surface-0);
  border: 1px solid var(--run-line);
  border-radius: 8px;
  padding: 10px 18px;
  gap: 16px;
  flex: none;
}

body[data-oneai-route="runtime"] .sentinel-metric {
  display: flex;
  align-items: center;
  gap: 10px;
}

body[data-oneai-route="runtime"] .sentinel-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--run-dim);
  font-weight: 600;
  white-space: nowrap;
}

body[data-oneai-route="runtime"] .sentinel-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--run-text);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

body[data-oneai-route="runtime"] .sentinel-val.font-mono {
  font-family: var(--run-mono);
  font-size: 13px;
  color: var(--run-cyan);
}

body[data-oneai-route="runtime"] .sentinel-ok {
  color: var(--run-green);
}

body[data-oneai-route="runtime"] .sentinel-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--run-green);
  box-shadow: 0 0 8px var(--run-green);
  flex: none;
  animation: runPulse 2.4s ease-in-out infinite;
}

@keyframes runPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.88); }
}

body[data-oneai-route="runtime"] .sentinel-divider {
  width: 1px;
  height: 20px;
  background: var(--run-line);
}

/* ==========================================================================
   4. Compact Segmented Control (Filters)
   ========================================================================== */
body[data-oneai-route="runtime"] .runtime-filter-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--run-surface-0);
  border: 1px solid var(--run-line);
  border-radius: 6px;
  padding: 3px;
  width: fit-content;
  flex: none;
}

body[data-oneai-route="runtime"] .runtime-filter-row .btn {
  height: 26px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--run-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}

body[data-oneai-route="runtime"] .runtime-filter-row .btn:hover {
  color: var(--run-text-bright);
}

body[data-oneai-route="runtime"] .runtime-filter-row .btn.is-active {
  color: var(--run-text-bright);
  background: var(--run-surface-2);
  border-color: var(--run-line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   5. Observatory Surface & Compact Event Stream (Internal Scroll)
   ========================================================================== */
body[data-oneai-route="runtime"] .runtime-stream {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--run-surface-0);
  border: 1px solid var(--run-line);
  border-radius: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--run-line) transparent;
}

body[data-oneai-route="runtime"] .runtime-stream::-webkit-scrollbar {
  width: 6px;
}

body[data-oneai-route="runtime"] .runtime-stream::-webkit-scrollbar-thumb {
  background: var(--run-line);
  border-radius: 3px;
}

/* Compact Telemetry Row: 54-62px height */
body[data-oneai-route="runtime"] .runtime-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--run-line-soft);
  background: transparent;
  transition: background 0.12s ease;
  flex: none;
}

body[data-oneai-route="runtime"] .runtime-item:last-child {
  border-bottom: none;
}

body[data-oneai-route="runtime"] .runtime-item:hover {
  background: var(--run-surface-hover);
}

/* Warning & Error rows elevate */
body[data-oneai-route="runtime"] .runtime-item.is-error {
  background: rgba(248, 113, 113, 0.035);
  min-height: 64px;
  align-items: flex-start;
  padding: 10px 16px;
}

body[data-oneai-route="runtime"] .runtime-item.is-warning {
  background: rgba(251, 191, 36, 0.025);
  min-height: 64px;
  align-items: flex-start;
  padding: 10px 16px;
}

body[data-oneai-route="runtime"] .runtime-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--run-surface-2);
  border: 1px solid var(--run-line);
  color: var(--run-cyan);
}

body[data-oneai-route="runtime"] .runtime-icon.result-ok {
  background: var(--run-green-soft);
  border-color: var(--run-green-border);
  color: var(--run-green);
}

body[data-oneai-route="runtime"] .runtime-icon.result-warn {
  background: var(--run-amber-soft);
  border-color: var(--run-amber-border);
  color: var(--run-amber);
}

body[data-oneai-route="runtime"] .runtime-icon.result-bad {
  background: var(--run-red-soft);
  border-color: var(--run-red-border);
  color: var(--run-red);
}

body[data-oneai-route="runtime"] .runtime-icon svg {
  width: 14px;
  height: 14px;
}

/* Horizontal single-line row flow for high information density */
body[data-oneai-route="runtime"] .runtime-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

body[data-oneai-route="runtime"] .runtime-item.is-warning .runtime-body,
body[data-oneai-route="runtime"] .runtime-item.is-error .runtime-body {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

body[data-oneai-route="runtime"] .runtime-header-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

body[data-oneai-route="runtime"] .runtime-who {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--run-text-bright);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex: none;
}

body[data-oneai-route="runtime"] .runtime-dot {
  color: var(--run-dim);
  font-size: 11px;
  flex: none;
}

body[data-oneai-route="runtime"] .runtime-title-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--run-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Normal events hide secondary description for single-line compactness; warning/error show it */
body[data-oneai-route="runtime"] .runtime-item:not(.is-warning):not(.is-error) .runtime-what {
  display: none;
}

body[data-oneai-route="runtime"] .runtime-item.is-warning .runtime-what,
body[data-oneai-route="runtime"] .runtime-item.is-error .runtime-what {
  display: block;
  font-size: 11px;
  color: var(--run-muted);
  line-height: 1.4;
}

body[data-oneai-route="runtime"] .runtime-meta {
  font-size: 10.5px;
  color: var(--run-dim);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-family: var(--run-mono);
  white-space: nowrap;
}

body[data-oneai-route="runtime"] .runtime-time {
  color: var(--run-muted);
}

body[data-oneai-route="runtime"] .runtime-id {
  color: var(--run-dim);
}

body[data-oneai-route="runtime"] .runtime-route {
  color: var(--run-cyan);
  opacity: 0.85;
}

body[data-oneai-route="runtime"] .runtime-result {
  flex: none;
  display: flex;
  align-items: center;
  margin-left: 4px;
}

body[data-oneai-route="runtime"] .runtime-badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  font-family: var(--run-mono);
  white-space: nowrap;
}

body[data-oneai-route="runtime"] .runtime-badge.result-ok,
body[data-oneai-route="runtime"] .result-ok {
  color: var(--run-green);
  background: var(--run-green-soft);
  border-color: var(--run-green-border);
}

body[data-oneai-route="runtime"] .runtime-badge.result-warn,
body[data-oneai-route="runtime"] .result-warn {
  color: var(--run-amber);
  background: var(--run-amber-soft);
  border-color: var(--run-amber-border);
}

body[data-oneai-route="runtime"] .runtime-badge.result-bad,
body[data-oneai-route="runtime"] .result-bad {
  color: var(--run-red);
  background: var(--run-red-soft);
  border-color: var(--run-red-border);
}

/* ==========================================================================
   6. Empty State
   ========================================================================== */
body[data-oneai-route="runtime"] .empty {
  padding: 40px 20px;
  text-align: center;
  background: transparent;
  border: none;
  margin: auto;
}

body[data-oneai-route="runtime"] .empty b {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--run-text);
  margin-bottom: 4px;
}

body[data-oneai-route="runtime"] .empty p {
  margin: 0;
  font-size: 11px;
  color: var(--run-dim);
}

/* ==========================================================================
   7. Responsive Adaptations (Mobile 390px)
   ========================================================================== */
@media (max-width: 640px) {
  body[data-oneai-route="runtime"] .shared-view {
    padding: 16px 14px 16px;
    gap: 12px;
    height: auto;
    max-height: none;
    overflow-y: auto;
  }

  body[data-oneai-route="runtime"] .shared-body {
    overflow: visible;
  }

  body[data-oneai-route="runtime"] .shared-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  body[data-oneai-route="runtime"] .shared-actions {
    justify-content: flex-start;
  }

  body[data-oneai-route="runtime"] .runtime-sentinel-band {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  body[data-oneai-route="runtime"] .sentinel-divider {
    display: none;
  }

  body[data-oneai-route="runtime"] .runtime-stream {
    overflow: visible;
  }

  body[data-oneai-route="runtime"] .runtime-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    min-height: auto;
  }

  body[data-oneai-route="runtime"] .runtime-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  body[data-oneai-route="runtime"] .runtime-header-line {
    flex-wrap: wrap;
  }

  body[data-oneai-route="runtime"] .runtime-item:not(.is-warning):not(.is-error) .runtime-what {
    display: block;
    font-size: 11px;
    color: var(--run-muted);
  }

  body[data-oneai-route="runtime"] .runtime-result {
    align-self: flex-start;
    margin-left: 0;
  }
}
