/* =====================================================
   ESRI WORLDVIEW — Military Intelligence HUD Styles
   ===================================================== */

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

:root {
  --hud-green: #00ff41;
  --hud-green-dim: #00ff4180;
  --hud-green-bg: #00ff4115;
  --hud-amber: #ffb000;
  --hud-red: #ff3333;
  --hud-cyan: #00e5ff;
  --hud-orange: #ff6600;
  --hud-magenta: #ff44cc;
  --hud-white: #e0e0e0;
  --hud-bg: rgba(0, 0, 0, 0.75);
  --hud-border: rgba(0, 255, 65, 0.3);
  --hud-font: 'Share Tech Mono', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--hud-font);
}

/* =====================================================
   INTRO MODAL
   ===================================================== */

#intro-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  background: radial-gradient(ellipse at center, #0a1a0a 0%, #000 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease-out;
}

#intro-modal.closing {
  animation: fadeOut 0.6s ease-in forwards;
}

#intro-content {
  max-width: 720px;
  width: 90%;
  color: var(--hud-green);
  font-family: var(--hud-font);
  padding: 30px;
  border: 1px solid var(--hud-border);
  background: rgba(0, 10, 0, 0.85);
  position: relative;
  backdrop-filter: blur(10px);
}

#intro-content::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 20px; height: 20px;
  border-top: 2px solid var(--hud-green);
  border-left: 2px solid var(--hud-green);
}

#intro-content::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 20px; height: 20px;
  border-bottom: 2px solid var(--hud-green);
  border-right: 2px solid var(--hud-green);
}

#intro-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hud-border);
}

#intro-logo {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 4px;
  text-shadow: 0 0 20px var(--hud-green-dim), 0 0 40px rgba(0, 255, 65, 0.15);
}

#intro-tagline {
  font-size: 11px;
  color: var(--hud-green-dim);
  letter-spacing: 3px;
  margin-top: 6px;
}

.intro-section {
  margin-bottom: 16px;
}

.intro-section-title {
  color: var(--hud-amber);
  font-size: 10px;
  letter-spacing: 1px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 176, 0, 0.2);
  padding-bottom: 3px;
}

.intro-section p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--hud-white);
}

.intro-section ul {
  list-style: none;
  font-size: 11px;
  line-height: 1.8;
  color: var(--hud-white);
}

.intro-section li strong {
  color: var(--hud-green);
}

.intro-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot-green { background: var(--hud-green); }
.dot-amber { background: var(--hud-amber); }
.dot-red { background: var(--hud-red); }
.dot-orange { background: var(--hud-orange); }
.dot-cyan { background: var(--hud-cyan); }
.dot-magenta { background: var(--hud-magenta); }

.intro-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
  color: var(--hud-white);
}

.intro-mode { display: flex; align-items: center; gap: 8px; }

.mode-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 9px;
  letter-spacing: 1px;
  border: 1px solid;
}

.mode-std { color: var(--hud-white); border-color: var(--hud-white); }
.mode-nvg { color: var(--hud-green); border-color: var(--hud-green); }
.mode-thm { color: var(--hud-orange); border-color: var(--hud-orange); }
.mode-crt2 { color: #33ff77; border-color: #33ff77; }

#intro-launch {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: transparent;
  border: 2px solid var(--hud-green);
  color: var(--hud-green);
  font-family: var(--hud-font);
  font-size: 14px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

#intro-launch:hover {
  background: var(--hud-green);
  color: #000;
  text-shadow: none;
}

#intro-footer {
  text-align: center;
  font-size: 9px;
  color: var(--hud-green-dim);
  margin-top: 12px;
  letter-spacing: 0.5px;
}

/* =====================================================
   MAIN VIEW
   ===================================================== */

#viewDiv {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

.esri-ui-corner .esri-component,
.esri-attribution { display: none !important; }

/* =====================================================
   HUD OVERLAY
   ===================================================== */

#hud-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10;
  pointer-events: none;
  font-family: var(--hud-font);
  color: var(--hud-green);
  font-size: 12px;
  letter-spacing: 0.5px;
}

#hud-overlay > * { pointer-events: auto; }
#crosshair { pointer-events: none; }

/* Top Bar */
#hud-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
  pointer-events: none;
  z-index: 100;
}

#hud-top-bar > * {
  pointer-events: auto;
}

#hud-title {
  font-size: 16px;
  font-weight: bold;
  text-shadow: 0 0 10px var(--hud-green-dim);
}

.hud-subtitle {
  font-size: 11px;
  color: var(--hud-green-dim);
  font-weight: normal;
}

#hud-clock {
  font-size: 14px;
  text-shadow: 0 0 10px var(--hud-green-dim);
}

/* Search Bar */
#search-container {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 9999;
}

#search-input {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--hud-border);
  color: var(--hud-green);
  font-family: var(--hud-font);
  font-size: 12px;
  padding: 5px 10px;
  width: 240px;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.2s, width 0.3s;
}

#search-input::placeholder {
  color: var(--hud-green-dim);
  font-size: 11px;
}

#search-input:focus {
  border-color: var(--hud-green);
  width: 320px;
}

#btn-return-globe {
  white-space: nowrap;
  background: rgba(255, 176, 0, 0.15);
  border-color: var(--hud-amber);
  color: var(--hud-amber);
  font-size: 10px;
  padding: 5px 10px;
}

#btn-return-globe:hover {
  background: var(--hud-amber);
  color: #000;
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(0, 5, 0, 0.95);
  border: 1px solid var(--hud-border);
  border-top: none;
  z-index: 9999;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.search-result-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 255, 65, 0.08);
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item:hover {
  background: var(--hud-green-bg);
}

.search-result-name {
  color: var(--hud-green);
  font-size: 11px;
}

.search-result-type {
  color: var(--hud-green-dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Crosshair */
#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 60px; height: 60px;
}

.crosshair-line { position: absolute; background: var(--hud-green-dim); }
.crosshair-top { top: 0; left: 50%; transform: translateX(-50%); width: 1px; height: 18px; }
.crosshair-bottom { bottom: 0; left: 50%; transform: translateX(-50%); width: 1px; height: 18px; }
.crosshair-left { top: 50%; left: 0; transform: translateY(-50%); width: 18px; height: 1px; }
.crosshair-right { top: 50%; right: 0; transform: translateY(-50%); width: 18px; height: 1px; }

.crosshair-circle {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 20px; height: 20px;
  border: 1px solid var(--hud-green-dim);
  border-radius: 50%;
}

/* Info Panel */
#hud-info-panel {
  position: absolute;
  bottom: 20px; left: 20px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  padding: 12px 16px;
  min-width: 200px;
  backdrop-filter: blur(4px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.hud-section { margin-bottom: 10px; }
.hud-section:last-child { margin-bottom: 0; }

.hud-label {
  color: var(--hud-amber);
  font-size: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hud-border);
  padding-bottom: 2px;
}

/* Controls */
#hud-controls {
  position: absolute;
  bottom: 20px; right: 20px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  padding: 12px 16px;
  min-width: 220px;
  backdrop-filter: blur(4px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* Buttons */
.hud-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.hud-btn {
  background: transparent;
  border: 1px solid var(--hud-border);
  color: var(--hud-green);
  font-family: var(--hud-font);
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.hud-btn:hover {
  background: var(--hud-green-bg);
  border-color: var(--hud-green);
}

.hud-btn.active {
  background: var(--hud-green);
  color: #000;
  border-color: var(--hud-green);
}

/* Toggles */
.hud-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.hud-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
}

.hud-toggle input[type="checkbox"] {
  appearance: none;
  width: 12px; height: 12px;
  border: 1px solid var(--hud-green-dim);
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.hud-toggle input[type="checkbox"]:checked {
  background: var(--hud-green);
  border-color: var(--hud-green);
}

.hud-toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 3px;
  width: 4px; height: 7px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Toggle color indicators */
.toggle-green { color: var(--hud-green); }
.toggle-amber { color: var(--hud-amber); }
.toggle-red { color: var(--hud-red); }
.toggle-orange { color: var(--hud-orange); }
.toggle-cyan { color: var(--hud-cyan); }
.toggle-magenta { color: var(--hud-magenta); }
.toggle-blue { color: #4fc3f7; }

/* Feature Detail Popup */
#feature-detail {
  position: absolute;
  top: 60px; right: 20px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-amber);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 320px;
  backdrop-filter: blur(4px);
  z-index: 20;
}

#feature-detail .hud-label { color: var(--hud-red); }

#feature-detail-body {
  font-size: 11px;
  line-height: 1.6;
  margin: 6px 0;
  word-break: break-word;
}

#feature-detail-body .detail-name {
  font-size: 13px;
  color: var(--hud-cyan);
  margin-bottom: 4px;
}

#feature-detail-body .detail-row {
  color: var(--hud-white);
}

#feature-detail-body .detail-row strong {
  color: var(--hud-green);
}

#feature-detail-close {
  margin-top: 8px;
  width: 100%;
}

/* CCTV Camera Feed Popup */
#cctv-popup {
  position: absolute;
  top: 60px;
  left: 12px;
  transform: none;
  background: rgba(0, 0, 0, 0.94);
  border: 1px solid var(--hud-green);
  z-index: 50;
  width: 380px;
  max-width: 40vw;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 40px rgba(0, 255, 100, 0.15), inset 0 0 20px rgba(0, 255, 100, 0.03);
  pointer-events: auto;
}

#cctv-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 255, 100, 0.3);
}

#cctv-popup-header .hud-label {
  color: var(--hud-green);
  margin: 0;
}

#cctv-popup-close {
  background: rgba(0, 255, 100, 0.1);
  border-color: var(--hud-green);
  color: var(--hud-green);
  font-size: 12px;
  padding: 3px 8px;
  min-width: auto;
}

#cctv-popup-close:hover {
  background: var(--hud-green);
  color: #000;
}

#cctv-popup-feed {
  width: 100%;
  height: 280px;
  background: #000;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cctv-popup-feed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

#cctv-popup-feed img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#cctv-popup-feed .feed-status {
  color: var(--hud-red);
  font-size: 11px;
  text-align: center;
  padding: 20px;
  line-height: 1.8;
}

#cctv-popup-feed .feed-status .feed-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.feed-rec {
  position: absolute;
  top: 8px;
  left: 10px;
  color: var(--hud-red);
  font-size: 10px;
  font-family: var(--hud-font);
  animation: blink 1s infinite;
}

.feed-timestamp {
  position: absolute;
  bottom: 8px;
  right: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 9px;
  font-family: var(--hud-font);
}

.feed-cam-id {
  position: absolute;
  top: 8px;
  right: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 9px;
  font-family: var(--hud-font);
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#cctv-popup-info {
  padding: 10px 14px;
  font-size: 10px;
  border-top: 1px solid rgba(0, 255, 100, 0.15);
}

#cctv-popup-info .detail-row {
  color: var(--hud-white);
  line-height: 1.8;
}

#cctv-popup-info .detail-row strong {
  color: var(--hud-green);
}

/* Loading overlay */
#loading-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.5s;
}

#loading-overlay.done { opacity: 0; }

#loading-bar-container {
  width: 300px;
  height: 3px;
  background: rgba(0, 255, 65, 0.15);
  margin-bottom: 8px;
}

#loading-bar {
  width: 0%;
  height: 100%;
  background: var(--hud-green);
  transition: width 0.3s;
}

#loading-text {
  font-size: 11px;
  color: var(--hud-green-dim);
  letter-spacing: 2px;
}

.hidden { display: none !important; }

/* =====================================================
   RENDER MODES
   ===================================================== */

body.mode-nvg #viewDiv {
  filter: saturate(0) brightness(1.2) contrast(1.1);
}

body.mode-nvg #viewDiv::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 255, 65, 0.08);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 2;
}

body.mode-thermal #viewDiv {
  filter: saturate(0) invert(1) contrast(1.3) brightness(0.9);
}

body.mode-thermal {
  --hud-green: #ff6600;
  --hud-green-dim: #ff660080;
  --hud-green-bg: #ff660015;
  --hud-border: rgba(255, 102, 0, 0.3);
  --hud-amber: #ff3333;
  --hud-cyan: #ffcc00;
}

body.mode-crt #viewDiv {
  filter: contrast(1.15) brightness(0.95) saturate(0.8);
}

body.mode-crt #scanlines {
  display: block !important;
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0, 0, 0, 0.15) 2px, rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 5;
}

body.mode-crt { --hud-green: #33ff77; }

/* =====================================================
   ANIMATIONS
   ===================================================== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* Corner decorations */
#hud-info-panel::before, #hud-controls::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 12px; height: 12px;
  border-top: 2px solid var(--hud-green);
  border-left: 2px solid var(--hud-green);
}

#hud-info-panel::after, #hud-controls::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-bottom: 2px solid var(--hud-green);
  border-right: 2px solid var(--hud-green);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {
  .intro-columns { grid-template-columns: 1fr; }
  .intro-modes { grid-template-columns: 1fr; }

  #intro-content { padding: 20px; }
  #intro-logo { font-size: 20px; }

  #hud-info-panel {
    bottom: auto; top: 55px; left: 10px;
    min-width: 160px; font-size: 10px;
  }

  #hud-controls {
    bottom: 10px; right: 10px;
    min-width: 180px; font-size: 10px;
  }

  #hud-title { font-size: 12px; }
  .hud-subtitle { display: none; }

  #search-input { width: 150px; font-size: 10px; }
  #search-input:focus { width: 200px; }
  #search-results { width: 200px; }

  #feature-detail {
    top: auto; bottom: 10px;
    left: 10px; right: 10px;
    max-width: none;
  }
}
