/* ==============================================================================
   ASIAIRWeb - Public Spectator Theme (Read-Only Observatory Viewer)
   Modern Dark Glassmorphism, Red Accent, High Contrast Astro HUD
   ============================================================================== */

:root {
  --bg-primary: #0a0b0e;
  --bg-surface: rgba(18, 20, 26, 0.82);
  --bg-card: rgba(26, 30, 40, 0.75);
  --bg-card-hover: rgba(36, 42, 56, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(255, 59, 48, 0.4);
  
  --text-main: #f0f2f5;
  --text-muted: #8b92a5;
  --text-dim: #5a6072;
  
  --zwo-red: #ff3b30;
  --zwo-red-glow: rgba(255, 59, 48, 0.35);
  --cyan-accent: #00d2ff;
  --green-online: #30d158;
  --orange-warn: #ff9f0a;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Night Mode (Red Light for dark sky observers) */
body.night-mode {
  --bg-primary: #050000;
  --bg-surface: rgba(25, 0, 0, 0.9);
  --bg-card: rgba(35, 0, 0, 0.85);
  --border-subtle: rgba(255, 0, 0, 0.2);
  --border-accent: rgba(255, 0, 0, 0.6);
  --text-main: #ff4d4d;
  --text-muted: #aa2222;
  --text-dim: #661111;
  --zwo-red: #ff2222;
  --cyan-accent: #ff4d4d;
  --green-online: #ff6666;
  --orange-warn: #ff5555;
}

body.night-mode .live-canvas,
body.night-mode .guider-canvas {
  filter: sepia(100%) hue-rotate(310deg) saturate(300%) brightness(0.9);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* ==============================================================================
   Top Navigation Bar
   ============================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  flex-shrink: 0;
}

.top-left, .top-right, .top-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 59, 48, 0.12);
  border: 1px solid var(--border-accent);
  padding: 4px 10px;
  border-radius: var(--radius-md);
}

.brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--zwo-red);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px var(--zwo-red-glow);
}

.brand-title {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.brand-tag {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--zwo-red);
  font-weight: 600;
  background: rgba(255, 59, 48, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--orange-warn);
  transition: all 0.3s;
}

.led-dot.online {
  background-color: var(--green-online);
  box-shadow: 0 0 8px var(--green-online);
  animation: pulse-online 2s infinite;
}

.led-dot.offline {
  background-color: var(--zwo-red);
  box-shadow: 0 0 8px var(--zwo-red);
}

@keyframes pulse-online {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Target Badge */
.target-badge {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 12px;
}

.target-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.target-name {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.target-constellation {
  font-size: 11px;
  color: var(--text-muted);
}

.target-coords {
  display: flex;
  gap: 10px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 1px;
}

/* Telemetry Strip */
.telemetry-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 10px;
}

.t-item {
  display: flex;
  flex-direction: column;
  padding: 0 6px;
  border-right: 1px solid var(--border-subtle);
}

.t-item:last-child {
  border-right: none;
}

.t-label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}

.t-val {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 600;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==============================================================================
   Main Telescope Viewport
   ============================================================================== */
.viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100% - 52px);
  overflow: hidden;
  background: radial-gradient(circle at center, #11141c 0%, #06070a 100%);
  cursor: grab;
}

.viewport:active {
  cursor: grabbing;
}

.viewport-canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
}

.live-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Reticle / Crosshair Overlay */
.reticle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}

.reticle-overlay.active {
  display: block;
}

.reticle-svg {
  width: 100%;
  height: 100%;
  stroke: rgba(0, 210, 255, 0.65);
  stroke-width: 1;
}

/* Floating Viewport HUD Chips */
.viewport-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.hud-chip {
  background: rgba(10, 12, 16, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.hud-chip.highlight {
  color: var(--cyan-accent);
  border-color: rgba(0, 210, 255, 0.3);
}

/* Floating Viewport Tool Buttons */
.viewport-tools {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 20;
}

.v-btn {
  background: rgba(15, 18, 25, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.v-btn:hover {
  background: rgba(25, 30, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}

.v-btn.active {
  background: var(--zwo-red);
  color: #fff;
  border-color: var(--zwo-red);
}

/* Exposure Countdown Banner */
.exposure-banner {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 15, 22, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-accent);
  border-radius: 30px;
  padding: 8px 24px;
  display: none;
  align-items: center;
  gap: 16px;
  z-index: 25;
  box-shadow: 0 8px 32px rgba(255, 59, 48, 0.25);
}

.exposure-banner.active {
  display: flex;
}

.exposure-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 59, 48, 0.2);
  border-top-color: var(--zwo-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.exposure-info {
  display: flex;
  flex-direction: column;
}

.exposure-state-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--zwo-red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.exposure-timer-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* ==============================================================================
   Floating Picture-in-Picture Guider Deck
   ============================================================================== */
.guider-deck {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 320px;
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 30;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.guider-deck.minimized .guider-body {
  display: none;
}

.guider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.guider-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guider-icon {
  width: 14px;
  height: 14px;
  color: var(--cyan-accent);
}

.guider-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.guider-pill {
  font-size: 9.5px;
  text-transform: uppercase;
  background: rgba(48, 209, 88, 0.15);
  color: var(--green-online);
  border: 1px solid rgba(48, 209, 88, 0.3);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.guider-controls {
  display: flex;
  gap: 6px;
}

.guider-btn-min {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.guider-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guider-camera-view {
  position: relative;
  width: 100%;
  height: 140px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.guider-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guider-cam-hud {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.guider-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.guider-crosshair::before, .guider-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(0, 210, 255, 0.8);
}

.guider-crosshair::before {
  top: 11px;
  left: 0;
  width: 24px;
  height: 1px;
}

.guider-crosshair::after {
  top: 0;
  left: 11px;
  width: 1px;
  height: 24px;
}

.guider-graph-container {
  height: 80px;
  background: #030406;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

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

.guider-rms-footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.rms-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rms-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.rms-val {
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.rms-val.total { color: #fff; }
.rms-val.ra { color: #00d2ff; }
.rms-val.dec { color: #ff3b30; }

/* ==============================================================================
   Spectator Bottom Watermark / Disclaimer
   ============================================================================== */
.spectator-watermark {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(14, 17, 24, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 20;
  pointer-events: none;
}

.watermark-icon {
  font-size: 12px;
}

/* Offline Banner Overlay */
.offline-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 22, 30, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  z-index: 40;
  max-width: 420px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
}

.offline-banner.active {
  display: flex;
}

.offline-icon {
  font-size: 32px;
}

.offline-title {
  font-size: 16px;
  font-weight: 700;
}

.offline-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .top-bar {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .telemetry-strip {
    display: none;
  }
  .target-coords {
    flex-direction: column;
    gap: 2px;
  }
  .guider-deck {
    width: calc(100vw - 32px);
    bottom: 12px;
    left: 16px;
  }
}
