/* Brian's Virtual Office — Dark theme */

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

body {
  background: #0a0a0f;
  overflow: hidden;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  color: #e0e0e0;
}

#world-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ── HUD Overlay ───────────────────────────────────────────────────────── */

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 220px;
  background: rgba(10, 10, 20, 0.85);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
  backdrop-filter: blur(8px);
  z-index: 100;
  font-size: 12px;
}

#hud-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.hud-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #00d4ff;
  flex: 1;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background: #10b981; box-shadow: 0 0 6px #10b981; }
.status-dot.offline { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

.viewer-badge {
  font-size: 10px;
  color: #888;
}

#agent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agent-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.agent-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agent-name {
  font-weight: 600;
  font-size: 11px;
}

.agent-activity {
  font-size: 10px;
  color: #888;
  margin-left: auto;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Chat Toggle Button ────────────────────────────────────────────────── */

#chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(10, 10, 20, 0.9);
  border: 1px solid rgba(0, 212, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  transition: transform 0.2s, border-color 0.2s;
}

#chat-toggle:hover {
  transform: scale(1.1);
  border-color: #00d4ff;
}

.chat-icon {
  font-size: 22px;
}

.unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── Chat Panel ────────────────────────────────────────────────────────── */

#chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 380px;
  height: 400px;
  background: rgba(10, 10, 20, 0.92);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-bottom: none;
  border-right: none;
  border-radius: 12px 0 0 0;
  backdrop-filter: blur(10px);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#chat-panel.chat-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #00d4ff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#chat-close {
  cursor: pointer;
  font-size: 18px;
  color: #888;
  transition: color 0.2s;
}
#chat-close:hover { color: #fff; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Chat message types */

.chat-msg {
  font-size: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg .msg-name {
  font-weight: 700;
  margin-right: 6px;
}

.chat-msg .msg-time {
  font-size: 10px;
  color: #555;
  margin-left: 6px;
}

.chat-msg.msg-status {
  color: #888;
  font-style: italic;
  font-size: 11px;
}

.chat-msg.msg-status::before {
  content: '\u2699 ';
}

.chat-msg.msg-join,
.chat-msg.msg-leave {
  text-align: center;
  font-size: 11px;
  padding: 2px 0;
}
.chat-msg.msg-join  { color: #10b981; }
.chat-msg.msg-leave { color: #ef4444; }

.chat-msg.msg-emote {
  font-style: italic;
  color: #aaa;
}

/* ── Floating Labels (CSS2D) ───────────────────────────────────────────── */

.agent-label {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 11px;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

.agent-label .label-name {
  font-weight: 700;
  display: block;
}

.agent-label .label-activity {
  font-size: 10px;
  color: #aaa;
  display: block;
}

/* ── Speech Bubble ─────────────────────────────────────────────────────── */

.speech-bubble {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 11px;
  max-width: 200px;
  background: rgba(10, 10, 20, 0.9);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px 10px;
  color: #e0e0e0;
  pointer-events: none;
  text-align: center;
  word-wrap: break-word;
}

/* ── Leaderboard Toggle Button ─────────────────────────────────────────── */

#leaderboard-toggle {
  position: fixed;
  bottom: 20px;
  right: 76px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(10, 10, 20, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  transition: transform 0.2s, border-color 0.2s;
}

#leaderboard-toggle:hover {
  transform: scale(1.1);
  border-color: #f59e0b;
}

.lb-icon { font-size: 20px; }

/* ── Leaderboard Panel ────────────────────────────────────────────────── */

#leaderboard-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 340px;
  max-height: 420px;
  background: rgba(10, 10, 20, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-bottom: none;
  border-left: none;
  border-radius: 0 12px 0 0;
  backdrop-filter: blur(10px);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#leaderboard-panel.lb-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #f59e0b;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#lb-close {
  cursor: pointer;
  font-size: 18px;
  color: #888;
  transition: color 0.2s;
}
#lb-close:hover { color: #fff; }

#lb-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

#lb-content::-webkit-scrollbar { width: 4px; }
#lb-content::-webkit-scrollbar-track { background: transparent; }
#lb-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.lb-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  color: #888;
}
.lb-rank.gold   { background: rgba(255, 215, 0, 0.15); color: #ffd700; }
.lb-rank.silver { background: rgba(192, 192, 192, 0.12); color: #c0c0c0; }
.lb-rank.bronze { background: rgba(205, 127, 50, 0.12); color: #cd7f32; }

.lb-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-stats {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: #888;
  flex-shrink: 0;
}

.lb-stat { text-align: right; }
.lb-stat-val { color: #e0e0e0; font-weight: 600; }

.lb-empty {
  text-align: center;
  color: #555;
  font-size: 12px;
  padding: 30px 10px;
}

/* ── Offline Overlay ───────────────────────────────────────────────────── */

#offline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.offline-content {
  text-align: center;
}

.offline-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.offline-content h2 {
  color: #00d4ff;
  font-size: 24px;
  margin-bottom: 8px;
}

.offline-content p {
  color: #888;
  font-size: 14px;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  #hud { width: 180px; font-size: 10px; }
  #chat-panel { width: 100vw; border-radius: 12px 12px 0 0; }
}
