/* ═══════════════════════════════════════════════════════════
   VOICE PiP — Floating mini-player (Picture-in-Picture)
   Persists across SPA navigation when user is in voice call
   LiveKit SFU — up to 12 participants per room
   ═══════════════════════════════════════════════════════════ */

/* ─── Container ─── */
.voice-pip {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: none;
  flex-direction: column;
  border-radius: 20px;
  background: rgba(15, 12, 41, 0.92);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.45),
    0 0 0 1px rgba(124, 58, 237, 0.1);
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', system-ui, sans-serif;
  min-width: 220px;
  max-width: 320px;
  animation: pipSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.voice-pip.visible {
  display: flex;
}

@keyframes pipSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.voice-pip.pip-exiting {
  animation: pipSlideOut 0.3s ease forwards;
}

@keyframes pipSlideOut {
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
}

/* ─── Header bar (always visible) ─── */
.voice-pip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.2s;
}

.voice-pip-header:hover {
  background: rgba(255,255,255,0.04);
}

.voice-pip-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: pipPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pipPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 4px rgba(34, 197, 94, 0.3); }
}

.voice-pip-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-pip-count {
  font-size: 0.72rem;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 12px;
  flex-shrink: 0;
}

.voice-pip-expand-icon {
  font-size: 0.7rem;
  color: #64748b;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.voice-pip.expanded .voice-pip-expand-icon {
  transform: rotate(180deg);
}

/* ─── Expanded body (avatars) ─── */
.voice-pip-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.35s ease;
  padding: 0 14px;
}

.voice-pip.expanded .voice-pip-body {
  max-height: 200px;
  padding: 6px 14px 8px;
}

.voice-pip-participants {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voice-pip-participant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}

.voice-pip-avatar-wrap {
  position: relative;
  width: 38px;
  height: 38px;
}

.voice-pip-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #1e293b;
  border: 2px solid transparent;
  transition: border-color 0.3s;
}

.voice-pip-participant.speaking .voice-pip-avatar {
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.voice-pip-participant.muted .voice-pip-mute-dot {
  display: block;
}

.voice-pip-mute-dot {
  display: none;
  position: absolute;
  bottom: 0;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid rgba(15, 12, 41, 0.92);
  font-size: 7px;
  color: #fff;
  line-height: 10px;
  text-align: center;
}

.voice-pip-name {
  font-size: 0.62rem;
  color: #94a3b8;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ─── Action bar ─── */
.voice-pip-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.voice-pip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  font-family: inherit;
}

.voice-pip-btn-mute {
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
}
.voice-pip-btn-mute:hover {
  background: rgba(255,255,255,0.14);
}
.voice-pip-btn-mute.is-muted {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.voice-pip-btn-leave {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.voice-pip-btn-leave:hover {
  background: rgba(239, 68, 68, 0.3);
}

.voice-pip-btn-open {
  background: rgba(124, 58, 237, 0.15);
  color: #a78bfa;
}
.voice-pip-btn-open:hover {
  background: rgba(124, 58, 237, 0.25);
}

/* ─── Mobile Responsive ─── */
@media (max-width: 600px) {
  .voice-pip {
    bottom: 80px; /* Above mobile bottom nav */
    right: 12px;
    min-width: 180px;
    max-width: 260px;
    border-radius: 16px;
  }

  .voice-pip-header {
    padding: 8px 12px;
  }

  .voice-pip-body {
    padding: 0 12px;
  }

  .voice-pip.expanded .voice-pip-body {
    padding: 4px 12px 6px;
  }

  .voice-pip-actions {
    padding: 6px 12px 10px;
  }

  .voice-pip-btn {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }

  .voice-pip-avatar-wrap {
    width: 32px;
    height: 32px;
  }

  .voice-pip-avatar {
    width: 32px;
    height: 32px;
  }
}
