/* ---------------------------------------------------------------------------
   Shared styling for both dashboards (Socket.IO and ActiveMQ/STOMP).
   System Architecture and Integration Course - Real-Time Telemetry module.
   --------------------------------------------------------------------------- */

:root {
  --bg:      #0b1120;
  --panel:   #0f172a;
  --panel-2: #131f38;
  --line:    #1e293b;
  --ink:     #e2e8f0;
  --muted:   #94a3b8;
  --dim:     #64748b;
  --accent:  #38bdf8;
  --ok:      #22c55e;
  --warn:    #f59e0b;
  --bad:     #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }

/* ------------------------------------------------------------------ shell */
#app { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #sidebar { max-height: 42vh; }
}

#sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}

.brand { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.brand .eyebrow {
  margin: 0 0 5px; font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent);
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 600; }
.brand .transport {
  margin: 8px 0 0; font-size: 11px; color: var(--dim);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; word-break: break-all;
}

/* ----------------------------------------------------------------- status */
.status {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 10px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on   { background: var(--ok);   box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.wait { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.off  { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }

/* ------------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.stat { background: var(--panel); padding: 10px 12px; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); }
.stat .v { margin-top: 2px; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ device list */
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px;
}
.list-head h2 {
  margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--dim);
}
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  border-radius: 7px; padding: 4px 9px; font-size: 11px; transition: background .12s;
}
.btn:hover { background: #1c2a49; }

#deviceList { flex: 1; overflow-y: auto; padding: 4px 10px 14px; }
.empty { color: var(--dim); font-size: 12px; text-align: center; padding: 26px 10px; line-height: 1.6; }

.device {
  display: block; width: 100%; text-align: left; margin-bottom: 7px; padding: 9px 11px;
  border: 1px solid var(--line); border-left: 3px solid var(--pin, var(--accent));
  border-radius: 9px; background: var(--panel-2); color: inherit; transition: background .12s;
}
.device:hover { background: #1a2742; }
.device-followed { outline: 1px solid var(--accent); }
.device-offline { opacity: .5; }

.device-head { display: flex; align-items: center; gap: 7px; }
.device-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pin); flex: none; }
.device-name { font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-ago { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; flex: none; }

.device-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip {
  font-size: 10px; padding: 2px 6px; border-radius: 5px;
  background: #0b1526; color: var(--muted); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.device-coords {
  margin-top: 6px; font-size: 11px; color: var(--dim);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.side-foot {
  padding: 11px 16px; border-top: 1px solid var(--line);
  font-size: 11px; line-height: 1.6; color: var(--dim);
}
.side-foot code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: var(--accent); }
.side-foot a { color: var(--accent); }

/* -------------------------------------------------------------------- map */
#map { height: 100%; width: 100%; background: #0b1120; }
.leaflet-container { background: #0b1120; }
/* Tone the tiles down so the coloured pins carry the eye. */
.leaflet-tile-pane { filter: brightness(.68) saturate(.75) contrast(1.06); }
.leaflet-control-attribution { background: rgba(15,23,42,.85) !important; color: var(--dim) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
.leaflet-popup-content { margin: 10px 13px; font-size: 12px; line-height: 1.5; }

/* ------------------------------------------------------------------- pins */
.pin-wrap { background: none; border: 0; }
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--pin); border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  display: grid; place-items: center; position: relative;
  color: #fff; font-size: 10px; font-weight: 700;
}
.pin-offline { filter: grayscale(1); opacity: .55; }
.pin span { position: relative; z-index: 1; }
/* A small triangle outside the circle, rotated to the reported heading. */
.pin-heading {
  position: absolute; inset: -9px; pointer-events: none;
}
.pin-heading::before {
  content: ''; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 8px solid var(--pin);
  filter: drop-shadow(0 0 1px rgba(255,255,255,.7));
}
