/* ============================================================================
   Airspace — 3D Map Canvas, Toolbar & Drawing
   ============================================================================ */

.sp-map-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

.sp-map-3d {
  width: 100%;
  height: 100%;
}
.sp-map-3d gmp-map-3d {
  width: 100%;
  height: 100%;
}

/* --- Sidebar Expand Button (shown when sidebar is collapsed) -------------- */
.sp-sidebar-expand {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  background: var(--sp-panel);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 6px;
  cursor: pointer;
  color: var(--sp-cyan);
}
.sp-sidebar-expand:hover {
  background: var(--sp-panel-alt);
  box-shadow: var(--sp-glow-sm);
}

/* --- Map Toolbar (bottom) ------------------------------------------------- */
.sp-map-toolbar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 6px 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
  max-width: calc(100% - 24px);
}

.sp-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sp-toolbar-right-group {
  margin-left: auto;
}

.sp-toolbar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sp-text-dim);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--sp-font);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.15s;
  white-space: nowrap;
}
.sp-toolbar-btn:hover {
  background: rgba(0, 212, 255, 0.08);
  color: var(--sp-text);
  border-color: rgba(0, 212, 255, 0.15);
}
.sp-toolbar-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--sp-cyan);
  border-color: rgba(0, 212, 255, 0.35);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.15);
}

.sp-toolbar-sep {
  width: 1px;
  height: 20px;
  background: rgba(0, 212, 255, 0.15);
  margin: 0 4px;
}

.sp-toolbar-coords {
  font-family: var(--sp-mono);
  font-size: 10px;
  color: var(--sp-text-dim);
  min-width: 160px;
  text-align: right;
}

/* --- Drawing Hint Overlay ------------------------------------------------- */
.sp-draw-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 212, 255, 0.12);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--sp-cyan);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 20;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.2s;
}

/* --- Map Info Overlay (drone popup on map) -------------------------------- */
.sp-map-popup {
  background: color-mix(in srgb, var(--bg-surface) 95%, transparent);
  border: 1px solid var(--sp-border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  color: var(--sp-text);
}
.sp-map-popup-title {
  font-weight: 700;
  color: var(--sp-cyan);
  font-size: 13px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.sp-map-popup-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.sp-map-popup-key { color: var(--sp-text-dim); }
.sp-map-popup-val { font-family: var(--sp-mono); color: var(--sp-text); }

/* --- Custom 3D SVG markers ------------------------------------------------- */
.sp-3d-marker {
  display: block;
  overflow: visible;
  pointer-events: none;
  transform-origin: center bottom;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
  transition: transform 0.15s ease, filter 0.15s ease;
}

.sp-3d-marker.is-selected {
  transform: scale(1.18);
  filter:
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.3))
    drop-shadow(0 8px 22px rgba(0, 0, 0, 0.65));
}

/* --- Ground marker context menu + Street View cards ----------------------- */
.sp-ground-ctx-menu {
  position: fixed;
  min-width: 220px;
  background: color-mix(in srgb, var(--bg-base) 96%, transparent);
  border: 1px solid rgba(122, 166, 255, 0.24);
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  padding: 10px;
  z-index: 90;
}

.sp-ground-ctx-title {
  color: var(--sp-text);
  font-family: var(--sp-font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.sp-ground-ctx-meta {
  color: var(--sp-text-dim);
  font-size: 11px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.sp-ground-ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(122, 166, 255, 0.08);
  border: 1px solid rgba(122, 166, 255, 0.16);
  border-radius: 8px;
  color: var(--sp-text);
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sp-font);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sp-ground-ctx-item:hover {
  background: rgba(122, 166, 255, 0.14);
  border-color: rgba(122, 166, 255, 0.28);
  transform: translateY(-1px);
}

.sp-ground-card {
  position: fixed;
  width: min(540px, calc(100vw - 20px));
  height: min(420px, calc(100vh - 20px));
  min-width: 420px;
  min-height: 340px;
  max-width: calc(100vw - 12px);
  max-height: calc(100vh - 12px);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg-deep) 96%, transparent);
  border: 1px solid rgba(122, 166, 255, 0.22);
  border-radius: 14px;
  overflow: hidden;
  resize: both;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(12px);
  z-index: 80;
}

.sp-ground-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  background:
    linear-gradient(180deg, rgba(122, 166, 255, 0.12), rgba(122, 166, 255, 0) 70%),
    color-mix(in srgb, var(--bg-base) 88%, transparent);
  border-bottom: 1px solid rgba(122, 166, 255, 0.14);
  cursor: move;
}

.sp-ground-card-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sp-ground-card-eyebrow {
  color: rgba(122, 166, 255, 0.82);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sp-ground-card-title {
  color: var(--sp-text);
  font-family: var(--sp-font-display);
  font-size: 16px;
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-ground-card-subtitle {
  color: var(--sp-text-dim);
  font-size: 11px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-ground-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sp-ground-card-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(122, 166, 255, 0.08);
  border: 1px solid rgba(122, 166, 255, 0.16);
  border-radius: 8px;
  color: var(--sp-text);
  cursor: pointer;
}

.sp-ground-card-btn:hover {
  background: rgba(122, 166, 255, 0.14);
  border-color: rgba(122, 166, 255, 0.28);
}

.sp-ground-card-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 250px;
  background: #07121a;
}

.sp-ground-card-panorama {
  width: 100%;
  height: 100%;
}

.sp-ground-card-status {
  position: absolute;
  inset: 16px auto auto 16px;
  max-width: calc(100% - 170px);
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-deep) 78%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sp-text);
  font-size: 11px;
  line-height: 1.4;
  display: none;
  z-index: 2;
}

.sp-ground-card-status.is-visible {
  display: block;
}

.sp-ground-card-map {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 144px;
  height: 118px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.sp-ground-card-hud {
  position: absolute;
  left: 14px;
  right: 172px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-deep) 76%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.sp-ground-card-badge {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #07121a;
  font-family: var(--sp-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--ground-badge, #7aa6ff);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.sp-ground-card-hud-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sp-ground-card-hud-copy strong {
  color: var(--sp-text);
  font-family: var(--sp-mono);
  font-size: 12px;
  line-height: 1.2;
}

.sp-ground-card-hud-copy span {
  color: var(--sp-text-dim);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .sp-ground-card {
    width: calc(100vw - 16px);
    min-width: 0;
    height: min(380px, calc(100vh - 16px));
  }

  .sp-ground-card-stage {
    min-height: 270px;
  }

  .sp-ground-card-map {
    width: 128px;
    height: 102px;
    right: 10px;
    bottom: 10px;
  }

  .sp-ground-card-hud {
    left: 10px;
    right: 148px;
    bottom: 10px;
    padding: 8px 10px;
  }

  .sp-ground-card-status {
    max-width: calc(100% - 148px);
  }
}

/* ============================================================================
   Operator HUD (top-left + top-right map overlays)
   ============================================================================ */
.sp-hud {
  position: absolute;
  z-index: 18;
  pointer-events: none;
  /* HUD widgets float over a satellite map on a semi-opaque black backdrop,
     so they need light text in both themes. Scoped overrides keep the rest
     of the theme system intact. */
  --sp-text: #F2EEE9;
  --sp-text-dim: #C4C2CC;
  color: var(--sp-text);
  font-family: var(--sp-mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.sp-hud-tl {
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.sp-hud-tr {
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

/* --- Scale bar -------------------------------------------------------- */
.sp-hud-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  backdrop-filter: blur(6px);
}
.sp-hud-scale-bar {
  height: 6px;
  border: 1px solid var(--sp-cyan);
  border-top: none;
  background: linear-gradient(
    to right,
    var(--sp-cyan) 50%,
    transparent 50%
  );
  background-size: 24px 100%;
  min-width: 40px;
  border-radius: 0;
}
.sp-hud-scale-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--sp-cyan);
  white-space: nowrap;
}

/* --- Center readout -------------------------------------------------- */
.sp-hud-readout {
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 3px;
  backdrop-filter: blur(6px);
  min-width: 168px;
}
.sp-hud-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  line-height: 1.5;
}
.sp-hud-key {
  color: var(--sp-text-dim);
  font-weight: 600;
  letter-spacing: 0.08em;
}
.sp-hud-val {
  color: var(--sp-text);
  font-weight: 600;
}

/* --- North rose ------------------------------------------------------ */
.sp-hud-rose-wrap {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  cursor: pointer;
  color: var(--sp-cyan);
  transition: border-color 0.12s, background 0.12s;
}
.sp-hud-rose-wrap:hover {
  background: rgba(0, 0, 0, 0.55);
  border-color: var(--sp-cyan);
}
.sp-hud-rose {
  transition: transform 0.15s linear;
}

/* --- Selected-track strip ------------------------------------------- */
.sp-hud-track {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--sp-cyan);
  border-left: 3px solid var(--sp-cyan);
  border-radius: 3px;
  backdrop-filter: blur(8px);
  min-width: 220px;
  max-width: 320px;
  text-align: right;
  pointer-events: auto;
}
.sp-hud-track-cs {
  font-size: 13px;
  font-weight: 700;
  color: var(--sp-cyan);
  letter-spacing: 0.04em;
}
.sp-hud-track-meta {
  font-size: 11px;
  color: var(--sp-text);
  letter-spacing: 0.02em;
}
.sp-hud-track-age {
  font-size: 10px;
  color: var(--sp-text-dim);
  letter-spacing: 0.04em;
}
.sp-hud-track-age.is-stale {
  color: var(--sp-amber);
}

/* ============================================================================
   Floating Radio Dock (bottom-right)
   ============================================================================ */
.sp-radio-dock {
  position: absolute;
  z-index: 19;
  right: 12px;
  bottom: 64px;
  width: 220px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--sp-border);
  border-radius: 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  font-family: var(--sp-font);
  /* Match HUD: dark glass dock needs light text in both themes. */
  --sp-text: #F2EEE9;
  --sp-text-dim: #C4C2CC;
  color: var(--sp-text);
}
.sp-radio-dock.is-hidden {
  display: none;
}
.sp-radio-dock-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 212, 255, 0.08);
  border-bottom: 1px solid var(--sp-border);
}
.sp-radio-dock-title {
  font-family: var(--sp-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--sp-cyan);
}
.sp-radio-dock-header .sp-radio-status {
  margin-left: auto;
  min-width: 0;
}
.sp-radio-dock-close {
  background: none;
  border: none;
  color: var(--sp-text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.sp-radio-dock-close:hover {
  color: var(--sp-cyan);
}
.sp-radio-dock-body {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
}
.sp-radio-dock-body .sp-radio-channel-wrap {
  flex: 1;
}
.sp-radio-dock-body .sp-radio-channel {
  width: 100%;
}
.sp-radio-dock-body .sp-radio-ptt {
  flex-shrink: 0;
}

/* When measure mode is active, give the map a crosshair cursor */
body.sp-measure-active .sp-map-3d,
body.sp-measure-active .sp-map-3d gmp-map-3d {
  cursor: crosshair;
}
#toolMeasure.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--sp-cyan);
  border-color: rgba(0, 212, 255, 0.35);
}
