// Floating anchor — fixed to bottom-right, above everything
.hud-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: var(--font-main);
}

// Toggle pill button — also a drag handle when panel is collapsed
.hud-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 20px;
  color: #f0f0f0;
  font-size: 0.8rem;
  cursor: grab;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;

  &:active { cursor: grabbing; }

  &:hover {
    border-color: #00a651;
    box-shadow: 0 0 10px rgba(0, 166, 81, 0.3);
  }
}

.hud-toggle-icon {
  font-size: 1rem;
}

.hud-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s ease;

  &.connected {
    background: #00a651;
    box-shadow: 0 0 6px rgba(0, 166, 81, 0.8);
    animation: pulse 1.5s infinite;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

// Main panel
.hud-panel {
  width: 280px;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 14px;
  animation: hudSlideIn 0.2s ease-out;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@keyframes hudSlideIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #222;
  cursor: grab;
  user-select: none;

  &:active { cursor: grabbing; }
}

.hud-drag-grip {
  font-size: 0.9rem;
  color: #444;
  margin-right: 6px;
  flex-shrink: 0;
}

.hud-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #888;
}

.hud-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 10px;
  background: #1a1a1a;
  color: #555;
  border: 1px solid #333;

  &.online {
    color: #00a651;
    border-color: #00a651;
    background: rgba(0, 166, 81, 0.1);
  }
}

// ── Header LED status lights ───────────────────────────────────────────────────
.hud-header-leds {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.hud-led-group {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.hud-led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #333;
  transition: background 0.3s ease, box-shadow 0.3s ease;

  &.led-green {
    background: #00a651;
    box-shadow: 0 0 6px rgba(0, 166, 81, 0.8);
    animation: pulse 1.5s infinite;
  }

  &.led-yellow {
    background: #ffc107;
    box-shadow: 0 0 5px rgba(255, 193, 7, 0.7);
  }

  &.led-red {
    background: #dc3545;
    box-shadow: 0 0 5px rgba(220, 53, 69, 0.7);
  }
}

.hud-led-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: #444;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

// Per-service row
.hud-row {
  padding: 8px 0;
  border-bottom: 1px solid #1a1a1a;

  &:last-of-type {
    border-bottom: none;
  }
}

.hud-service-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-metric-block {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.hud-metric-label {
  font-size: 0.6rem;
  color: #555;
  font-weight: 600;
  width: 28px;
  flex-shrink: 0;
}

.hud-bar-track {
  flex: 1;
  height: 5px;
  background: #1a1a1a;
  border-radius: 3px;
  overflow: hidden;
}

.hud-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.4s ease;
}

.hud-metric-value {
  font-size: 0.68rem;
  font-weight: 700;
  color: #ccc;
  width: 38px;
  text-align: right;
  flex-shrink: 0;
}

.hud-ram-value {
  font-size: 0.68rem;
  font-weight: 700;
  color: #ccc;
  flex: 1;
}

.hud-waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  color: #555;
  font-size: 0.72rem;

  &.hud-offline {
    color: #dc3545;
  }
}

.hud-offline-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.hud-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #333;
  border-top-color: #00a651;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

// Service status block (NestJS / n8n indicators)
.hud-service-status {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-svc-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-svc-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: #555;
  width: 38px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.hud-svc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;

  &.dot-green  { background: #00a651; box-shadow: 0 0 5px rgba(0,166,81,0.7); }
  &.dot-yellow { background: #ffc107; box-shadow: 0 0 5px rgba(255,193,7,0.6); }
  &.dot-red    { background: #dc3545; box-shadow: 0 0 5px rgba(220,53,69,0.6); }
}

.hud-svc-state {
  font-size: 0.6rem;
  color: #555;

  &.state-online  { color: #00a651; }
  &.state-warn    { color: #ffc107; }
  &.state-offline { color: #dc3545; }
}

.hud-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1a1a1a;
  font-size: 0.58rem;
  color: #333;
  letter-spacing: 0.05em;
}
