/* ============================================================
   TACTICAL OPERATIONS ROOM - COLD WAR NAVAL COMMAND CENTER
   Phosphor-glow aesthetic: green #00ff88, cyan #00e5ff, amber #ffb300
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');

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

:root {
  --green:  #00ff88;
  --cyan:   #00e5ff;
  --amber:  #ffb300;
  --red:    #ff2244;
  --dim-green: #00aa55;
  --dim-cyan:  #0099bb;
  --bg-dark:   #050a07;
  --bg-panel:  #060d0a;
  --bg-panel2: #080f0b;
  --panel-border: #1a3a28;
  --panel-border-bright: #00ff8844;
  --text-primary: #00ff88;
  --text-secondary: #00e5ff;
  --text-dim: #337755;
  --steel: #1a2820;
  --steel-bright: #243830;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  --font-display: 'Orbitron', 'Share Tech Mono', monospace;
  --scanline-opacity: 0.03;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,var(--scanline-opacity)) 2px,
    rgba(0,0,0,var(--scanline-opacity)) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ---- TOP BAR ---- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  background: linear-gradient(180deg, #0a1a10 0%, #050e08 100%);
  border-bottom: 2px solid var(--green);
  padding: 0 16px;
  box-shadow: 0 0 20px rgba(0,255,136,0.15), inset 0 -1px 0 rgba(0,255,136,0.3);
  position: relative;
  z-index: 100;
}

.topbar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 130px;
}

.topbar-label {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--dim-green);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.topbar-value {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 8px var(--green);
  letter-spacing: 1px;
}

#title-block {
  flex: 1;
  align-items: center;
}

#main-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan), 0 0 24px rgba(0,229,255,0.4);
  letter-spacing: 3px;
}

#sub-title {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--dim-cyan);
  letter-spacing: 4px;
}

.status-online  { color: var(--green) !important; text-shadow: 0 0 10px var(--green) !important; }
.status-offline { color: var(--red)   !important; text-shadow: 0 0 10px var(--red)   !important; }
.status-degraded{ color: var(--amber) !important; text-shadow: 0 0 10px var(--amber) !important; }

.alert-normal    { color: var(--green) !important; }
.alert-intercept { color: var(--amber) !important; text-shadow: 0 0 10px var(--amber) !important; }
.alert-lost      { color: var(--red)   !important; text-shadow: 0 0 14px var(--red)   !important; }

@keyframes alert-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
.alert-intercept { animation: alert-blink 1.2s infinite; }
.alert-lost      { animation: alert-blink 0.5s infinite; }

/* ---- MAIN LAYOUT ---- */
#main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}

/* ---- PANELS COMMON ---- */
.panel-header {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan);
  padding: 6px 10px;
  background: linear-gradient(90deg, rgba(0,229,255,0.08) 0%, transparent 100%);
  border-bottom: 1px solid var(--panel-border);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---- LEFT PANEL ---- */
#left-panel {
  width: 240px;
  min-width: 240px;
  background: var(--bg-panel);
  border-right: 2px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#left-panel::-webkit-scrollbar { width: 4px; }
#left-panel::-webkit-scrollbar-track { background: var(--bg-dark); }
#left-panel::-webkit-scrollbar-thumb { background: var(--dim-green); border-radius: 2px; }

.gauge-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 6px 4px;
}

.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.gauge-container.wide {
  width: 100%;
  padding: 0 8px;
}

.gauge-label {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--dim-green);
  letter-spacing: 1.5px;
  text-align: center;
}

.gauge-readout {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 6px var(--green);
  text-align: center;
  min-width: 60px;
}

canvas.gauge {
  display: block;
}

/* ---- TELEMETRY GRID ---- */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  padding: 6px;
  border-top: 1px solid var(--panel-border);
  margin-top: 4px;
}

.telem-block {
  background: var(--steel);
  border: 1px solid var(--panel-border);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.telem-block.full-width {
  grid-column: 1 / -1;
}

.telem-label {
  font-size: 8px;
  color: var(--dim-green);
  letter-spacing: 1px;
  font-family: var(--font-display);
}

.telem-value {
  font-size: 11px;
  color: var(--green);
  text-shadow: 0 0 4px rgba(0,255,136,0.5);
  font-family: var(--font-mono);
}

.telem-value.corrupt {
  color: var(--red);
  text-shadow: 0 0 4px var(--red);
  animation: static-flicker 0.1s infinite;
}

@keyframes static-flicker {
  0%   { opacity: 1; }
  25%  { opacity: 0.7; }
  50%  { opacity: 1; }
  75%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* ---- CENTER PANEL ---- */
#center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #030805;
  border-right: 2px solid var(--panel-border);
  min-width: 0;
}

#canvas-scale-label {
  font-size: 9px;
  color: var(--dim-green);
  letter-spacing: 1px;
}

#canvas-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #020603;
}

#tactical-canvas,
#radar-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#tactical-canvas {
  z-index: 1;
}

#radar-canvas {
  z-index: 2;
  pointer-events: none;
}

/* ---- RIGHT PANEL ---- */
#right-panel {
  width: 260px;
  min-width: 260px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#right-panel::-webkit-scrollbar { width: 4px; }
#right-panel::-webkit-scrollbar-track { background: var(--bg-dark); }
#right-panel::-webkit-scrollbar-thumb { background: var(--dim-cyan); border-radius: 2px; }

.target-section,
.intercept-section,
.colreg-section,
.autopilot-section,
.command-section {
  padding: 6px 8px;
  border-bottom: 1px solid var(--panel-border);
}

.section-label {
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 4px rgba(0,229,255,0.5);
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(0,229,255,0.15);
}

.target-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.target-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px;
  background: var(--steel);
  border: 1px solid rgba(0,255,136,0.05);
}

.t-label {
  font-size: 9px;
  color: var(--dim-green);
  letter-spacing: 1px;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.t-value {
  font-size: 11px;
  color: var(--green);
  font-family: var(--font-mono);
  text-align: right;
}

.cpa-value  { color: var(--amber); text-shadow: 0 0 6px var(--amber); }
.colreg-value { color: var(--cyan); }
.autopilot-mode { color: var(--green); font-size: 10px; font-weight: bold; }

/* ---- INTERCEPT BUTTON ---- */
.command-section {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intercept-button {
  width: 100%;
  padding: 12px 8px;
  background: linear-gradient(180deg, #3a0008 0%, #200005 100%);
  border: 2px solid var(--red);
  color: var(--red);
  font-family: var(--font-display);
  font-weight: 900;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
  text-shadow: 0 0 8px var(--red);
  box-shadow: 0 0 12px rgba(255,34,68,0.3), inset 0 0 12px rgba(255,34,68,0.05);
}

.intercept-button .btn-line1 {
  font-size: 14px;
  letter-spacing: 2px;
}

.intercept-button .btn-line2 {
  font-size: 8px;
  letter-spacing: 1px;
  color: rgba(255,34,68,0.7);
}

.intercept-button:hover {
  background: linear-gradient(180deg, #5a0010 0%, #380008 100%);
  box-shadow: 0 0 24px rgba(255,34,68,0.6), inset 0 0 16px rgba(255,34,68,0.15);
}

.intercept-button:active {
  transform: scale(0.98);
}

.intercept-button.active {
  background: linear-gradient(180deg, #600015 0%, #3a000c 100%);
  border-color: #ff4466;
  animation: intercept-pulse 0.8s infinite;
}

@keyframes intercept-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255,34,68,0.4), inset 0 0 12px rgba(255,34,68,0.1); }
  50%       { box-shadow: 0 0 30px rgba(255,34,68,0.9), inset 0 0 20px rgba(255,34,68,0.3); }
}

.reset-button {
  width: 100%;
  padding: 7px 8px;
  background: linear-gradient(180deg, #0a1a12 0%, #060e09 100%);
  border: 1px solid var(--dim-green);
  color: var(--dim-green);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-button:hover {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 8px rgba(0,255,136,0.3);
}

/* ---- BOTTOM CONSOLES ---- */
#bottom-consoles {
  display: flex;
  height: 150px;
  min-height: 150px;
  background: var(--bg-dark);
  border-top: 2px solid var(--panel-border);
  gap: 0;
}

.console-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--panel-border);
  overflow: hidden;
}

.console-panel:last-child {
  border-right: none;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: linear-gradient(90deg, rgba(0,229,255,0.06) 0%, transparent 100%);
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.console-title {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 4px rgba(0,229,255,0.4);
}

.console-indicator {
  font-size: 9px;
  color: var(--green);
  text-shadow: 0 0 6px var(--green);
}

.console-indicator.offline {
  color: var(--red);
  animation: alert-blink 0.8s infinite;
}

.console-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim-green);
  background: #030905;
  line-height: 1.5;
}

.console-body::-webkit-scrollbar { width: 3px; }
.console-body::-webkit-scrollbar-track { background: var(--bg-dark); }
.console-body::-webkit-scrollbar-thumb { background: var(--dim-green); }

.console-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0;
  transition: color 0.1s;
}

.console-line.new-line {
  color: var(--green);
  text-shadow: 0 0 4px rgba(0,255,136,0.5);
  animation: fade-to-dim 2s forwards;
}

.console-line.warn {
  color: var(--amber);
  text-shadow: 0 0 4px var(--amber);
}

.console-line.error {
  color: var(--red);
  text-shadow: 0 0 6px var(--red);
  animation: alert-blink 0.3s 3;
}

.console-line.corrupt {
  color: var(--red);
  opacity: 0.7;
  letter-spacing: 0;
}

@keyframes fade-to-dim {
  0%   { color: var(--green); text-shadow: 0 0 4px rgba(0,255,136,0.5); }
  100% { color: var(--dim-green); text-shadow: none; }
}

/* ---- CONTACT LOST OVERLAY ---- */
#contact-lost-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#contact-lost-overlay.visible {
  display: flex;
}

#contact-lost-content {
  text-align: center;
  border: 2px solid var(--red);
  padding: 40px 60px;
  background: rgba(20, 0, 4, 0.95);
  box-shadow: 0 0 60px rgba(255,34,68,0.5), inset 0 0 40px rgba(255,34,68,0.08);
  position: relative;
}

#cl-title {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  color: var(--red);
  text-shadow: 0 0 20px var(--red), 0 0 40px rgba(255,34,68,0.6);
  letter-spacing: 8px;
  animation: alert-blink 0.8s infinite;
}

#cl-subtitle {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 12px var(--amber);
  letter-spacing: 6px;
  margin-top: 8px;
}

#cl-line {
  font-family: var(--font-display);
  font-size: 14px;
  color: rgba(255,34,68,0.7);
  letter-spacing: 4px;
  margin-top: 12px;
  animation: alert-blink 1.5s infinite;
}

#cl-details {
  margin-top: 24px;
  border-top: 1px solid rgba(255,34,68,0.3);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cl-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  font-size: 12px;
  color: var(--dim-green);
}

.cl-detail-row span:first-child {
  color: var(--dim-green);
  font-family: var(--font-display);
  letter-spacing: 1px;
}

.cl-detail-row span:last-child {
  color: var(--green);
}

.cl-red {
  color: var(--red) !important;
  text-shadow: 0 0 6px var(--red);
}

#cl-static {
  font-family: var(--font-display);
  font-size: 11px;
  color: rgba(255,34,68,0.5);
  letter-spacing: 6px;
  margin-top: 16px;
  animation: static-flicker 0.05s infinite;
}

/* ---- MISC UTILITIES ---- */
.corrupt-value {
  color: var(--red) !important;
  animation: static-flicker 0.15s infinite;
}

/* ---- RESPONSIVE SCALING ---- */
@media (max-height: 700px) {
  #topbar { height: 44px; min-height: 44px; }
  #bottom-consoles { height: 120px; min-height: 120px; }
  .gauge-row { padding: 4px 6px 2px; }
}

/* ---- PANEL CORNER DECORATIONS ---- */
#left-panel::before,
#right-panel::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--green) 0%, transparent 100%);
  opacity: 0.4;
}

/* Vignette on tactical canvas */
#center-panel::after {
  content: '';
  position: absolute;
  top: 28px; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 3;
}

/* Scrollbar for right panel */
#right-panel::-webkit-scrollbar { width: 4px; }
#right-panel::-webkit-scrollbar-track { background: #030905; }
#right-panel::-webkit-scrollbar-thumb { background: #1a4030; border-radius: 2px; }
