/* ═══════════════════════════════════════════════
   DESIGN TOKENS — per sense_ai_ui_spec.html §9
═══════════════════════════════════════════════ */
:root {
  --bg:       #0a0c0f;
  --bg2:      #0f1115;
  --bg3:      #13161b;
  --bg4:      #1a1e25;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.13);
  --green:    #00e676;
  --green-dim:rgba(0,230,118,0.14);
  --green-faint:rgba(0,230,118,0.05);
  --amber:    #ffb300;
  --red:      #ef5350;
  --text:     #e8eaed;
  --text2:    #8a9099;
  --text3:    #50565f;
  --mono:     'Share Tech Mono', monospace;
  --sans:     'DM Sans', sans-serif;
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  overflow: auto;
}

/* ═══════════════════════════════════════════════
   DASHBOARD SHELL
═══════════════════════════════════════════════ */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   NAV BAR — 48px (two-line center)
═══════════════════════════════════════════════ */
.nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  height: 48px;
  padding: 0 14px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.nav-col {
  display: flex;
  align-items: center;
}

.nav-left {
  gap: 8px;
}
.nav-logo-img {
  width: 22px; height: 22px;
  border-radius: 3px;
  flex-shrink: 0;
}
.nav-logo-text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  font-weight: 400;
}

.nav-center {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}
.nav-center-top {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.12em;
  font-weight: 500;
}
.nav-center-bottom {
  display: flex;
  gap: 10px;
  align-items: center;
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
}
.nav-pill.connected .pill-dot { background: var(--green); }
.nav-pill.disconnected .pill-dot { background: var(--red); animation: none; }
.nav-pill.degraded .pill-dot { background: var(--amber); animation: none; }

.pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: pulse 2s ease-in-out infinite;
}

.nav-right {
  justify-content: flex-end;
}

.nav-clock {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  text-align: right;
}
.nav-clock small {
  color: var(--text2);
  font-size: 10px;
  margin-right: 3px;
}

/* ═══════════════════════════════════════════════
   BODY ROW — content (flex:4) + sidebar (flex:1)
═══════════════════════════════════════════════ */
.body-row {
  display: flex;
  flex: 1;
  min-height: 600px;
}

.content {
  flex: 4;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.07);
  min-width: 0;
}

/* ═══════════════════════════════════════════════
   SECTION BAR
═══════════════════════════════════════════════ */
.section-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg3);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sbar-lbl {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex: 1;
}

.sbar-cid {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text2);
}

.sbar-rec {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--red);
}
.sbar-rec::before {
  content: '';
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 0.8s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════
   CAMERA PANELS
═══════════════════════════════════════════════ */
.cam-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cam-panel.cam-a {
  flex: 1;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.cam-panel.cam-b {
  flex: 1;
  border-right: 1px solid rgba(255,255,255,0.07);
}

.cam-feed {
  flex: 1;
  background: #000;
  position: relative;
  overflow: hidden;
}

.cam-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.cam-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  z-index: 2;
}
.cam-placeholder svg {
  width: 22px; height: 22px;
  stroke: #333; fill: none; stroke-width: 1.5;
}
.cam-placeholder p {
  font-family: var(--mono);
  font-size: 8px;
  color: #333;
  letter-spacing: 0.08em;
}
.cam-placeholder.hidden { display: none; }

.cam-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg3);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.cam-badge {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 2px;
}

.cam-stat {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
}
.cam-stat strong { color: var(--text2); font-weight: 400; }

.cam-footer-sep { flex: 1; }

/* ═══════════════════════════════════════════════
   BOTTOM ROW — Cam B + Sensor side-by-side
═══════════════════════════════════════════════ */
.bottom-row {
  flex: 1.2;
  display: flex;
  min-height: 0;
}

/* ═══════════════════════════════════════════════
   SENSOR / HEATMAP PANEL
═══════════════════════════════════════════════ */
.sensor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.heatmap-feed {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

#heatmap-canvas {
  display: block;
  border-radius: 2px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  max-height: 100%;
}

/* ═══════════════════════════════════════════════
   FLOOR BAR — 32px
═══════════════════════════════════════════════ */
.floor-bar {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 32px;
  background: var(--bg3);
  border-top: 1px solid rgba(255,255,255,0.07);
  gap: 8px;
  flex-shrink: 0;
}

.floor-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  letter-spacing: 0.1em;
  flex: 1;
}

.floor-btn {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 2px;
  cursor: pointer;
}
.floor-btn:hover { border-color: var(--border2); color: var(--text2); }
.floor-btn.active {
  color: var(--green);
  background: rgba(0,230,118,0.08);
  border-color: rgba(0,230,118,0.2);
}

/* ═══════════════════════════════════════════════
   SIDEBAR — flex:1
═══════════════════════════════════════════════ */
.sidebar {
  flex: 1;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  min-width: 280px;
  max-width: 400px;
}

.sb-section {
  flex: 1;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sb-sec-lbl {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 5px;
  margin-bottom: 2px;
}

.sb-body {
  font-size: 10.5px;
  color: var(--text2);
  line-height: 1.6;
}

.sb-flow {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 4px;
}

.sb-fn {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--green);
  min-width: 16px;
}

.sb-ft {
  font-size: 10px;
  color: var(--text2);
  line-height: 1.5;
}
.sb-ft strong {
  color: var(--text);
  font-weight: 500;
}

.sb-arr {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  padding-left: 21px;
}

.sb-sensor-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.sb-sname {
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
}

.sb-smodel {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
}

.sb-det-badge {
  margin-top: 6px;
  border: 1px solid var(--green);
  background: var(--green-faint);
  border-radius: 4px;
  padding: 6px 8px;
}

.sb-det-lbl {
  font-family: var(--mono);
  font-size: 7px;
  color: var(--green);
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.sb-det-num {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--green);
  line-height: 1;
  transition: opacity 0.2s ease;
}
.sb-det-num.updating { opacity: 0.4; }

.sb-det-unit {
  font-family: var(--mono);
  font-size: 7px;
  color: var(--text3);
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════
   FLOORPLAN PANEL (collapsible)
═══════════════════════════════════════════════ */
.floorplan-panel {
  display: flex;
  flex-direction: column;
  height: 50vh;
  min-height: 350px;
  background: var(--bg);
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.fp-spacer { flex: 1; }

.fp-tag {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 2px;
}

.floorplan-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#floorplan-img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#floorplan-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ═══════════════════════════════════════════════
   PEOPLE DOTS (SenseAI alignment)
═══════════════════════════════════════════════ */
.person-dot {
  position: absolute;
  width: var(--dot-size, 100px);
  height: var(--dot-size, 100px);
  margin-left: calc(var(--dot-size, 100px) * -0.5);
  margin-top: calc(var(--dot-size, 100px) * -0.5);
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,230,118,0.18) 0%, rgba(0,230,118,0.06) 40%, transparent 65%);
  border: max(1px, calc(var(--dot-size, 100px) * 0.02)) solid rgba(0,230,118,0.35);
  box-shadow:
    0 0 calc(var(--dot-size, 100px) * 0.24) rgba(0,230,118,0.25),
    0 0 calc(var(--dot-size, 100px) * 0.6) rgba(0,230,118,0.12);
  animation: personRingPulse 2.4s ease-in-out infinite;
}

.person-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    linear-gradient(to right, transparent calc(50% - 1px), rgba(0,230,118,0.5) calc(50% - 1px), rgba(0,230,118,0.5) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), rgba(0,230,118,0.5) calc(50% - 1px), rgba(0,230,118,0.5) calc(50% + 1px), transparent calc(50% + 1px));
  opacity: 0.9;
  animation: personCrossFade 1.8s ease-in-out infinite;
}

.person-dot::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: calc(var(--dot-size, 100px) * 0.16);
  height: calc(var(--dot-size, 100px) * 0.16);
  margin-left: calc(var(--dot-size, 100px) * -0.08);
  margin-top: calc(var(--dot-size, 100px) * -0.08);
  border-radius: 50%;
  background: #00e676;
  border: max(1px, calc(var(--dot-size, 100px) * 0.02)) solid rgba(255,255,255,0.5);
  box-shadow:
    0 0 calc(var(--dot-size, 100px) * 0.14) rgba(0,230,118,0.9),
    0 0 calc(var(--dot-size, 100px) * 0.32) rgba(0,230,118,0.6),
    0 0 calc(var(--dot-size, 100px) * 0.5) rgba(0,230,118,0.3),
    inset 0 0 calc(var(--dot-size, 100px) * 0.06) rgba(255,255,255,0.4);
  animation: personDotPulse 1.6s ease-in-out infinite;
}

@keyframes personRingPulse {
  0%, 100% { border-color: rgba(0,230,118,0.35); transform: scale(1); }
  50%      { border-color: rgba(0,230,118,0.65); transform: scale(1.1); }
}

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

@keyframes personDotPulse { 0%, 100% { background: #00e676; } 50% { background: #69f0ae; } }

/* ═══════════════════════════════════════════════
   KEYFRAMES
═══════════════════════════════════════════════ */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ═══════════════════════════════════════════════
   RESPONSIVE — tablet / small desktop (≤1100px)
═══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .nav { height: auto; padding: 6px 10px; grid-template-columns: 1fr 1fr; }
  .nav-right { grid-column: 2; justify-self: end; }
  .nav-center { grid-column: 1 / -1; }
  .nav-clock { font-size: 12px; }

  .body-row { flex-direction: column; }
  .content { flex: none; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.07); }
  .sidebar {
    flex: none; flex-direction: row;
    min-width: auto; max-width: none;
    max-height: 140px; overflow-y: auto;
  }
  .sb-section { flex: 1; min-width: 0; }

  .cam-panel.cam-a { min-height: 240px; }
  .bottom-row { min-height: 200px; }

  .floorplan-panel { height: 40vh; min-height: 250px; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — phones (≤600px)
═══════════════════════════════════════════════ */
@media (max-width: 600px) {
  html, body { font-size: 11px; overflow: auto; }
  .dashboard { height: auto; min-height: 100vh; }

  .nav {
    grid-template-columns: 1fr;
    height: auto;
    padding: 4px 6px;
    gap: 4px;
  }
  .nav-left { justify-content: center; }
  .nav-right { grid-column: 1; justify-self: center; }
  .nav-center { grid-column: 1; }
  .nav-center-top { font-size: 12px; }
  .nav-clock { font-size: 11px; }
  .nav-pill { font-size: 8px; gap: 3px; }
  .pill-dot { width: 4px; height: 4px; }

  .body-row { flex-direction: column; }
  .content { flex: none; border-right: none; }

  .cam-panel.cam-a { min-height: 180px; }
  .bottom-row { min-height: 150px; flex-direction: column; }
  .cam-panel.cam-b { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.07); }

  .sidebar {
    flex: none; flex-direction: column;
    min-width: auto; max-width: none;
    max-height: none;
  }

  .section-bar { padding: 4px 6px; gap: 4px; }
  .sbar-lbl { font-size: 7px; }
  .cam-footer { padding: 3px 6px; gap: 4px; }
  .cam-badge { font-size: 7px; }
  .cam-stat { font-size: 7px; }

  .floor-bar { height: 28px; padding: 0 6px; gap: 4px; }
  .floor-lbl { font-size: 7px; }
  .floor-btn { font-size: 7px; padding: 1px 5px; }

  .floorplan-panel { height: 35vh; min-height: 200px; }
}
