/* Widget de amigos (botón arriba a la derecha + panel + chat privado).
   El botón se mete DENTRO de .topbar-actions (clase .in-bar), o sea que va en
   la fila de "Donar"/"Salir" y por eso no puede taparle nada a nadie: si no
   cabe, la barra lo baja de línea. El modo flotante (sin .in-bar) queda solo
   como respaldo por si alguna página no tuviera barra superior. */
.friends-btn {
  position: fixed; right: 14px; top: 14px; z-index: 55;
  background: var(--primary); color: #fff; border: none; border-radius: 12px;
  padding: 10px 14px; font-weight: 700; cursor: pointer; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
/* Anclado en la barra: se comporta como un botón más de la fila. */
.friends-btn.in-bar {
  position: static; box-shadow: none; border-radius: 10px;
  padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.friends-btn:hover { background: var(--primary-hover); }
.fbadge {
  background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px;
  font-size: 12px; margin-left: 4px;
}

/* El panel cuelga debajo del botón; friends.js le calcula top/left en vivo y lo
   recorta contra los bordes para que nunca se salga de la pantalla. */
.friends-panel {
  position: fixed; right: 14px; top: 62px; z-index: 55;
  width: 320px; max-width: calc(100vw - 16px);
  max-height: min(70vh, 460px); display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); overflow: hidden;
}
.fp-head { padding: 12px 14px; font-weight: 800; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.fp-list { flex: 1; min-height: 0; overflow-y: auto; }
.fp-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
/* min-width:0 para que un nombre largo se corte con "..." en vez de estirar la
   fila y empujar el resto fuera del panel. */
.fp-meta { flex: 1; min-width: 0; line-height: 1.2; }
.fp-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-rank { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-row .btn { flex-shrink: 0; }
.fp-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.fp-dot.on { background: var(--success); }
.fp-dot.off { background: #667; }
.fp-empty { padding: 16px; color: var(--muted); font-size: 13px; }

.friend-menu {
  position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; width: 190px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.friend-menu .fm-title { font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.btn.block { width: 100%; }

/* Chat privado */
.pm-windows { position: fixed; right: 14px; bottom: 14px; z-index: 58; display: flex; gap: 10px; align-items: flex-end; }
.pm-box {
  width: min(280px, 90vw); background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.pm-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--card2); }
.pm-dot { width: 9px; height: 9px; border-radius: 50%; }
.pm-dot.on { background: var(--success); } .pm-dot.off { background: #667; }
.pm-name { font-weight: 700; font-size: 14px; flex: 1; }
.pm-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.pm-log { height: 200px; overflow-y: auto; padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.pm-msg .pm-who { font-weight: 700; color: var(--primary); }
.pm-msg.mine .pm-who { color: var(--success); }
.pm-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.pm-input input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); outline: none; }

.friend-toast {
  position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%) translateY(20px);
  background: var(--success); color: #04210f; font-weight: 700; padding: 10px 16px;
  border-radius: 10px; z-index: 70; opacity: 0; transition: all .3s; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.friend-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Aviso en rojo (p. ej. "los invitados no pueden agregar amigos"). */
.friend-toast.err {
  background: var(--danger); color: #fff; max-width: min(420px, 92vw); text-align: center;
}

@media (max-width: 560px) {
  .pm-windows { right: 6px; left: 6px; }
  .pm-box { width: 100%; }
}
