/* ============================================================
   StarNexus — Dark Theme
   ============================================================ */

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: #0a0a1a;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ============================================================
   Status Bar
   ============================================================ */

#status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.status-bar-left .logo {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
}

.status-bar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-counts {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 10px;
}

.status-dot:first-child {
  margin-left: 0;
}

.status-dot.online { background: #00ff88; box-shadow: 0 0 6px #00ff88; }
.status-dot.degraded { background: #ffaa00; box-shadow: 0 0 6px #ffaa00; }
.status-dot.offline { background: #ff4444; }

.status-bar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.btn-refresh {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-refresh:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.btn-refresh.spinning {
  animation: spin 0.6s linear;
}

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

/* ============================================================
   Error Banner
   ============================================================ */

.error-banner {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  z-index: 999;
  padding: 8px 20px;
  background: rgba(255, 68, 68, 0.15);
  border-bottom: 1px solid rgba(255, 68, 68, 0.3);
  color: #ff6666;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.error-banner.hidden {
  display: none;
}

/* ============================================================
   Map
   ============================================================ */

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

/* ============================================================
   Leaflet Dark Theme Overrides
   ============================================================ */

/* Zoom controls */
.leaflet-control-zoom {
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 6px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: rgba(10, 10, 26, 0.9) !important;
  color: rgba(255, 255, 255, 0.6) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(30, 30, 60, 0.9) !important;
  color: #ffffff !important;
}

/* Attribution */
.leaflet-control-attribution {
  background: rgba(10, 10, 26, 0.7) !important;
  color: rgba(255, 255, 255, 0.25) !important;
  font-size: 10px !important;
  font-family: 'JetBrains Mono', monospace !important;
}

.leaflet-control-attribution a {
  color: rgba(255, 255, 255, 0.35) !important;
}

/* Tooltip */
.leaflet-tooltip {
  background: rgba(15, 15, 35, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #e0e0e0 !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 12px !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-tooltip-top:before {
  border-top-color: rgba(15, 15, 35, 0.95) !important;
}
.leaflet-tooltip-bottom:before {
  border-bottom-color: rgba(15, 15, 35, 0.95) !important;
}
.leaflet-tooltip-left:before {
  border-left-color: rgba(15, 15, 35, 0.95) !important;
}
.leaflet-tooltip-right:before {
  border-right-color: rgba(15, 15, 35, 0.95) !important;
}

/* Popup */
.leaflet-popup-content-wrapper {
  background: rgba(12, 12, 30, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 10px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
  color: #e0e0e0 !important;
  font-family: 'JetBrains Mono', monospace !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}

.leaflet-popup-tip {
  background: rgba(12, 12, 30, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
}

.leaflet-popup-close-button {
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 18px !important;
  padding: 6px 8px 0 0 !important;
}

.leaflet-popup-close-button:hover {
  color: #ffffff !important;
}

/* ============================================================
   Node Markers
   ============================================================ */

/* Prevent Leaflet icon wrapper from clipping box-shadow glow */
.leaflet-marker-icon {
  overflow: visible !important;
  background: none !important;
  border: none !important;
}

.node-marker {
  border-radius: 50%;
  border: 2px solid;
  cursor: pointer;
  transition: transform 0.2s;
}

.node-marker:hover {
  transform: scale(1.4);
}

.node-marker.online {
  background: #00ff88;
  border-color: #00ff88;
  box-shadow: 0 0 8px #00ff88, 0 0 20px rgba(0, 255, 136, 0.4);
  animation: breathe-online 2s ease-in-out infinite;
}

.node-marker.degraded {
  background: #ffaa00;
  border-color: #ffaa00;
  box-shadow: 0 0 8px #ffaa00, 0 0 16px rgba(255, 170, 0, 0.3);
  animation: breathe-degraded 3s ease-in-out infinite;
}

.node-marker.offline {
  background: #ff4444;
  border-color: #ff4444;
  opacity: 0.5;
}

.node-marker.unknown {
  background: #666666;
  border-color: #666666;
  opacity: 0.6;
}

@keyframes breathe-online {
  0%, 100% {
    box-shadow: 0 0 8px #00ff88, 0 0 20px rgba(0, 255, 136, 0.4);
  }
  50% {
    box-shadow: 0 0 16px #00ff88, 0 0 40px rgba(0, 255, 136, 0.6), 0 0 60px rgba(0, 255, 136, 0.2);
  }
}

@keyframes breathe-degraded {
  0%, 100% {
    box-shadow: 0 0 6px #ffaa00, 0 0 14px rgba(255, 170, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 12px #ffaa00, 0 0 30px rgba(255, 170, 0, 0.5);
  }
}

/* ============================================================
   Node Detail Popup
   ============================================================ */

.node-popup {
  padding: 16px;
  min-width: 260px;
}

.node-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.node-popup-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.node-popup-provider {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}

.status-badge.online { background: rgba(0, 255, 136, 0.15); color: #00ff88; }
.status-badge.degraded { background: rgba(255, 170, 0, 0.15); color: #ffaa00; }
.status-badge.offline { background: rgba(255, 68, 68, 0.15); color: #ff4444; }
.status-badge.unknown { background: rgba(102, 102, 102, 0.15); color: #666666; }

/* Metric rows */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.metric-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  min-width: 60px;
}

.metric-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  margin: 0 10px;
  overflow: hidden;
}

.metric-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.metric-value {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  min-width: 40px;
  text-align: right;
}

/* Bar colors by usage */
.bar-green { background: #00ff88; }
.bar-yellow { background: #ffaa00; }
.bar-red { background: #ff4444; }

/* Text metric rows */
.metric-text-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
}

.metric-text-row .label {
  color: rgba(255, 255, 255, 0.5);
}

.metric-text-row .value {
  color: rgba(255, 255, 255, 0.8);
}

.node-popup-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 10px 0;
}

/* ============================================================
   Link Tooltip
   ============================================================ */

.link-tooltip {
  font-size: 12px;
  line-height: 1.6;
}

.link-tooltip .label {
  color: rgba(255, 255, 255, 0.5);
}

.link-tooltip .value {
  color: #ffffff;
  font-weight: 500;
}

/* ============================================================
   Terminator (day/night line)
   ============================================================ */

.leaflet-terminator {
  fill: rgba(0, 0, 40, 0.5);
  stroke: none;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  #status-bar {
    flex-direction: column;
    height: auto;
    padding: 8px 12px;
    gap: 6px;
  }

  .status-bar-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .status-counts {
    font-size: 11px;
  }

  .node-popup {
    min-width: 220px;
  }
}
