/* engine.css — shared styling for bq-demo-engine components.
   Brand tokens mirror engine/theme.js. Any demo that uses the components links this
   once; demo-specific layout lives in the demo's own stylesheet. */

:root {
  --bq-bg: #0d0f1a;
  --bq-panel: #151827;
  --bq-elevated: #1c2033;
  --bq-orange: #e86a10;
  --bq-orange-soft: #f59245;
  --bq-on-accent: #ffffff; /* text/icon color on an orange (accent) fill */
  --bq-text: #e7eaf3;
  --bq-muted: #8a90a6;
  --bq-faint: #5a607a;
  --bq-border: #262b40;
  --bq-ok: #2fbf71;
  --bq-info: #3b82f6;
  --bq-warning: #f5a623;
  --bq-critical: #e5484d;
  --bq-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- KPI card ---- */
.bq-kpi {
  background: var(--bq-panel);
  border: 1px solid var(--bq-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.bq-kpi .kpi-label {
  font-size: 12px;
  color: var(--bq-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bq-kpi .kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.bq-kpi .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--bq-text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.bq-kpi .kpi-unit {
  font-size: 13px;
  color: var(--bq-muted);
}
.bq-kpi .kpi-sub {
  font-size: 11px;
  color: var(--bq-faint);
}

/* ---- Alert feed ---- */
.bq-alert-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.bq-alert-feed .alert-empty {
  color: var(--bq-faint);
  font-size: 13px;
  padding: 12px;
  text-align: center;
}
.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bq-elevated);
  border: 1px solid var(--bq-border);
  border-left: 3px solid var(--bq-muted);
  border-radius: 8px;
  padding: 8px 10px;
}
.alert-row.is-acked {
  opacity: 0.55;
}
.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.alert-body {
  flex: 1 1 auto;
  min-width: 0;
}
.alert-msg {
  font-size: 13px;
  color: var(--bq-text);
  line-height: 1.3;
}
.alert-meta {
  font-size: 11px;
  color: var(--bq-faint);
  margin-top: 2px;
}
.alert-tag {
  font-size: 9px;
  font-weight: 700;
  border: 1px solid;
  border-radius: 4px;
  padding: 1px 4px;
  margin-right: 6px;
  letter-spacing: 0.05em;
  vertical-align: middle;
}
.alert-ack {
  flex: 0 0 auto;
  background: transparent;
  color: var(--bq-orange);
  border: 1px solid var(--bq-orange);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--bq-font);
}
.alert-ack:hover {
  background: var(--bq-orange);
  color: var(--bq-on-accent);
}
.alert-acked {
  font-size: 11px;
  color: var(--bq-faint);
  flex: 0 0 auto;
}

/* ---- Device grid ---- */
.bq-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14px, 1fr));
  gap: 4px;
  align-content: start;
}
.device-tile {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: var(--bq-faint);
  transition: background 0.4s ease;
  will-change: transform;
}

/* ---- Narration chips ---- */
.bq-narration {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 40;
}
.narration-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(21, 24, 39, 0.92);
  border: 1px solid var(--bq-border);
  border-left-width: 3px;
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--bq-text);
  font-size: 13px;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}
.narration-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ---- Map fleet (Leaflet) ---- */
.bq-map {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bq-elevated);
}
.map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 260px;
  color: var(--bq-faint);
  font-size: 12px;
}
.map-truck-icon {
  background: transparent;
  border: none;
}
.truck-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bq-bg);
}
.leaflet-popup-content-wrapper {
  background: var(--bq-elevated);
  color: var(--bq-text);
  border: 1px solid var(--bq-border);
  border-radius: 10px;
  font-family: var(--bq-font);
}
.leaflet-popup-tip {
  background: var(--bq-elevated);
}
.leaflet-container a.leaflet-popup-close-button {
  color: var(--bq-muted);
}
.leaflet-tooltip {
  background: var(--bq-elevated);
  color: var(--bq-text);
  border: 1px solid var(--bq-border);
  font-family: var(--bq-font);
  font-size: 11px;
}

/* ---- Floor plan (interactive SVG) ---- */
.bq-floor-plan {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border-radius: 14px;
  overflow: hidden;
}
.floor-plan-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.floor-room rect {
  transition: fill 0.5s ease, stroke 0.5s ease;
}
.floor-room.is-waste rect:first-of-type {
  stroke: var(--bq-warning);
  stroke-dasharray: 5 3;
}
.floor-switch {
  cursor: pointer;
}
.floor-switch:focus-visible {
  outline: 2px solid var(--bq-orange);
  outline-offset: 2px;
}
.floor-switch-knob {
  transition: fill 0.2s ease;
}

/* ---- Rive stub ---- */
.bq-rive-stub {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--bq-border);
  border-radius: 12px;
  color: var(--bq-faint);
  font-size: 12px;
  min-height: 120px;
}
