<script setup lang="ts">
import ControlPanel from '@/components/ControlPanel.vue'
import GpsMapPanel from '@/components/GpsMapPanel.vue'
import NetworkPanel from '@/components/NetworkPanel.vue'
import VideoPanel from '@/components/VideoPanel.vue'
import { useMonitoringData } from '@/composables/useMonitoringData'

const { gps, network, video, errorMessage, headerStatus } = useMonitoringData()
</script>

<template>
  <div class="page-shell">
    <header class="hero">
      <div>
        <p class="eyebrow">Overview</p>
        <h1>Robot Command Center</h1>
      </div>
      <p class="hero-text">
        The A-side daemon now owns video receive, control ingress arbitration, and live session
        telemetry in one backend process.
      </p>
    </header>

    <section class="banner" :class="{ error: !!errorMessage }">
      {{ headerStatus }}
    </section>

    <main class="layout">
      <section class="primary-grid">
        <VideoPanel :video="video" />
        <ControlPanel />
      </section>

      <GpsMapPanel :gps="gps" />
      <NetworkPanel :network="network" />
    </main>
  </div>
</template>

<style scoped>
.page-shell {
  display: grid;
  gap: 22px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 20px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8da2fb;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.04;
}

.hero-text {
  margin: 0;
  color: #c8d2e8;
  font-size: 16px;
  line-height: 1.75;
}

.banner {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(11, 19, 35, 0.84);
  border: 1px solid rgba(133, 147, 169, 0.2);
  color: #d5dbee;
}

.banner.error {
  color: #ffd0d0;
  border-color: rgba(255, 107, 107, 0.28);
}

.layout {
  display: grid;
  gap: 20px;
}

.primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.95fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 1280px) {
  .primary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
  }
}
</style>
