/**
 * Multiplayer Shared Cursors & Chat Styles
 * Shared cursor overlay, control badges, chat sidebar, voice controls
 */

/* ==========================================================================
   Cursor Overlay
   ========================================================================== */

#vm-multiplayer-cursor-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  touch-action: none;
}

/* ==========================================================================
   Control Badge
   ========================================================================== */

#vm-control-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: rgba(10, 14, 28, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e8eaf2;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

#vm-control-badge.visible {
  opacity: 1;
}

#vm-control-badge button {
  pointer-events: auto;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: transparent;
  color: #e8eaf2;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#vm-control-badge button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Pass control dropdown menu */
#vm-pass-control-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  z-index: 1002;
  background: rgba(10, 14, 28, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: vm-menu-in 0.15s ease;
}

@keyframes vm-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

#vm-pass-control-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #e8eaf2;
  font: 13px Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  text-align: left;
  cursor: pointer;
}

#vm-pass-control-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Control request popup */
#vm-control-request-popup {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 10000;
  background: rgba(10, 14, 28, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  min-width: 280px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: vm-popup-in 0.2s ease;
}

@keyframes vm-popup-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

#vm-control-request-popup button {
  padding: 8px 16px;
  border-radius: 8px;
  font: 500 13px Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#vm-control-request-popup #vm-approve-btn {
  border: none;
  background: #3b6fe0;
  color: #fff;
}

#vm-control-request-popup #vm-approve-btn:hover {
  background: #4a7cec;
}

#vm-control-request-popup #vm-deny-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #e8eaf2;
}

#vm-control-request-popup #vm-deny-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   Spectator Overlay
   ========================================================================== */

.vm-spectator-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 999;
}

/* ==========================================================================
   Chat Sidebar
   ========================================================================== */

.vm-chat-sidebar {
  position: fixed;
  top: 0;
  right: -380px;
  width: 380px;
  max-width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 28, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.vm-chat-sidebar.open {
  right: 0;
}

.vm-chat-sidebar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

/* Chat Header */
.vm-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.vm-chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #e8eaf2;
}

.vm-chat-title .participant-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.vm-chat-close {
  background: none;
  border: none;
  color: #9aa3bf;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vm-chat-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e8eaf2;
}

/* Voice Bar */
.vm-chat-voice-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.vm-voice-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #e8eaf2;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vm-voice-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.vm-voice-btn.active {
  background: #3b6fe0;
  border-color: #3b6fe0;
}

.vm-voice-btn.muted {
  background: #d94a4a;
  border-color: #d94a4a;
}

.vm-voice-btn.deafened {
  opacity: 0.6;
}

.vm-voice-status {
  flex: 1;
  font-size: 12px;
  color: #9aa3bf;
}

/* Chat Messages */
.vm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vm-chat-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: vm-fade-in 0.2s ease;
}

@keyframes vm-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.vm-chat-message.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.vm-chat-message.system {
  align-self: center;
  max-width: 100%;
  color: #9aa3bf;
  font-size: 12px;
  text-align: center;
}

.vm-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #000;
}

.vm-chat-avatar.speaking {
  box-shadow: 0 0 0 2px #3b6fe0, 0 0 12px #3b6fe0;
  animation: vm-pulse 1s infinite;
}

@keyframes vm-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #3b6fe0; }
  50% { box-shadow: 0 0 0 4px #3b6fe0, 0 0 16px #3b6fe0; }
}

.vm-chat-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 40px;
}

.vm-chat-message.own .vm-chat-bubble {
  background: rgba(59, 111, 224, 0.3);
  border-color: rgba(59, 111, 224, 0.5);
}

.vm-chat-bubble-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.vm-chat-sender {
  font-weight: 600;
  color: #e8eaf2;
}

.vm-chat-message.own .vm-chat-sender {
  color: #a5c0ff;
}

.vm-chat-time {
  color: #6a7496;
}

.vm-chat-text {
  color: #e8eaf2;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.vm-chat-message.system .vm-chat-text {
  color: #9aa3bf;
  font-style: italic;
}

/* Chat Input */
.vm-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.vm-chat-input-wrapper {
  display: flex;
  gap: 8px;
}

.vm-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 10px 16px;
  color: #e8eaf2;
  font: 13px Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vm-chat-input:focus {
  border-color: #3b6fe0;
  box-shadow: 0 0 0 3px rgba(59, 111, 224, 0.2);
}

.vm-chat-input::placeholder {
  color: #6a7496;
}

.vm-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #3b6fe0;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.vm-chat-send:hover {
  background: #4a7cec;
}

.vm-chat-send:active {
  transform: scale(0.95);
}

/* Chat Toggle Button */
.vm-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1999;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3b6fe0, #6366f1);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(59, 111, 224, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.vm-chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(59, 111, 224, 0.5);
}

.vm-chat-toggle .notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d94a4a;
  border: 2px solid #0b0e18;
  display: none;
}

.vm-chat-toggle.has-unread .notification-dot {
  display: block;
  animation: vm-ping 1.5s infinite;
}

@keyframes vm-ping {
  0% { box-shadow: 0 0 0 0 rgba(217, 74, 74, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(217, 74, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 74, 74, 0); }
}

/* Participants Dropdown */
.vm-participants-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: rgba(10, 14, 28, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 8px;
  min-width: 200px;
  z-index: 2001;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.vm-participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #e8eaf2;
  font-size: 13px;
}

.vm-participant-item .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #000;
}

.vm-participant-item .status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.vm-participant-item .badges {
  display: flex;
  gap: 4px;
}

.vm-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.vm-badge.host {
  background: #3b6fe0;
  color: #fff;
}

.vm-badge.controller {
  background: #7ee2a8;
  color: #000;
}

.vm-badge.muted {
  background: #d94a4a;
  color: #fff;
}

.vm-badge.deafened {
  background: #9aa3bf;
  color: #000;
}

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

@media (max-width: 640px) {
  .vm-chat-sidebar {
    width: 100vw;
    right: -100vw;
  }

  .vm-chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  #vm-control-badge {
    top: 8px;
    left: 8px;
    right: 8px;
    left: auto;
    justify-content: center;
  }

  #vm-control-request-popup {
    left: 16px;
    right: 16px;
    bottom: 80px;
    min-width: auto;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .vm-chat-sidebar,
  .vm-chat-message,
  #vm-pass-control-menu,
  #vm-control-request-popup,
  .vm-chat-toggle,
  .vm-chat-toggle .notification-dot {
    animation: none !important;
    transition: none !important;
  }
}